Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
thearyanag committed Feb 11, 2025
1 parent 4569b98 commit 567cc50
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,23 @@ export async function main(argv: string[]) {
}
},
}),
openaiApiKey: () =>
model: () =>
p.select({
message: "Choose your AI model:",
options: [
{ value: "claude-sonnet", label: "Claude Sonnet"},
{ value: "gpt-4", label: "GPT-4" },
{ value: "deepseek-chat", label: "DeepSeek Chat" },
],
}),
apiKey: (results) =>
p.text({
message: "DeepSeek or OpenAI API Key:",
message: `${results.results.model === "claude-sonnet" ? "Anthropic" : results.results.model === "gpt-4" ? "OpenAI" : "DeepSeek"} API Key:`,
placeholder: "sk-...",
defaultValue: "",
validate(value) {
if (!value) {
return "DeepSeek or OpenAI API Key is required";
return "API Key is required";
}
},
}),
Expand All @@ -110,7 +119,7 @@ export async function main(argv: string[]) {
},
);

const { projectName, rpcURL, openaiApiKey, solanaPrivateKey } = group;
const { projectName, rpcURL, model, apiKey, solanaPrivateKey } = group;

const finalProjectName = projectName || defaultProjectName;
const finalRpcURL = rpcURL || defaultRpcURL;
Expand All @@ -128,9 +137,13 @@ export async function main(argv: string[]) {
await fs.promises.writeFile(pkgPath, JSON.stringify(pkg, null, 2));

const envPath = path.join(root, ".env");
const apiKeyName = model === "claude-sonnet" ? "ANTHROPIC_API_KEY"
: model === "gpt-4" ? "OPENAI_API_KEY"
: "DEEPSEEK_API_KEY";

await fs.promises.writeFile(
envPath,
`OPENAI_API_KEY=${openaiApiKey}\nRPC_URL=${finalRpcURL}\nSOLANA_PRIVATE_KEY=${solanaPrivateKey}`,
`MODEL=${model}\n${apiKeyName}=${apiKey}\nRPC_URL=${finalRpcURL}\nSOLANA_PRIVATE_KEY=${solanaPrivateKey}`,
);

spinner.succeed();
Expand Down
4 changes: 4 additions & 0 deletions templates/next/components/chat/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { AGENT_MODES } from "./ModeSelector";
import { DropdownComp } from "./WalletSelector";
import { useEffect, useState } from "react";
export const MOCK_MODELS = [
{
name: "Claude",
subTxt: "Claude 3.5 Sonnet",
},
{
name: "OpenAI",
subTxt: "GPT-4o-mini",
Expand Down
9 changes: 8 additions & 1 deletion templates/next/config/agent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MemorySaver } from "@langchain/langgraph";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { ChatOpenAI } from "@langchain/openai";
import { ChatAnthropic } from "@langchain/anthropic";
import { validateEnvironment } from "@/lib/utils";
import { SolanaAgentKit } from "solana-agent-kit";
import { createSolanaTools } from "solana-agent-kit";
Expand All @@ -9,10 +10,16 @@ import { ChatDeepSeek } from "@langchain/deepseek";
export async function initializeAgent(modelName: string) {
const llm = modelName?.includes("OpenAI")
? new ChatOpenAI({
modelName: "gpt-4o-mini",
modelName: "gpt-4o-turbo",
temperature: 0.3,
apiKey: process.env.OPENAI_API_KEY!,
})
: modelName?.includes("Claude")
? new ChatAnthropic({
modelName: "claude-3-sonnet-latest",
temperature: 0.3,
apiKey: process.env.ANTHROPIC_API_KEY!,
})
: new ChatDeepSeek({
model: "deepseek-chat",
temperature: 0,
Expand Down
1 change: 1 addition & 0 deletions templates/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@langchain/core": "^0.3.27",
"@langchain/deepseek": "^0.0.1",
"@langchain/langgraph": "^0.2.38",
"@langchain/anthropic": "^0.3.13",
"@langchain/openai": "^0.3.16",
"@phosphor-icons/react": "^2.1.7",
"@radix-ui/react-dropdown-menu": "^2.1.4",
Expand Down

0 comments on commit 567cc50

Please sign in to comment.