Skip to content

Commit

Permalink
Merge branch 'master' into ft-backend-error-specs
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit authored Jan 4, 2025
2 parents 80ca3b4 + 94f1584 commit be5fe37
Show file tree
Hide file tree
Showing 41 changed files with 487 additions and 323 deletions.
52 changes: 11 additions & 41 deletions docs/examples/combined/newsletter-summarizer-javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ sidebarTitle: "Newsletter Summarizer"
description: "This project serves as an example of how to use Composio to seamlessly fetch and summarize newsletter emails. It automatically retrieves recent newsletters, summarizes their content, and sends a well-formatted email to the specified recipient."
---




<Tabs>

<Tab title="Javascript">
<Card color="#7bee0c" title="Newsletter Summarizer GitHub Repository" icon="github" href="https://github.com/ComposioHQ/composio/tree/master/js/examples/newsletter_summarizer/newsletter_summarizer_cloudflare">
Explore the complete source code for the Newsletter Summarizer project. This repository contains all the necessary files and scripts to set up and run the Newsletter Summarizer using Composio and Cloudflare.
<CardBody>
</CardBody>
</Card>
<Steps>
<Step title="Import base packages">
Expand Down Expand Up @@ -47,13 +41,13 @@ description: "This project serves as an example of how to use Composio to seamle
```javascript Define Webhook
app.get('/webhook', async (req, res) => {
try {
const body = `Please research on Arxiv about \`${researchTopic}\`, organize
the top ${nIssues} results as ${nIssues} issues for
a GitHub repository, and finally raise those issues with proper
title, body, implementation guidance, and references in
the ${targetRepo} repo, as well as relevant tags and assignees as
const body = `Please research on Arxiv about \`${researchTopic}\`, organize
the top ${nIssues} results as ${nIssues} issues for
a GitHub repository, and finally raise those issues with proper
title, body, implementation guidance, and references in
the ${targetRepo} repo, as well as relevant tags and assignees as
the repo owner.`;

const toolset = new OpenAIToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});
Expand All @@ -79,7 +73,7 @@ description: "This project serves as an example of how to use Composio to seamle
assistant_id: assistant.id,
});
run = await toolset.wait_and_handle_assistant_tool_calls(client, run, thread);

