mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-06-07 23:26:49 +00:00
fin
This commit is contained in:
22
examples/agent-kit-langgraph/src/agents/readAgent.ts
Normal file
22
examples/agent-kit-langgraph/src/agents/readAgent.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
||||
import { gpt4o } from "../utils/model";
|
||||
import { solanaAgentState } from "../utils/state";
|
||||
import { HumanMessage } from "@langchain/core/messages";
|
||||
import { agentKit } from "../utils/solanaAgent";
|
||||
import {
|
||||
SolanaBalanceTool,
|
||||
SolanaFetchPriceTool,
|
||||
} from "solana-agent-kit/dist/langchain";
|
||||
|
||||
const readAgent = createReactAgent({
|
||||
llm: gpt4o,
|
||||
tools: [new SolanaBalanceTool(agentKit), new SolanaFetchPriceTool(agentKit)],
|
||||
});
|
||||
|
||||
export const readNode = async (state: typeof solanaAgentState.State) => {
|
||||
const { messages } = state;
|
||||
|
||||
const result = await readAgent.invoke({ messages });
|
||||
|
||||
return { messages: [...result.messages] };
|
||||
};
|
||||
Reference in New Issue
Block a user