Skip to content

Commit

Permalink
Merge branch 'feat/genlayer-plugin' of https://github.com/yeagerai/eliza
Browse files Browse the repository at this point in the history
 into HEAD
  • Loading branch information
lalalune committed Jan 5, 2025
2 parents b808c24 + b5ba91c commit 34d64ad
Show file tree
Hide file tree
Showing 34 changed files with 3,606 additions and 2,936 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,5 @@ FUEL_WALLET_PRIVATE_KEY=
# Tokenizer Settings
TOKENIZER_MODEL= # Specify the tokenizer model to be used.
TOKENIZER_TYPE= # Options: tiktoken (for OpenAI models) or auto (AutoTokenizer from Hugging Face for non-OpenAI models). Default: tiktoken.
# GenLayer
GENLAYER_PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000 # Private key of the GenLayer account to use for the agent
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
- chore: bump version to v0.1.7-alpha.1 [\#1361](https://github.com/elizaOS/eliza/pull/1361) ([shakkernerd](https://github.com/shakkernerd))
- chore: New version 0.1.7 alpha.1 [\#1360](https://github.com/elizaOS/eliza/pull/1360) ([shakkernerd](https://github.com/shakkernerd))
- chore: develop -\> main, change elizaos/eliza to elizaos/core [\#1359](https://github.com/elizaOS/eliza/pull/1359) ([lalalune](https://github.com/lalalune))
- feat: change @elizaos/eliza to @elizaos/core [\#1357](https://github.com/elizaOS/eliza/pull/1357) ([lalalune](https://github.com/lalalune))
- feat: change @elizaos/core to @elizaos/core [\#1357](https://github.com/elizaOS/eliza/pull/1357) ([lalalune](https://github.com/lalalune))
- chore: Merge Develop into Main [\#1356](https://github.com/elizaOS/eliza/pull/1356) ([lalalune](https://github.com/lalalune))
- chore: revert discord url [\#1355](https://github.com/elizaOS/eliza/pull/1355) ([madjin](https://github.com/madjin))
- Update DOCUMENTATION links to point to https://elizaOS.github.io/eliza/ [\#1353](https://github.com/elizaOS/eliza/pull/1353) ([imwylin](https://github.com/imwylin))
Expand Down Expand Up @@ -502,7 +502,7 @@
- Agent Responds Twice to prompts [\#726](https://github.com/elizaOS/eliza/issues/726)
- Twitter Client Breaks out of the box [\#673](https://github.com/elizaOS/eliza/issues/673)
- Twitter client only works for one agent when running multiple agents simultaneously [\#656](https://github.com/elizaOS/eliza/issues/656)
- Cannot find module '@ai16z/eliza' or its corresponding type declarations. [\#601](https://github.com/elizaOS/eliza/issues/601)
- Cannot find module '@elizaos/core' or its corresponding type declarations. [\#601](https://github.com/elizaOS/eliza/issues/601)
- create-eliza-app package doesn't install or exist [\#553](https://github.com/elizaOS/eliza/issues/553)
- Non node.js environments have issues building \(workers for instance\) [\#507](https://github.com/elizaOS/eliza/issues/507)
- Error: Property 'clients' does not exist on type 'Plugin' in src/index.ts during pnpm start [\#423](https://github.com/elizaOS/eliza/issues/423)
Expand Down Expand Up @@ -1259,7 +1259,7 @@
- feat: Add Heurist API Integration as New Model Provider [\#335](https://github.com/elizaOS/eliza/pull/335) ([tsubasakong](https://github.com/tsubasakong))
- Docs: additional Quickstart clarification and improvements [\#334](https://github.com/elizaOS/eliza/pull/334) ([odilitime](https://github.com/odilitime))
- Docs: README.md improvements: clarify testing, add additional docker information [\#333](https://github.com/elizaOS/eliza/pull/333) ([odilitime](https://github.com/odilitime))
- fix: Build error for packages requiring @ai16z/eliza [\#331](https://github.com/elizaOS/eliza/pull/331) ([shakkernerd](https://github.com/shakkernerd))
- fix: Build error for packages requiring @elizaos/core [\#331](https://github.com/elizaOS/eliza/pull/331) ([shakkernerd](https://github.com/shakkernerd))
- claude vertex configs added to generation.ts \(was missing\) [\#330](https://github.com/elizaOS/eliza/pull/330) ([denizekiz](https://github.com/denizekiz))
- README\_KOR.md Korean version edited by a Korean [\#329](https://github.com/elizaOS/eliza/pull/329) ([zo-eth](https://github.com/zo-eth))
- Save Trade on creation to the backend [\#328](https://github.com/elizaOS/eliza/pull/328) ([MarcoMandar](https://github.com/MarcoMandar))
Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@elizaos/plugin-fuel": "workspace:*",
"@elizaos/plugin-avalanche": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-genlayer": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand Down
31 changes: 17 additions & 14 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
import { RedisClient } from "@elizaos/adapter-redis";
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
import { AutoClientInterface } from "@elizaos/client-auto";
import { DiscordClientInterface } from "@elizaos/client-discord";
Expand All @@ -10,31 +11,33 @@ import { TwitterClientInterface } from "@elizaos/client-twitter";
import {
AgentRuntime,
CacheManager,
CacheStore,
Character,
Client,
Clients,
DbCacheAdapter,
defaultCharacter,
elizaLogger,
FsCacheAdapter,
IAgentRuntime,
ICacheManager,
IDatabaseAdapter,
IDatabaseCacheAdapter,
ModelProviderName,
settings,
stringToUuid,
validateCharacterConfig,
CacheStore,
Client,
ICacheManager,
parseBooleanFromText,
validateCharacterConfig
} from "@elizaos/core";
import { RedisClient } from "@elizaos/adapter-redis";
import { zgPlugin } from "@elizaos/plugin-0g";
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
import createGoatPlugin from "@elizaos/plugin-goat";
// import { intifacePlugin } from "@elizaos/plugin-intiface";
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
import { DirectClient } from "@elizaos/client-direct";
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
import { abstractPlugin } from "@elizaos/plugin-abstract";
import { aptosPlugin } from "@elizaos/plugin-aptos";
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
import {
advancedTradePlugin,
coinbaseCommercePlugin,
Expand All @@ -44,32 +47,29 @@ import {
webhookPlugin,
} from "@elizaos/plugin-coinbase";
import { confluxPlugin } from "@elizaos/plugin-conflux";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
import { evmPlugin } from "@elizaos/plugin-evm";
import { storyPlugin } from "@elizaos/plugin-story";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
import { nearPlugin } from "@elizaos/plugin-near";
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
import { createNodePlugin } from "@elizaos/plugin-node";
import { solanaPlugin } from "@elizaos/plugin-solana";
import { storyPlugin } from "@elizaos/plugin-story";
import { suiPlugin } from "@elizaos/plugin-sui";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { tonPlugin } from "@elizaos/plugin-ton";
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { abstractPlugin } from "@elizaos/plugin-abstract";
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import Database from "better-sqlite3";
import fs from "fs";
import net from "net";
import path from "path";
import { fileURLToPath } from "url";
import yargs from "yargs";
import net from "net";

const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory
Expand Down Expand Up @@ -609,6 +609,9 @@ export async function createAgent(
getSecret(character, "ECHOCHAMBERS_API_KEY")
? echoChamberPlugin
: null,
getSecret(character, "GENLAYER_PRIVATE_KEY")
? genLayerPlugin
: null,
].filter(Boolean),
providers: [],
actions: [],
Expand Down
12 changes: 9 additions & 3 deletions docs/community/Discord/development/coders/chat_2024-12-05.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# 💻-coders 2024-12-05

## Summary

The discussion focused on creating custom plugins, running them from .json files to TS configs. Lambert successfully ran his methods using 'plugins: []' without modifying agent/src/index.ts but with custom clients calling the plugin. Ayvaras mentioned memory consumption issues needing optimization.

## FAQ

- Is there a ts equivalent for running a character from a json file? How to import and use custom plugins in agent/src/index.ts? (asked by [DL])
- How did you solve the memory consumption issue with your uncensored model? (asked by [nylon, nylon])
- What's the difference between Solana plugin and Goat one? How to login with cookies in browser, then copy into .env file following specific syntax mentioned somewhere on README? (asked by [SotoAlt | WAWE])
Expand All @@ -16,20 +18,22 @@ The discussion focused on creating custom plugins, running them from .json files
- Why am I getting an error when trying to generate a new tweet? What should be in the .env file for it to work correctly? (asked by @Manasvi)

## Who Helped Who

- [DL] helped [dl] with Create a custom plugin for characters and import it into the ts file. by providing Odilitime explained how to set up character object in agent/src/index.ts.
- [coinwitch (ai16z intern)] helped [SotoAlt | WAWE] with Troubleshooting Eliza Agent by providing coinwitch helped with getting the agent working in eliza-starter project.
- @sototal helped @ayvaras with Resolving server IP change issue by providing SotoAlt | WAWE suggested using cookies for login and enabling 2FA as a solution.
- 'Try without' and 'nah my agent doesn't have any', suggesting Ayvaras to test the software feature with cookies disabled. helped [Ayvaras (02:39, 02:41)] with 'Investigate why setting VPN doesn't work' by providing [lambert (02:38, 02:40)]
- @lambert, @Tharakesh helped @Ayvaras with Troubleshooting cookie usage in the application by providing Ayvaras asked for help with cookies and database deletion
- @lambert helped @Manasvi with Troubleshooting error in Eliza project. by providing Provided guidance on checking Twitter API credentials and ensuring correct setup.
- frenchplace helped problem with loading content into memory via API or commands with loading sources for agent's knowledge by providing Robotic Dreams provided a solution on how to specify plugins in character file and set required fields.
- @DL helped @cleverson1 with Resolving Twitter integration issue with @ai16z/plugin-image-generation. by providing DL (@ai16z) provided guidance on using image plugin without specifying plugins field and ensuring correct AI API keys are used.
- @DL helped @cleverson1 with Resolving Twitter integration issue with @elizaos/plugin-image-generation. by providing DL (@ai16z) provided guidance on using image plugin without specifying plugins field and ensuring correct AI API keys are used.
- [Bunchu] helped [Cleverson1] with Adding web search plugin by providing @bunchu helped @cleverson1 by providing steps to add a plugin and resolve image posting issue.
- kungfumode helped Agent Issue Resolution Successful. with Tweet formatting by providing Ayvaras provided a PR to fix the issue of agents posting multi-line tweets.

## Action Items

### Technical Tasks

- Create a custom plugin for character files (mentioned by [DL, lambert])
- Create a TG token bot (mentioned by [SotoAlt | WAWE])
- Watch Agent Dev School videos for learning (mentioned by @coinwitch)
Expand All @@ -45,12 +49,14 @@ The discussion focused on creating custom plugins, running them from .json files
- Fix tweet formatting issue by applying PR #856 (mentioned by Ayvaras)

### Documentation Needs

- Optimize memory consumption of the uncensored model. (mentioned by Ayvaras)
- Fix the issue with `Cannot GET /` error in eliza-starter project. (mentioned by [coinwitch (ai16z intern)])
- Ensure the .env file contains correct Twitter account details. (mentioned by Ayvaras)
- Use pnpm run build for Twitter agent and terminal runtime agent, investigate if possible. (mentioned by Konstantine)
- Create a GitHub issue to address image plugin documentation (mentioned by @coinwitch (ai16z intern))
- Add @ai16z/plugin-web-search to dependencies in package.json and import it into index.ts. (mentioned by [Bunchu])
- Add @elizaos/plugin-web-search to dependencies in package.json and import it into index.ts. (mentioned by [Bunchu])

### Feature Requests
- Resolve server IP change issue by using cookies or enabling two-factor authentication (2FA) (mentioned by @SotoAlt | WAWE)

- Resolve server IP change issue by using cookies or enabling two-factor authentication (2FA) (mentioned by @SotoAlt | WAWE)
1 change: 0 additions & 1 deletion packages/plugin-aptos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"dependencies": {
"@elizaos/core": "workspace:*",
"@aptos-labs/ts-sdk": "^1.26.0",
"bignumber": "1.1.0",
"bignumber.js": "9.1.2",
"node-cache": "5.1.2",
"tsup": "8.3.5",
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-cronoszkevm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
],
"dependencies": {
"@elizaos/core": "workspace:*",
"@elizaos/plugin-trustdb": "workspace:*",
"tsup": "^8.3.5",
"web3": "^4.15.0",
"web3-plugin-zksync": "^1.0.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-cronoszkevm/src/enviroment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAgentRuntime } from "@elizaos/eliza";
import { IAgentRuntime } from "@elizaos/core";
import { z } from "zod";

export const CronosZkEVMEnvSchema = z.object({
Expand Down
18 changes: 18 additions & 0 deletions packages/plugin-genlayer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@elizaos/plugin-genlayer",
"version": "0.1.0",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix",
"test": "vitest run"
},
"dependencies": {
"genlayer-js": "0.4.7",
"@elizaos/core": "workspace:*",
"tsup": "8.3.5"
}
}
150 changes: 150 additions & 0 deletions packages/plugin-genlayer/src/actions/deployContract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import {
Action,
HandlerCallback,
IAgentRuntime,
Memory,
State,
elizaLogger,
} from "@elizaos/core";
import fs from "fs";
import { DeployContractParams } from "../types";
import { ClientProvider } from "../providers/client";
import { getParamsWithLLM } from "../utils/llm";

const deployContractTemplate = `
# Task: Determine the contract code file path and constructor arguments for deploying a contract.
# Instructions: The user is requesting to deploy a contract to the GenLayer protocol.
<latest user message>
{{userMessage}}
</latest user message>
<data from recent messages>
{{recentMessagesData}}
</data from recent messages>
# Your response must be formatted as a JSON block with this structure:
\`\`\`json
{
"code_file": "<Contract Code File Path>",
"args": [<Constructor Args>],
"leaderOnly": <true/false>
}
\`\`\`
`;

export const deployContractAction: Action = {
name: "DEPLOY_CONTRACT",
similes: ["DEPLOY_CONTRACT"],
description: "Deploy a contract to the GenLayer protocol",
validate: async (runtime: IAgentRuntime) => {
const privateKey = runtime.getSetting("GENLAYER_PRIVATE_KEY");
return typeof privateKey === "string" && privateKey.startsWith("0x");
},
handler: async (
runtime: IAgentRuntime,
message: Memory,
state: State,
_options: any,
callback: HandlerCallback
) => {
elizaLogger.info("Starting deploy contract action");
elizaLogger.debug("User message:", message.content.text);

const clientProvider = new ClientProvider(runtime);
const options = await getParamsWithLLM<DeployContractParams>(
runtime,
message,
deployContractTemplate,
state
);

if (!options) {
elizaLogger.error("Failed to parse deploy contract parameters");
throw new Error("Failed to parse deploy contract parameters");
}

elizaLogger.debug("Parsed parameters:", options);
elizaLogger.info(
"Deploying contract with code length:",
options.code_file.length
);

const code = await fs.readFileSync(options.code_file, "utf8");

const result = await clientProvider.client.deployContract({
code: code,
args: options.args,
leaderOnly: options.leaderOnly,
});

elizaLogger.success(
`Successfully sent contract for deployment. Transaction hash: ${result}`
);
await callback(
{
text: `Successfully sent contract for deployment. Transaction hash: ${result}`,
},
[]
);
},
examples: [
[
{
user: "{{user1}}",
content: {
text: "Deploy a new contract from /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py with the argument 'true'",
},
},
{
user: "{{agentName}}",
content: {
text: "Deploying contract...",
action: "DEPLOY_CONTRACT",
},
},
],
[
{
user: "{{user1}}",
content: {
text: "Please help me deploy a contract",
},
},
{
user: "{{agentName}}",
content: {
text: "Sure! I'll help you deploy a contract. Please provide the code file path and constructor arguments.",
action: "CONTINUE",
},
},
{
user: "{{user1}}",
content: {
text: "The code file is /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py",
},
},
{
user: "{{agentName}}",
content: {
text: "Understood, I'll help you deploy the contract from /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py. Now, please provide the constructor arguments.",
action: "CONTINUE",
},
},
{
user: "{{user1}}",
content: {
text: "The constructor argument is 'true'",
},
},
{
user: "{{agentName}}",
content: {
text: "Perfect, I'll help you deploy the contract from /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py with the argument 'true'.",
action: "DEPLOY_CONTRACT",
},
},
],
],
};
Loading

0 comments on commit 34d64ad

Please sign in to comment.