mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-06-08 07:36:45 +00:00
added write functionalities ie, swap and transfer
This commit is contained in:
48
examples/agent-kit-langgraph/src/prompts/manager.ts
Normal file
48
examples/agent-kit-langgraph/src/prompts/manager.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { StructuredOutputParser } from "@langchain/core/output_parsers";
|
||||
import { z } from "zod";
|
||||
import { PromptTemplate } from "@langchain/core/prompts";
|
||||
|
||||
export const parser = StructuredOutputParser.fromZodSchema(
|
||||
z.object({
|
||||
isSolanaReadQuery: z
|
||||
.boolean()
|
||||
.describe("Query requires reading data from Solana blockchain"),
|
||||
isSolanaWriteQuery: z
|
||||
.boolean()
|
||||
.describe("Query requires writing/modifying data on Solana blockchain"),
|
||||
isGeneralQuery: z
|
||||
.boolean()
|
||||
.describe("Query is about non-blockchain topics"),
|
||||
}),
|
||||
);
|
||||
|
||||
export const prompt = PromptTemplate.fromTemplate(
|
||||
`
|
||||
You are the Chief Routing Officer for a multi-blockchain agent network. Your role is to:
|
||||
1. Analyze and classify incoming queries
|
||||
2. Determine if the query requires Solana read operations, write operations, or is general
|
||||
|
||||
Format your response according to:
|
||||
{formatInstructions}
|
||||
|
||||
Classification Guidelines:
|
||||
- Solana Read Operations include:
|
||||
* Checking account balances
|
||||
* Viewing NFT metadata
|
||||
* Getting program data
|
||||
* Querying transaction history
|
||||
* Checking token prices or holdings
|
||||
- Solana Write Operations include:
|
||||
* Creating or updating programs
|
||||
* Sending tokens or SOL
|
||||
* Minting NFTs
|
||||
* Creating accounts
|
||||
* Any transaction that modifies blockchain state
|
||||
- General queries include:
|
||||
* Non-blockchain topics
|
||||
* Internet searches
|
||||
* General knowledge questions
|
||||
|
||||
\n {messages} \n
|
||||
`,
|
||||
);
|
||||
43
examples/agent-kit-langgraph/src/prompts/transferSwap.ts
Normal file
43
examples/agent-kit-langgraph/src/prompts/transferSwap.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
ChatPromptTemplate,
|
||||
MessagesPlaceholder,
|
||||
} from "@langchain/core/prompts";
|
||||
import { tokenList } from "../helper/tokenList";
|
||||
|
||||
// Convert token list to a more readable format for the prompt
|
||||
const formattedTokenList = tokenList
|
||||
.map(
|
||||
(token) =>
|
||||
`- ${token.name} (${token.ticker}) - Decimals: ${token.decimal} - Address: ${token.mintAddress}`,
|
||||
)
|
||||
.join("\n ");
|
||||
|
||||
export const transferSwapPrompt = ChatPromptTemplate.fromMessages([
|
||||
[
|
||||
"system",
|
||||
`You are an agent that is an expert in Solana transactions, specialized in token transfers and swaps. You can execute these transactions using the available tools based on user input.
|
||||
|
||||
When processing token amounts:
|
||||
1. Use EXACTLY the decimal amount specified by the user without any modifications
|
||||
2. Do not round or adjust the numbers
|
||||
3. Maintain precise decimal places as provided in the user input
|
||||
|
||||
For transfers:
|
||||
- User must specify the token, amount, and recipient address
|
||||
- The same token will be used for input and output
|
||||
|
||||
For swaps:
|
||||
- User must specify the input token, output token, and amount to swap
|
||||
- Input and output tokens must be different
|
||||
- Select tokens from this list of supported tokens:
|
||||
|
||||
${formattedTokenList}
|
||||
|
||||
Example amounts:
|
||||
If you say "0.01 SOL", I will use exactly 0.01 (not 0.010 or 0.0100)
|
||||
If you say "1.234 USDC", I will use exactly 1.234 (not 1.23 or 1.2340)
|
||||
For swaps, have the slippage be 200 bps
|
||||
`,
|
||||
],
|
||||
new MessagesPlaceholder("messages"),
|
||||
]);
|
||||
Reference in New Issue
Block a user