Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate text based way of generating JSON #920

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export async function generateTextArray({
}
}

export async function generateObject({
export async function generateObjectDEPRECATED({
runtime,
context,
modelClass,
Expand All @@ -682,7 +682,7 @@ export async function generateObject({
modelClass: string;
}): Promise<any> {
if (!context) {
elizaLogger.error("generateObject context is empty");
elizaLogger.error("generateObjectDEPRECATED context is empty");
return null;
}
let retryDelay = 1000;
Expand Down Expand Up @@ -1111,7 +1111,7 @@ export const generateObjectV2 = async ({
mode = "json",
}: GenerationOptions): Promise<GenerateObjectResult<unknown>> => {
if (!context) {
const errorMessage = "generateObject context is empty";
const errorMessage = "generateObjectV2 context is empty";
console.error(errorMessage);
throw new Error(errorMessage);
}
Expand Down Expand Up @@ -1204,7 +1204,7 @@ export async function handleProvider(
case ModelProviderName.GROQ:
return await handleGroq(options);
case ModelProviderName.LLAMALOCAL:
return await generateObject({
return await generateObjectDEPRECATED({
runtime,
context,
modelClass,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-aptos/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
type Action,
} from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza";
import { generateObject } from "@ai16z/eliza";
import { generateObjectDEPRECATED } from "@ai16z/eliza";
import {
Account,
Aptos,
Expand All @@ -27,7 +27,7 @@
amount: string | number;
}

function isTransferContent(content: any): content is TransferContent {

Check warning on line 30 in packages/plugin-aptos/src/actions/transfer.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected any. Specify a different type
console.log("Content for transfer", content);
return (
typeof content.recipient === "string" &&
Expand Down Expand Up @@ -111,7 +111,7 @@
});

// Generate transfer content
const content = await generateObject({
const content = await generateObjectDEPRECATED({
runtime,
context: transferContext,
modelClass: ModelClass.SMALL,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-flow/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
composeContext,
Content,
elizaLogger,
generateObject,
generateObjectDEPRECATED,
ModelClass,
type Action,
type ActionExample,
Expand Down Expand Up @@ -87,7 +87,7 @@ export class TransferAction {
});

// Generate transfer content
const content = await generateObject({
const content = await generateObjectDEPRECATED({
runtime,
context: transferContext,
modelClass: ModelClass.SMALL,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-icp/src/actions/createToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
composeContext,
generateImage,
generateText,
generateObject,
generateObjectDEPRECATED,
} from "@ai16z/eliza";
import {
ActionExample,
Expand Down Expand Up @@ -148,7 +148,7 @@ export const executeCreateToken: Action = {
template: createTokenTemplate,
});

const response = await generateObject({
const response = await generateObjectDEPRECATED({
runtime,
context: createTokenContext,
modelClass: ModelClass.LARGE,
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-solana/src/actions/pumpfun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Memory,
ModelClass,
State,
generateObject,
generateObjectDEPRECATED,
composeContext,
type Action,
} from "@ai16z/eliza";
Expand Down Expand Up @@ -262,8 +262,8 @@ Example response:
Given the recent messages, extract or generate (come up with if not included) the following information about the requested token creation:
- Token name
- Token symbol
- Token description
- Token image description
- Token description
- Token image description
- Amount of SOL to buy

Respond with a JSON markdown block containing only the extracted values.`;
Expand Down Expand Up @@ -302,7 +302,7 @@ export default {
template: pumpfunTemplate,
});

const content = await generateObject({
const content = await generateObjectDEPRECATED({
runtime,
context: pumpContext,
modelClass: ModelClass.LARGE,
Expand All @@ -325,7 +325,7 @@ export default {
height: 512,
count: 1
}, runtime);

if (imageResult.success && imageResult.data && imageResult.data.length > 0) {
// Remove the "data:image/png;base64," prefix if present
tokenMetadata.file = imageResult.data[0].replace(/^data:image\/[a-z]+;base64,/, '');
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-solana/src/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
State,
type Action,
composeContext,
generateObject,
generateObjectDEPRECATED,
settings,
} from "@ai16z/eliza";
import { TokenProvider } from "../providers/token.ts";
Expand Down Expand Up @@ -110,7 +110,7 @@ Example response:
\`\`\`json
{
"inputTokenSymbol": "SOL",
"outputTokenSymbol": "USDC",
"outputTokenSymbol": "USDC",
"inputTokenCA": "So11111111111111111111111111111111111111112",
"outputTokenCA": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 1.5
Expand All @@ -125,7 +125,7 @@ Given the recent messages and wallet information below:

Extract the following information about the requested token swap:
- Input token symbol (the token being sold)
- Output token symbol (the token being bought)
- Output token symbol (the token being bought)
- Input token contract address if provided
- Output token contract address if provided
- Amount to swap
Expand All @@ -134,7 +134,7 @@ Respond with a JSON markdown block containing only the extracted values. Use nul
\`\`\`json
{
"inputTokenSymbol": string | null,
"outputTokenSymbol": string | null,
"outputTokenSymbol": string | null,
"inputTokenCA": string | null,
"outputTokenCA": string | null,
"amount": number | string | null
Expand Down Expand Up @@ -209,7 +209,7 @@ export const executeSwap: Action = {
template: swapTemplate,
});

const response = await generateObject({
const response = await generateObjectDEPRECATED({
runtime,
context: swapContext,
modelClass: ModelClass.LARGE,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-solana/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
type Action,
} from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza";
import { generateObject } from "@ai16z/eliza";
import { generateObjectDEPRECATED } from "@ai16z/eliza";

export interface TransferContent extends Content {
tokenAddress: string;
Expand Down Expand Up @@ -119,7 +119,7 @@ export default {
});

// Generate transfer content
const content = await generateObject({
const content = await generateObjectDEPRECATED({
runtime,
context: transferContext,
modelClass: ModelClass.LARGE,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-starknet/src/actions/subdomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
State,
type Action,
composeContext,
generateObject,
generateObjectDEPRECATED,
Content,
elizaLogger,
} from "@ai16z/eliza";
Expand Down Expand Up @@ -107,7 +107,7 @@ export default {
});

// Generate transfer content
const content = await generateObject({
const content = await generateObjectDEPRECATED({
runtime,
context: transferContext,
modelClass: ModelClass.MEDIUM,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-starknet/src/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ActionExample,
composeContext,
elizaLogger,
generateObject,
generateObjectDEPRECATED,
HandlerCallback,
IAgentRuntime,
Memory,
Expand Down Expand Up @@ -105,7 +105,7 @@ export const executeSwap: Action = {
template: swapTemplate,
});

const response = await generateObject({
const response = await generateObjectDEPRECATED({
runtime,
context: swapContext,
modelClass: ModelClass.MEDIUM,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-starknet/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
composeContext,
Content,
elizaLogger,
generateObject,
generateObjectDEPRECATED,
HandlerCallback,
IAgentRuntime,
Memory,
Expand Down Expand Up @@ -136,7 +136,7 @@ export default {
});

// Generate transfer content
const content = await generateObject({
const content = await generateObjectDEPRECATED({
runtime,
context: transferContext,
modelClass: ModelClass.MEDIUM,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-starknet/src/actions/unruggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ActionExample,
composeContext,
elizaLogger,
generateObject,
generateObjectDEPRECATED,
HandlerCallback,
IAgentRuntime,
Memory,
Expand Down Expand Up @@ -102,7 +102,7 @@ export const deployToken: Action = {
template: deployTemplate,
});

const response = await generateObject({
const response = await generateObjectDEPRECATED({
runtime,
context: deployContext,
modelClass: ModelClass.MEDIUM,
Expand Down
Loading