Skip to content

Commit

Permalink
Merge branch 'develop' into fix-plugin-quick-intel
Browse files Browse the repository at this point in the history
  • Loading branch information
shakkernerd authored Jan 28, 2025
2 parents bfa95c8 + b35c2f0 commit d8949c9
Show file tree
Hide file tree
Showing 33 changed files with 773 additions and 652 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"cookie": "0.7.0",
"bs58": "5.0.0",
"@coral-xyz/anchor": "0.28.0"
},
"patchedDependencies": {
"@solana-developers/helpers": "patches/@solana-developers__helpers.patch"
}
},
"engines": {
Expand All @@ -71,15 +74,15 @@
"@injectivelabs/sdk-ts": "^1.14.33",
"@vitest/eslint-plugin": "1.0.1",
"amqplib": "0.10.5",
"bs58": "4.0.0",
"csv-parse": "5.6.0",
"langdetect": "^0.2.1",
"ollama-ai-provider": "0.16.1",
"optional": "0.1.4",
"pnpm": "9.14.4",
"sharp": "0.33.5",
"bs58": "4.0.0"
"pnpm": "9.15.0",
"sharp": "0.33.5"
},
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee",
"packageManager": "pnpm@9.15.0",
"workspaces": [
"packages/*"
]
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"puppeteer-extra-plugin-capsolver": "2.0.1",
"sharp": "0.33.5",
"srt": "0.0.3",
"systeminformation": "5.23.5",
"systeminformation": "5.23.8",
"tar": "7.4.3",
"tinyld": "1.3.4",
"uuid": "11.0.3",
Expand Down
19 changes: 13 additions & 6 deletions packages/plugin-omniflix/src/actions/bank/send_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class SendTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -128,14 +128,21 @@ const buildTransferDetails = async (
message: Memory,
state: State
): Promise<SendTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);

// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const transferContext = composeContext({
state,
state: currentState,
template: sendTokensTemplate,
});

Expand Down
18 changes: 12 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/cancel_unbonding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class CancelUnbondingAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -135,14 +135,20 @@ const buildCancelUnbondingContent = async (
message: Memory,
state: State
): Promise<CancelUnbondingContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const cancelUnbondingContext = composeContext({
state,
state: currentState,
template: cancelUnbondingTemplate,
});

Expand Down
19 changes: 13 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/delegate_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class DelegateTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -128,14 +128,21 @@ const buildDelegateTokensContent = async (
message: Memory,
state: State
): Promise<DelegateTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);

// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const delegateContext = composeContext({
state,
state: currentState,
template: delegateTokensTemplate,
});

Expand Down
17 changes: 11 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/redelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class RedelegateTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -150,14 +150,19 @@ const buildRedelegateDetails = async (
message: Memory,
state: State
): Promise<RedelegateTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }
let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const redelegateContext = composeContext({
state,
state: currentState,
template: redelegateTokensTemplate,
});

Expand Down
18 changes: 12 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/undelegate_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class UndelegateTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -128,14 +128,20 @@ const buildUndelegateTokensContent = async (
message: Memory,
state: State
): Promise<UndelegateTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const undelegateContext = composeContext({
state,
state: currentState,
template: undelegateTokensTemplate,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-omniflix/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Plugin } from "@elizaos/core";
import type { Plugin } from "@elizaos/core";
import providers from "./providers/index.ts";
import actions from "./actions/index.ts";

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-omniflix/src/providers/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class BankProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in sendTokens: " + e);
elizaLogger.error(`Error in sendTokens: ${e}`);
throw e;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-omniflix/src/providers/gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GovProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in voteOnProposal: " + e);
elizaLogger.error(`Error in voteOnProposal: ${e}`);
throw e;
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-omniflix/src/providers/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in delegate: " + e);
elizaLogger.error(`Error in delegate: ${e}`);
throw e;
}
}
Expand All @@ -53,7 +53,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in undelegate: " + e);
elizaLogger.error(`Error in undelegate: ${e}`);
throw e;
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in redelegate: " + e);
elizaLogger.error(`Error in redelegate: ${e}`);
throw e;
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in cancelUnbondingDelegation: " + e);
elizaLogger.error(`Error in cancelUnbondingDelegation: ${e}`);
throw e;
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/plugin-omniflix/src/providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ export const walletProvider: Provider = {
"omniflix"
);
elizaLogger.info("Wallet initialized with private key");
} else {
} else if (mnemonic) {
// Use mnemonic
wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic!, {
wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
prefix: "omniflix",
});
elizaLogger.info("Wallet initialized with mnemonic");
} else {
throw new Error("Neither private key nor mnemonic available");
}

