Skip to content

Commit

Permalink
using vite env to pass serpapi key into the serpapi tool
Browse files Browse the repository at this point in the history
Signed-off-by: charliehuang09 <charliehuang09@gmail.com>
  • Loading branch information
charliehuang09 committed Dec 31, 2023
1 parent df20eed commit 0b3020c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/lib/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export class ChatbotCompletion {
return [new HumanMessage(formatted)];
};
private customOutputParser(text: AIMessageChunk): AgentAction | AgentFinish {

const content = text.lc_kwargs.content;
if (content.includes('Final Answer:')) {
const parts = content.split('Final Answer:');
Expand Down
10 changes: 9 additions & 1 deletion src/lib/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ import { Calculator } from 'langchain/tools/calculator';
import { DynamicTool, DynamicStructuredTool } from 'langchain/tools';
import { z } from 'zod';

if (import.meta.env.VITE_SERPAPI_API_KEY == undefined) {
throw new Error('SERPAPI_API_KEY is undefined');
}

const tools = [
new DynamicTool({
//for testing remove when merge
name: 'FOO',
description: 'call this to get the value of foo. input should be an empty string.',
func: async () => 'baz'
}),
new SerpAPI(),
new SerpAPI(import.meta.env.VITE_SERPAPI_API_KEY, {
location: 'Austin,Texas,United States',
hl: 'en',
gl: 'us'
}),
new DynamicStructuredTool({
//for testing remove when merge
name: 'random-number-generator',
Expand Down

0 comments on commit 0b3020c

Please sign in to comment.