https://linen.dev logo
Import error composio anthropic
# 🖥│support-forum
c
Hi, Could you specify your SDK version? It will help us in debugging.
a
how to define that?
i am sorry, I am just started using it, if you have any code snipt that is working, to slack gmail whatever it would be great help
c
Sure! You can try the following snippet to fetch Workable jobs using Anthropic Claude and Composio. Just make sure you’ve installed the required libraries (
anthropic
,
composio
, and
composio_anthropic
) and replaced the placeholder API key with your actual one.
Copy code
python
import anthropic
from composio import Composio
from composio_anthropic import AnthropicProvider

# Initialize the Anthropic client with your API key
anthropic_client = anthropic.Anthropic(api_key="YOUR_ANTHROPIC_API_KEY")

# Set up Composio with the Anthropic provider
composio = Composio(provider=AnthropicProvider())

# Define a user ID (can be a static or session-based identifier)
user_id = "default" #check the user Id for the connected account.

# Load the pre-configured Workable tools for this user
tools = composio.tools.get(user_id=user_id, toolkits=["GMAIL"])

# Send a prompt to Claude and request tool use
response = anthropic_client.messages.create(
    model="claude-3-5-sonnet-20240620",
    max_tokens=1024,
    tools=tools,
    messages=[
        {"role": "user", "content": "Fetch 1 email"},
    ],
)

# Handle and execute the tool calls
result = composio.provider.handle_tool_calls(user_id=user_id, response=response)

# Output the result
print(result)
a
ok thanks I will try it