const client = await SigningStargateClient.connectWithSigner(
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-opacity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class OpacityAdapter implements IVerifiableInferenceAdapter {
});

// Get provider-specific endpoint
let endpoint;
let authHeader;
let endpoint: string;
let authHeader: string;

switch (provider) {
case ModelProviderName.OPENAI:
Expand All @@ -54,7 +54,7 @@ export class OpacityAdapter implements IVerifiableInferenceAdapter {
}

try {
let body;
let body: Record<string, unknown>;
// Handle different API formats
switch (provider) {
case ModelProviderName.OPENAI:
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-opacity/src/utils/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


export async function verifyProof(baseUrl: string, textID: string, proof: string) {
export async function verifyProof(baseUrl: string, _textID: string, proof: string) {
const response = await fetch(`${baseUrl}/api/verify`, {
headers: {
"Content-Type": "application/json",
Expand Down
9 changes: 5 additions & 4 deletions packages/plugin-open-weather/src/actions/getCurrentWeather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ export const getCurrentWeatherAction: Action = {
callback: HandlerCallback
) => {
// Initialize/update state
if (!state) {
state = (await runtime.composeState(message)) as State;
let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
state = await runtime.updateRecentMessageState(state);
currentState = await runtime.updateRecentMessageState(currentState);

// state -> context
const weatherContext = composeContext({
state,
state: currentState,
template: getCurrentWeatherTemplate,
});

Expand Down
25 changes: 22 additions & 3 deletions packages/plugin-openai/src/actions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,27 @@ export function validateApiKey(): string {
* @returns The response data.
* @throws Will throw an error for request failures or rate limits.
*/

export interface OpenAIRequestData {
model: string;
prompt: string;
max_tokens: number;
temperature: number;
[key: string]: unknown;
}

export interface OpenAIEditRequestData {
model: string;
input: string;
instruction: string;
max_tokens: number;
temperature: number;
[key: string]: unknown;
}

export async function callOpenAiApi<T>(
url: string,
data: any,
data: OpenAIRequestData | OpenAIEditRequestData,
apiKey: string,
): Promise<T> {
try {
Expand All @@ -55,7 +73,7 @@ export async function callOpenAiApi<T>(
const response = await axios.post<T>(url, data, config);
return response.data;
} catch (error) {
console.error("Error communicating with OpenAI API:", error.message);
console.error("Error communicating with OpenAI API:", error instanceof Error ? error.message : String(error));
if (axios.isAxiosError(error)) {
if (error.response?.status === 429) {
throw new Error("Rate limit exceeded. Please try again later.");
Expand All @@ -73,12 +91,13 @@ export async function callOpenAiApi<T>(
* @param temperature - The sampling temperature.
* @returns The request payload for OpenAI completions.
*/

export function buildRequestData(
prompt: string,
model: string = DEFAULT_MODEL,
maxTokens: number = DEFAULT_MAX_TOKENS,
temperature: number = DEFAULT_TEMPERATURE,
): Record<string, any> {
): OpenAIRequestData {
return {
model,
prompt,
Expand Down
Loading

0 comments on commit d8949c9

Please sign in to comment.