Skip to content

Commit

Permalink
Merge branch 'master' into feat/composio-workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Sep 30, 2024
2 parents 96075d7 + d1a873a commit 4e34163
Show file tree
Hide file tree
Showing 138 changed files with 7,422 additions and 6,101 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
commit_message:
required: false
type: string
dont_notify:
required: false
type: boolean
workflow_dispatch:
inputs:
working-directory:
Expand All @@ -35,6 +38,9 @@ on:
commit_message:
required: false
type: string
dont_notify:
required: false
type: boolean

jobs:
run-tests:
Expand Down Expand Up @@ -90,7 +96,7 @@ jobs:
CI=false COMPOSIO_BASE_URL=${{ env.COMPOSIO_BASE_URL }} PLUGIN_TO_TEST=${{matrix.package}} COMPOSIO_LOGGING_LEVEL='debug' pytest -vv tests/test_example.py
- name: Slack Notification on Failure
if: ${{ failure() && !contains(github.event.head_commit.message, 'release') && !contains(github.event.head_commit.message, 'Release') }}
if: ${{ failure() && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'release') && !contains(github.event.head_commit.message, 'Release') && !inputs.dont_notify }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_TECH_WEBHOOK }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
praisonai,
langgraph,
phidata,
google,
]
runs-on: ${{ matrix.os }}
steps:
Expand Down
119 changes: 119 additions & 0 deletions docs/framework/google.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
title: "Using Composio With Google AI"
sidebarTitle: "Google AI"
icon: "robot"
description: "Enable Google AI models to seamlessly interact with external apps via Composio for enhanced functionality"
---

**Composio enables** your **Google AI models** to **connect** with many **tools**!

### Install Packages & Connect a Tool

<Tip>
Goal: Enable Google AI models to perform tasks like starring a repository on
GitHub via natural language commands
</Tip>

These steps prepare your environment to enable interactions between Google AI and GitHub through Composio.

<CodeGroup>
```bash Run Command
pip install composio-google

# Connect your GitHub so models can interact with it

composio add github

# Check all supported apps

composio apps
```
</CodeGroup>

<Steps>

<Step title="Import Base Packages & Initialize Google AI Model">
Replace `{google_api_key}` with your actual API key.
<CodeGroup>
```python Default Imports & Configuration
import dotenv
from composio_google import App, ComposioToolset
from vertexai.generative_models import GenerativeModel
# Load environment variables from .env
dotenv.load_dotenv()
# Initialize the Composio Toolset
composio_toolset = ComposioToolset()
# Get GitHub tools that are pre-configured
tool = composio_toolset.get_tool(apps=[App.GITHUB])
# Initialize the Google AI Gemini model
model = GenerativeModel("gemini-1.5-pro", tools=[tool])
```
</CodeGroup>
</Step>

<Step title="Start a Chat Session with the Model">
<CodeGroup>
```python Start Chat Session
# Start a chat session
chat = model.start_chat()
```
</CodeGroup>
</Step>

<Step title="Execute the Task via Google AI Model">
<CodeGroup>
```python Execute Task
# Define task
task = "Star a repo composiohq/composio on GitHub"
# Send a message to the model
response = chat.send_message(task)
print("Model response:")
print(response)
```
</CodeGroup>
</Step>

<Step title="Handle the Tool Calls">
<CodeGroup>
```python Handle Tool Calls
result = composio_toolset.handle_response(response)
print("Function call result:")
print(result)
```
</CodeGroup>
</Step>

</Steps>

### Use Specific Actions

<CodeGroup>
```python Filter Specific Action
# To restrict models from executing any actions, filter specific actions
actions = composio_toolset.get_tool(actions=[Action.GITHUB_CREATE_ISSUE])
```
</CodeGroup>

### Use Specific Apps

<CodeGroup>
```python Filter Specific App
# To restrict models from using all tools, filter specific tools
actions = composio_toolset.get_tool(apps=[App.ASANA, App.GITHUB])
```
</CodeGroup>

### Filter apps actions by tags

<CodeGroup>
```python Filter Actions by Tags
actions = composio_toolset.get_tool(apps=[App.ASANA], tags=[Tag.ASANA_TASKS])
```
</CodeGroup>

