This commit is contained in:
Arihant Bansal
2024-11-27 16:52:12 +05:30
parent 92651642e8
commit 2658a88753
6 changed files with 181 additions and 48 deletions

View File

@@ -1,48 +1,42 @@
import { SolanaAgentKit } from "../src";
import { createSolanaTools } from "../src/langchain";
import { OpenAI } from "@langchain/openai";
import { AgentExecutor } from "langchain/agents";
import { PromptTemplate } from "@langchain/core/prompts";
import { pull } from "langchain/hub";
import { createReactAgent } from "langchain/agents";
// import { SolanaAgentKit } from "../src";
// import { createSolanaTools } from "../src/langchain";
// import { OpenAI } from "@langchain/openai";
// import { AgentExecutor } from "langchain/agents";
// import { PromptTemplate } from "@langchain/core/prompts";
// import { pull } from "langchain/hub";
// import { createReactAgent } from "langchain/agents";
// Initialize SolanaAgentKit
const solanaKit = new SolanaAgentKit(
"",
"https://mainnet.helius-rpc.com/?api-key="
);
// // Initialize SolanaAgentKit
// const solanaKit = new SolanaAgentKit(undefined, "rpc-url");
solanaKit.connection.getRecentPrioritizationFees
// // Create Solana-specific tools
// const tools = createSolanaTools(solanaKit);
// Create Solana-specific tools
const tools = createSolanaTools(solanaKit);
// (async () => {
// // Define a Prompt Template for the Agent
// const prompt = await pull<PromptTemplate>("hwchase17/react");
(async () => {
// Define a Prompt Template for the Agent
const prompt = await pull<PromptTemplate>("hwchase17/react");
// // Create an LLM Chain
// const llm = new OpenAI({
// modelName: "gpt-4o-mini",
// temperature: 0,
// });
// Create an LLM Chain
const llm = new OpenAI({
modelName: "gpt-4o-mini",
temperature: 0,
});
// const agent = await createReactAgent({
// llm,
// tools,
// prompt,
// });
const agent = await createReactAgent({
llm,
tools,
prompt,
});
// const agentExecutor = new AgentExecutor({
// agent,
// tools,
// maxIterations: 50,
// });
const agentExecutor = new AgentExecutor({
agent,
tools,
maxIterations: 50,
});
// const result = await agentExecutor.invoke({
// input: "Deploy a token with 6 decimals ",
// });
const result = await agentExecutor.invoke({
input:
"Deploy a token with 6 decimals ",
});
console.log(result);
})();
// console.log(result);
// })();