Skip to content

Commit

Permalink
added pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak-likes-code committed Dec 27, 2024
1 parent 954e49e commit ab9259d
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/agent-kit-langgraph/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OPENAI_API_KEY=
RPC_URL=
SOLANA_PRIVATE_KEY=
TAVILY_API_KEY= #Optional: for search functionality
11 changes: 11 additions & 0 deletions examples/agent-kit-langgraph/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dependencies
node_modules/
package-lock.json

# Environment variables
.env
.env.local

# Build output
dist/
build/
12 changes: 11 additions & 1 deletion examples/agent-kit-langgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node --loader ts-node/esm"
},
"keywords": [],
"author": "",
Expand All @@ -15,5 +17,13 @@
"@langchain/langgraph": "^0.2.36",
"dotenv": "^16.4.7",
"solana-agent-kit": "^1.3.0"
},
"devDependencies": {
"ts-node": "^10.9.2",
"typescript": "^5.0.0"
},
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
}
139 changes: 136 additions & 3 deletions examples/agent-kit-langgraph/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions examples/agent-kit-langgraph/src/agents/generalAgent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { gpt4o } from "../utils/model.js";
import { solanaAgentState } from "../utils/state.js";
import { TavilySearchResults } from "@langchain/community/tools/tavily_search";
import { HumanMessage } from "@langchain/core/messages";

// Initialize tools array
const searchTools = [];

// Only add Tavily search if API key is available
if (process.env.TAVILY_API_KEY) {
searchTools.push(new TavilySearchResults());
}

export const generalAgent = createReactAgent({
llm: gpt4o,
tools: searchTools,
});

export const generalistNode = async (state: typeof solanaAgentState.State) => {
const { messages } = state;

const result = await generalAgent.invoke({ messages });

return { messages: [...result.messages] };
};

const messages = [new HumanMessage("What is the best way to buy SOL?")];

const result = await generalAgent.invoke({ messages });

console.log(result.messages);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ab9259d

Please sign in to comment.