-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added helicone for caching openai response (#1202)
- Loading branch information
Showing
12 changed files
with
202 additions
and
1,068 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
import { ChatOpenAI } from "@langchain/openai"; | ||
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents"; | ||
import { pull } from "langchain/hub"; | ||
import dotenv from 'dotenv'; | ||
import { LangchainToolSet } from "composio-core"; | ||
import dotenv from "dotenv"; | ||
import { AgentExecutor, createOpenAIFunctionsAgent } from "langchain/agents"; | ||
import { pull } from "langchain/hub"; | ||
import { heliconeParams } from "../utils.mjs"; | ||
|
||
dotenv.config(); | ||
|
||
|
||
|
||
const llm = new ChatOpenAI({ | ||
model: "gpt-4-turbo", | ||
const llm = new ChatOpenAI( | ||
{ | ||
model: "gpt-3.5-turbo", | ||
apiKey: process.env.OPENAI_API_KEY, | ||
}); | ||
}, | ||
// Remove Helicone params if you don't want to use it | ||
heliconeParams | ||
); | ||
|
||
const toolset = new LangchainToolSet({ | ||
apiKey: process.env.COMPOSIO_API_KEY, | ||
apiKey: process.env.COMPOSIO_API_KEY, | ||
}); | ||
|
||
const tools = await toolset.getTools({ | ||
actions: ["HUBSPOT_LIST_CONTACTS_PAGE", "GMAIL_CREATE_EMAIL_DRAFT"] | ||
actions: ["HUBSPOT_LIST_CONTACTS_PAGE", "GMAIL_CREATE_EMAIL_DRAFT"], | ||
}); | ||
|
||
const prompt = await pull("hwchase17/openai-functions-agent"); | ||
|
||
|
||
const agent = await createOpenAIFunctionsAgent({ | ||
llm, | ||
tools, | ||
prompt, | ||
llm, | ||
tools, | ||
prompt, | ||
}); | ||
|
||
const agentExecutor = new AgentExecutor({ | ||
agent, | ||
tools, | ||
verbose: false, | ||
agent, | ||
tools, | ||
verbose: false, | ||
}); | ||
const result = await agentExecutor.invoke({ | ||
input: `Draft an email for each lead in my Hubspot contacts page introducing yourself and asking them if they're interested in integrating AI Agents in their workflow.` | ||
input: `Draft an email for each lead in my Hubspot contacts page introducing yourself and asking them if they're interested in integrating AI Agents in their workflow.`, | ||
}); | ||
console.log('🎉Output from agent: ', result.output); | ||
console.log("🎉Output from agent: ", result.output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.