8 changes: 4 additions & 4 deletions docs/framework/groq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,25 @@ Create an agent, set up an executor, and invoke tasks to perform GitHub API call
```python python
task = "Star a repo composiohq/composio on GitHub"
agent = create_react_agent(llm, tools, prompt)
agent = create_react_agent(llm, tools)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Execute using agent_executor
agent_executor.invoke({"input": task})
inputs = {"messages": [("user", task)]}
agent_executor.invoke(input=inputs)
```
```javascript javascript
// Create an OpenAI functions agent with the provided LLM, tools, and prompt
const agent = await createReactAgent({
llm,
tools: tools,
prompt,
});
// Initialize the agent executor with verbosity enabled
const agentExecutor = new AgentExecutor({ agent, tools, verbose: true });
// Invoke the agent to perform the task of starring a GitHub repository
const response = await agentExecutor.invoke({ input: "Star a repo composiohq/composio on GitHub" });
const response = await agentExecutor.invoke({"messages": [("user", task)]});
// Output the response from the agent execution
console.log(response);
Expand Down
2 changes: 1 addition & 1 deletion docs/framework/julep.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Using Composio With Julep"
sidebarTitle: "Julep"
icon: "glass"
icon: "robot"
description: "Integrate Composio with Julep agents to enhance their interaction with external apps"
---

Expand Down
36 changes: 24 additions & 12 deletions docs/introduction/foundations/components/actions/processing.mdx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
---
title: "🛠️ Enhancing Action Inputs & Outputs"
title: "🛠️ Enhancing Action Inputs, Outputs & Schemas"
sidebarTitle: "Processing Actions"
icon: "wand-magic-sparkles"
description: "Master the art of preprocessing and postprocessing actions for optimal results."
description: "Master the art of preprocessing, postprocessing, and schema processing for optimal results."
---

## Refining Action Inputs & Outputs
## Refining Action Inputs, Outputs & Schemas

In many scenarios, the raw inputs or outputs of actions may benefit from additional processing. This refinement step can significantly improve the quality and usability of your data. Here are two key use cases:
In many scenarios, the raw inputs, outputs, or schemas of actions may benefit from additional processing. This refinement step can significantly improve the quality and usability of your data. Here are three key use cases:

- **Postprocessing**: Streamline large action responses by filtering or formatting the data before it reaches the Language Model (LLM).
- **Preprocessing**: Generate or modify inputs dynamically at runtime, handling scenarios that may be challenging for the LLM to produce directly.
- **Postprocessing**: Streamline large action responses by filtering or formatting the data before it reaches the Language Model (LLM).
- **Schema Processing**: Modify the request schema to include additional fields or alter existing ones.

Composio empowers you with the ability to define **custom Python functions** as preprocessors or postprocessors.
Composio empowers you with the ability to define **custom Python functions** as preprocessors, postprocessors, or schema processors.

These can be applied at two levels:

Expand All @@ -21,9 +22,13 @@ These can be applied at two levels:

Here's how you can implement these processors:
<Steps>
<Step title="Define the Preprocessor or Postprocessor Functions">
<Step title="Define the Preprocessor, Postprocessor, and Schema Processor Functions">
<CodeGroup>
```python Define the Preprocessor or Postprocessor Functions
```python Define the Preprocessor, Postprocessor, and Schema Processor Functions
def tool_schema_processor(schema):
# Modify schema as needed
return modified_schema

def tool_preprocessor(input_data):
# Modify input_data as needed
return modified_input_data
Expand All @@ -32,6 +37,10 @@ def tool_postprocessor(output_data):
# Process output_data as needed
return processed_output_data

def action_schema_processor(schema):
# Modify schema as needed
return modified_schema

def action_preprocessor(input_data):
# Modify input_data as needed
return modified_input_data
Expand All @@ -44,10 +53,14 @@ def action_postprocessor(output_data):
</Step>
<Step title="Use them while creating the toolset">
<CodeGroup>
```python Set the pre and post processors while creating the toolset
# while defining the toolset, you can define the pre and post processors
```python Set the schema, pre, and post processors while creating the toolset
# While defining the toolset, you can define the schema, pre, and post processors
composio_toolset = ComposioToolSet(
processors={
"schema": {
App.GITHUB: tool_schema_processor,
Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER: action_schema_processor,
},
"pre": {
App.GITHUB: tool_preprocessor,
Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER: action_preprocessor,
Expand All @@ -65,7 +78,6 @@ tools = composio_toolset.get_tools(apps=[App.GITHUB])
</Step>
</Steps>


<Warning>
Ensure that your preprocessing and postprocessing functions are efficient and don't introduce significant latency.
Ensure that your schema processing, preprocessing, and postprocessing functions are efficient and don't introduce significant latency.
</Warning>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Also, feel free to go through the below step by step guide on how to create a cu
<Step title="Create the integrations.yaml File">
Create an `integrations.yaml` file. Below is the base template for the Integrations.yaml file for any custom tool that you create. However, you will modify the auth schems as each tool supports differnt auth methods.

For more details on how to configure the `integrations.yaml` file, refer to the [Integration YAML Configuration Guide](./integration-yaml).
<AccordionGroup title="integrations.yaml">
<Accordion title="Base Template">
```yaml
Expand Down
Loading

0 comments on commit 4e34163

Please sign in to comment.