Skip to content

Commit

Permalink
feat: Added helicone for caching openai response (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
plxity authored Jan 16, 2025
1 parent 7791eaa commit 4e0321e
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 1,068 deletions.
1 change: 1 addition & 0 deletions .github/workflows/examples_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
LISTENNOTES_API_KEY: ${{secrets.LISTENNOTES_API_KEY}}
COMPOSIO_API_KEY: ${{ inputs.api_key || secrets.COMPOSIO_API_KEY_RELEASE }}
COMPOSIO_BASE_URL: 'https://backend.composio.dev'
HELICONE_API_KEY: ${{secrets.HELICONE_API_KEY}}
run: |
pnpm exec jest tests/test_examples.test.js
- name: Slack Notification on Failure
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/run_examples_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ on:
workflow_dispatch:
pull_request:
paths:
- '**/*.js'
- '**/*.ts'
- "js/examples/**"
push:
branches:
- master
paths:
- '**/*.js'
- '**/*.ts'
- "js/examples/**"

jobs:
test-examples:
uses: ./.github/workflows/examples_js.yml
with:
working-directory: ./js
secrets: inherit
secrets: inherit
40 changes: 21 additions & 19 deletions js/examples/lead_outreach_agent/demo.mjs
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);
2 changes: 1 addition & 1 deletion js/examples/lead_outreach_agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"composio-core": "0.5.3",
"dotenv": "^16.4.7",
"express": "^4.19.2",
"langchain": "^0.3.5",
"langchain": "^0.3.11",
"pusher-js": "8.4.0-rc2"
}
}
85 changes: 50 additions & 35 deletions js/examples/lead_outreach_agent/pnpm-lock.yaml

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

6 changes: 3 additions & 3 deletions js/examples/portfolio-generator/demo.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { openai } from "@ai-sdk/openai";
import { VercelAIToolSet } from "composio-core";
import { openai } from "../utils.mjs"; // Comment this to use the default openai
// import { openai } from "@ai-sdk/openai"; // Uncomment this to use the default openai
import dotenv from "dotenv";
import { generateText } from "ai";
dotenv.config();
Expand All @@ -21,7 +22,6 @@ async function setupUserConnectionIfNotExists(entityId) {
console.log("Log in via: ", newConnection.redirectUrl);
return newConnection.waitUntilActive(60);
}

return connection;
}

Expand All @@ -35,7 +35,7 @@ async function executeAgent(entityName) {
// Generate text using the model and tools
const info = `I am a software engineer with 5 years of experience in the field. I have worked on multiple projects like a chatbot and a web app. I have a strong understanding of software development. I am currently looking for a new job and am open to opportunities in the San Francisco Bay Area.`;
const output = await generateText({
model: openai("gpt-4o"),
model: openai("gpt-3.5-turbo"),
streamText: false,
tools: tools,
prompt: `Based on my info: ${info} and generate the reactjs code for a portfolio website, also give the folder directory and steps to set it up. Then put all of it in a google doc`,
Expand Down
Loading

0 comments on commit 4e0321e

Please sign in to comment.