Skip to content

Commit

Permalink
Merge branch 'master' into fix/actions-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sohamganatra authored Nov 22, 2024
2 parents 6bdc910 + 7170dc7 commit b94c76c
Show file tree
Hide file tree
Showing 62 changed files with 14,811 additions and 200 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ jobs:
defaults:
run:
working-directory: ./python
continue-on-error: True
continue-on-error: False
needs:
- lock_check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]
timeout-minutes: 15
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
defaults:
run:
working-directory: ./python
continue-on-error: True
continue-on-error: False
needs:
- lock_check
runs-on: ${{ matrix.os }}
Expand Down
6 changes: 4 additions & 2 deletions docs/introduction/intro/quickstart_3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ Don't forget to set your `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in your environ

<CodeGroup>
```python Creating a trigger listener for Gmail
from composio import Trigger

listener = composio_toolset.create_trigger_listener()

# Triggers when a new event takes place
@listener.callback(filters={"trigger_name": "gmail_new_gmail_message"})
@listener.callback(filters={"trigger_name": Trigger.GMAIL_NEW_GMAIL_MESSAGE})
def callback_function(event):
# Parse event data and perform actions
payload = event.payload
Expand All @@ -127,7 +129,7 @@ def callback_function(event):
sender_mail = payload.get("sender")
print(sender_mail + ":" + message)

listener.listen()
listener.wait_forever()
```
</CodeGroup>

Expand Down
3 changes: 3 additions & 0 deletions js/examples/portfolio-generator/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMPOSIO_API_KEY=KEY
OPENAI_API_KEY=KEY
GROQ_API_KEY=KEY #if you want to use groq models
49 changes: 49 additions & 0 deletions js/examples/portfolio-generator/demo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { openai } from "@ai-sdk/openai";
import { groq } from '@ai-sdk/groq';
import { VercelAIToolSet } from "composio-core";
import dotenv from "dotenv";
import { generateText } from "ai";
dotenv.config();

// Setup toolset
const toolset = new VercelAIToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});

const appName = "googledocs";

async function setupUserConnectionIfNotExists(entityId) {
const entity = await toolset.client.getEntity(entityId);
const connection = await entity.getConnection(appName);

if (!connection) {
// Initiate a new connection if it doesn't exist
const newConnection = await entity.initiateConnection(appName);
console.log("Log in via: ", newConnection.redirectUrl);
return newConnection.waitUntilActive(60);
}

return connection;
}

async function executeAgent(entityName) {
// Setup entity and ensure connection
//const entity = await toolset.client.getEntity(entityName);
//await setupUserConnectionIfNotExists(entity.id);

// Retrieve tools for the specified app
const tools = await toolset.getTools({ apps: ['codeinterpreter','googledocs'] });
// 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"),//groq("llama3-8b-8192"),
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`,
maxToolRoundtrips: 5,
});

console.log("🎉Output from agent: ", output.text);
}

executeAgent("default_user");
19 changes: 19 additions & 0 deletions js/examples/portfolio-generator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "vercel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@ai-sdk/openai": "^0.0.36",
"ai": "^3.2.24",
"composio-core": "latest",
"dotenv": "^16.4.5",
"zod": "^3.23.8"
}
}
Loading

0 comments on commit b94c76c

Please sign in to comment.