Skip to content

Commit

Permalink
Merge branch 'feature/open_ai'
Browse files Browse the repository at this point in the history
* feature/open_ai:
  adjustments to include comments or package name fix, and .env.sample update
  • Loading branch information
rsoury committed Jan 13, 2025
2 parents f847449 + 7763d80 commit 0af7ff2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ APTOS_ORACLE_ADDRESS=""
APTOS_INDEXER_CRON="*/5 * * * * *"
APTOS_PRIVATE_KEY=""

X_API_KEY=""
X_API_SECRET=""

# Postgres config
POSTGRES_USER=user
POSTGRES_DB=xxxxxxxxx
Expand All @@ -24,3 +21,9 @@ DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres_db:543
# Optionals
SENTRY_DSN=""
ECDSA_PRIVATE_KEY="" # for verity analysis.

# Integrations
X_API_KEY=""
X_API_SECRET=""

OPEN_AI_TOKEN=""
4 changes: 2 additions & 2 deletions orchestrator/src/integrations/openAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const chatSchema = Joi.object({
}).required(),
),
});
export default class TwitterIntegration extends BasicBearerAPIHandler {
export default class OpenAIIntegration extends BasicBearerAPIHandler {
validatePayload(path: string, payload: string): boolean {
try {
if (this.supported_paths.includes(path)) {
Expand All @@ -33,7 +33,7 @@ export default class TwitterIntegration extends BasicBearerAPIHandler {
}
}

export const instance = new TwitterIntegration(
export const instance = new OpenAIIntegration(
env.integrations.xBearerToken,
["api.openai.com"],
["/v1/chat/completions"],
Expand Down
2 changes: 1 addition & 1 deletion rooch/Move.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "verity-move-@orchestrators"
name = "verity-move-oracles"
version = "0.0.1"

[dependencies]
Expand Down
2 changes: 2 additions & 0 deletions rooch/sources/oracle_registry.move
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module verity::registry {
let supported_urls = &account::borrow_resource<GlobalParams>(@verity).supported_urls;

let url = string_utils::to_lower_case(&url);
// Is the Orchestrator registered as an Oracle?
if (simple_map::contains_key(supported_urls, &orchestrator)) {
let orchestrator_urls = simple_map::borrow(supported_urls, &orchestrator);

Expand All @@ -89,6 +90,7 @@ module verity::registry {
if (orchestrator_url.minimum_payload_length > payload_length) {
return option::none()
};
// The minimum_payload_length covers for metadata associated request payload.
let chargeable_token: u256 = ((payload_length as u256) - (orchestrator_url.minimum_payload_length as u256));
return option::some(
orchestrator_url.base_fee +
Expand Down
4 changes: 4 additions & 0 deletions rooch/sources/oracles.move
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module verity::oracles {
oracle: address,
response_status: u16,
response: Option<String>,
// This is an account to be paid back by the Contract in case of excess payment.
account_to_credit: address,
amount: u256
}
Expand All @@ -62,6 +63,8 @@ module verity::oracles {
struct GlobalParams has key {
owner: address,
treasury: Object<CoinStore<RGas>>,
// Holds the address of each requesting Contract and their balance
// Either a calling Contract, or a User adjust the balance.
balances: SimpleMap<address, u256>,
}

Expand Down Expand Up @@ -196,6 +199,7 @@ module verity::oracles {
): ObjectID {
let sent_coin = coin::value(&payment);
// 1024 could be changed to the max string length allowed on Move
// This 1024 is a default estaimate for the expected payload length, however, it's the user's responsibility to cover in case of requests that expect large payload responses.
let option_min_amount = OracleSupport::estimated_cost(oracle, params.url, string::length(&params.body), 1024);
assert!(option::is_some(&option_min_amount), OracleSupportError);
let min_amount = option::destroy_some(option_min_amount);
Expand Down

0 comments on commit 0af7ff2

Please sign in to comment.