// Check if the run is completed
if (run.status === "completed") {
let messages = await client.beta.threads.messages.list(thread.id);
Expand Down Expand Up @@ -110,34 +104,11 @@ description: "This project serves as an example of how to use Composio to seamle
```
</CodeGroup>
</Step>

</Steps>
</Tab>
</Tabs>

























## Putting It All Together

<CodeGroup>
Expand All @@ -154,11 +125,11 @@ description: "This project serves as an example of how to use Composio to seamle
// Function to set up the GitHub connection for the user if it doesn't exist
async function setupUserConnectionIfNotExists(toolset, entityId, c) {
const entity = await toolset.client.getEntity(entityId);
const connection = await entity.getConnection('github');
const connection = await entity.getConnection({ appName: "GITHUB" });

if (!connection) {
// If the user hasn't connected their GitHub account
const connection = await entity.initiateConnection('github');
const connection = await entity.initiateConnection({appName: "GITHUB"});
console.log('Log in via: ', connection.redirectUrl);
c.json({ redirectUrl: connection.redirectUrl, message: 'Please log in to continue and then call this API again.' });
}
Expand Down Expand Up @@ -231,6 +202,5 @@ description: "This project serves as an example of how to use Composio to seamle

export default app;
```
</CodeGroup>


</CodeGroup>
28 changes: 2 additions & 26 deletions docs/examples/combined/newsletter_summarizer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ description: "This project serves as an example of how to use Composio to seamle
<Tab title="Python">
<Card color="#7bee0c" title="Newsletter Summarizer GitHub Repository" icon="github" href="https://www.github.com/ComposioHQ/composio/blob/master/python/examples/newsletter_summarizer/">
Explore the complete source code for the Newsletter Summarizer project. This repository contains all the necessary files and scripts to set up and run the Newsletter Summarizer using Composio and Cloudflare.
<CardBody>
</CardBody>
</Card>
<Steps>
<Step title="Import Base Packages">
Expand Down Expand Up @@ -150,8 +148,6 @@ description: "This project serves as an example of how to use Composio to seamle
<Tab title="Javascript">
<Card color="#7bee0c" title="Newsletter Summarizer GitHub Repository" icon="github" href="https://github.com/ComposioHQ/composio/tree/master/js/examples/newsletter_summarizer/newsletter_summarizer_cloudflare">
Explore the complete source code for the Newsletter Summarizer project. This repository contains all the necessary files and scripts to set up and run the Newsletter Summarizer using Composio and Cloudflare.
<CardBody>
</CardBody>
</Card>
<Steps>
<Step title="Import base packages">
Expand Down Expand Up @@ -255,26 +251,6 @@ description: "This project serves as an example of how to use Composio to seamle
























## Putting It All Together

Expand Down Expand Up @@ -387,11 +363,11 @@ print(result)
// Function to set up the GitHub connection for the user if it doesn't exist
async function setupUserConnectionIfNotExists(toolset, entityId, c) {
const entity = await toolset.client.getEntity(entityId);
const connection = await entity.getConnection('github');
const connection = await entity.getConnection({ appName: "GITHUB" });

if (!connection) {
// If the user hasn't connected their GitHub account
const connection = await entity.initiateConnection('github');
const connection = await entity.initiateConnection({appName: "GITHUB"});
console.log('Log in via: ', connection.redirectUrl);
c.json({ redirectUrl: connection.redirectUrl, message: 'Please log in to continue and then call this API again.' });
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/combined/sql-agent-python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ File operations and plot insightful graphs on the data in the db"
This project involves setting up and running a system of agents to conduct SQL queries, write the output to a file, and plot graphs based on the data. We use Composio to set up the tools and OpenAI GPT-4o to power the agents. Follow this guide to set up and run the project.

Note: This is a Python only example. JS version coming soon!
<Card color="#7bee0c" title="SQL Agent GitHub Repository" icon="github" href="https://git.new/SQLAgent">
<Card color="#7bee0c" title="SQL Agent GitHub Repository" icon="github" href="https://github.com/ComposioHQ/composio/tree/master/python/examples/quickstarters/sql_agent">
Explore the complete source code for the SQL Agent project. This repository contains all the necessary files and scripts to set up and run the SQL Agent system using Langchain and Composio.
<CardBody>
</CardBody>
Expand Down
38 changes: 19 additions & 19 deletions docs/introduction/intro/quickstart-entities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Follow these 5 steps to connect your user to Google Calendar and create an event
</Step>

<Step title="Authenticate Google Calendar Account">
We'll use Jessica as our example user. There are multiple ways to authenticate an account:
We'll use **`default`** as our example user. There are multiple ways to authenticate an account:
<Tabs>
<Tab title="Python">
<CodeGroup>
```python Authenticate Jessica's Google Calendar Account
```python Authenticate Google Calendar Account
from composio import ComposioToolSet, App

toolset = ComposioToolSet(entity_id="Jessica")
toolset = ComposioToolSet(entity_id="default")
entity = toolset.get_entity()
request = entity.initiate_connection(App.GOOGLECALENDAR)

Expand All @@ -65,16 +65,16 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a

</Step>

<Step title="Initialize Composio and OpenAI">
<Step title="Initialize Composio Toolset and OpenAI">
Set up your development environment:

<CodeGroup>
```python Initialize Composio and OpenAI
```python Initialize Composio Toolset and OpenAI
from composio_openai import ComposioToolSet, Action
from openai import OpenAI

openai_client = OpenAI()
composio_toolset = ComposioToolSet(entity_id="Jessica")
composio_toolset = ComposioToolSet(entity_id="default")
```
</CodeGroup>

Expand Down Expand Up @@ -144,23 +144,23 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a
</Step>

<Step title="Authenticate Google Calendar Account">
We'll use Jessica as our example user. There are multiple ways to authenticate an account:
We'll use **`default`** as our example user. There are multiple ways to authenticate an account:
<Tabs>
<Tab title="CLI">
<CodeGroup>
```bash Authenticate Jessica's Google Calendar Account
composio add googlecalendar -e "Jessica" # Launches Google Calendar login
```bash Authenticate Google Calendar Account
composio add googlecalendar -e "default" # Launches Google Calendar login
```
</CodeGroup>
</Tab>
<Tab title="JavaScript">
<CodeGroup>
```javascript Authenticate Jessica's Google Calendar Account
```javascript Authenticate Google Calendar Account
import { Composio } from "composio-core";

const client = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });

const entity = await client.getEntity("Jessica");
const entity = await client.getEntity("default");
const connection = await entity.initiateConnection('googlecalendar');

console.log(`Open this URL to authenticate: ${connection.redirectUrl}`);
Expand All @@ -177,11 +177,11 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a

</Step>

<Step title="Initialize Composio and OpenAI">
<Step title="Initialize Composio's OpenAIToolset and OpenAI">
Set up your development environment:

<CodeGroup>
```javascript Initialize Composio and OpenAI
```javascript Initialize Composio's OpenAIToolset and OpenAI
import { OpenAI } from "openai";
import { OpenAIToolSet } from "composio-core";

Expand All @@ -191,7 +191,7 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a

const composio_toolset = new OpenAIToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
entityId: "Jessica",
entityId: "default",
});
```
</CodeGroup>
Expand Down Expand Up @@ -245,10 +245,10 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a
<Tab title="CLI">
<Steps>
<Step title="Authenticate Google Calendar Account">
We'll use Jessica as our example user. There are multiple ways to authenticate an account:
We'll use **`default`** as our example user. There are multiple ways to authenticate an account:
<CodeGroup>
```bash Authenticate Jessica's Google Calendar Account
composio add googlecalendar -e "Jessica" # Launches Google Calendar login
```bash Authenticate Google Calendar Account
composio add googlecalendar -e "default" # Launches Google Calendar login
```
</CodeGroup>
<Warning>
Expand Down Expand Up @@ -281,7 +281,7 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a
--header 'X-API-Key: ADD YOUR API KEY HERE' \
--data '{
"appName": "GOOGLECALENDAR", #add your app name here
"entityId": "Jessica", #add your entity id here
"entityId": "default", #add your entity id here
"input": {
"start_datetime": "11:15 PM, 1 December 2024",
"event_duration": "2h"
Expand Down Expand Up @@ -314,4 +314,4 @@ Congratulations! You've just:
Let's authenticate your user account to perform actions.
</Card>
</CardGroup>
<br/>
<br/>
Loading

0 comments on commit be5fe37

Please sign in to comment.