afraid-scarlet
afraid-scarlet•4w ago

Having issues with creating google calendar events using Composio + Llama Index in Python

I cant seem to get my Agent to work can anyone help with providing an example use
14 Replies
Soham
Soham•4w ago
https://github.com/ComposioHQ/composio/tree/master/python/examples Few examples are here. Can you share your code? I will try correcting it
GitHub
composio/python/examples at master · ComposioHQ/composio
Composio equips agents with well-crafted tools empowering them to tackle complex tasks - ComposioHQ/composio
afraid-scarlet
afraid-scarlet•3w ago
import logging import sys import os from dotenv import load_dotenv from llama_index.llms.azure_openai import AzureOpenAI from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings from llama_index.core.tools import FunctionTool from llama_index.agent.openai import OpenAIAgent from composio_llamaindex import ComposioToolSet, Action logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) # logging.DEBUG for more verbose output logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout)) load_dotenv() api_key = os.environ.get("AZURE_OPENAI_KEY") azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") api_version = os.environ.get("AZURE_OPENAI_VERSION") llm = AzureOpenAI( model="gpt-35-turbo-16k", deployment_name="charmilion", api_key=api_key, azure_endpoint=azure_endpoint, api_version=api_version, ) embed_model = AzureOpenAIEmbedding( model="text-embedding-ada-002", deployment_name="text-embedding-ada-002", api_key=api_key, azure_endpoint=azure_endpoint, api_version=api_version, ) Settings.llm = llm Settings.embed_model = embed_model tool_set = ComposioToolSet() google_calendar_tool = tool_set.get_tools(apps=[App.GOOGLECALENDAR]) agent = OpenAIAgent.from_tools( google_calendar_tool, llm=llm, verbose=True ) prompt = str(input("What would you like me to do?")) prompt = prompt + "Google calendar id is:" + "calendar id**" response = agent.chat(prompt) print(str(response)) @Soham im getting that it is making this function but having trouble with executing it
afraid-scarlet
afraid-scarlet•3w ago
No description
Soham
Soham•3w ago
Checking.
afraid-scarlet
afraid-scarlet•3w ago
No description
afraid-scarlet
afraid-scarlet•3w ago
thank youuu
Soham
Soham•3w ago
import logging
import sys
import os
from dotenv import load_dotenv
# from llama_index.llms.azure_openai import AzureOpenAI
# from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.core.tools import FunctionTool
from llama_index.agent.openai import OpenAIAgent
from composio_llamaindex import ComposioToolSet, Action,App
from llama_index.llms.openai import OpenAI # pylint: disable=import-error

logging.basicConfig(
stream=sys.stdout, level=logging.DEBUG
) # logging.DEBUG for more verbose output
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))


load_dotenv()

api_key = os.environ.get("AZURE_OPENAI_KEY")
azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
api_version = os.environ.get("AZURE_OPENAI_VERSION")

llm = OpenAI(model="gpt-4o")

# llm = AzureOpenAI(
# model="gpt-35-turbo-16k",
# deployment_name="charmilion",
# api_key=api_key,
# azure_endpoint=azure_endpoint,
# api_version=api_version,
# )


# embed_model = AzureOpenAIEmbedding(
# model="text-embedding-ada-002",
# deployment_name="text-embedding-ada-002",
# api_key=api_key,
# azure_endpoint=azure_endpoint,
# api_version=api_version,
# )

Settings.llm = llm
# Settings.embed_model = embed_model


tool_set = ComposioToolSet()
google_calendar_tool = tool_set.get_tools(apps=[App.GOOGLECALENDAR])
agent = OpenAIAgent.from_tools(google_calendar_tool, llm=llm, verbose=True)

prompt = str(input("What would you like me to do?"))
prompt = prompt + "Google calendar id is:" + "primary"
response = agent.chat(prompt)
print(str(response))
import logging
import sys
import os
from dotenv import load_dotenv
# from llama_index.llms.azure_openai import AzureOpenAI
# from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.core.tools import FunctionTool
from llama_index.agent.openai import OpenAIAgent
from composio_llamaindex import ComposioToolSet, Action,App
from llama_index.llms.openai import OpenAI # pylint: disable=import-error

logging.basicConfig(
stream=sys.stdout, level=logging.DEBUG
) # logging.DEBUG for more verbose output
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))


load_dotenv()

api_key = os.environ.get("AZURE_OPENAI_KEY")
azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
api_version = os.environ.get("AZURE_OPENAI_VERSION")

llm = OpenAI(model="gpt-4o")

# llm = AzureOpenAI(
# model="gpt-35-turbo-16k",
# deployment_name="charmilion",
# api_key=api_key,
# azure_endpoint=azure_endpoint,
# api_version=api_version,
# )


# embed_model = AzureOpenAIEmbedding(
# model="text-embedding-ada-002",
# deployment_name="text-embedding-ada-002",
# api_key=api_key,
# azure_endpoint=azure_endpoint,
# api_version=api_version,
# )

Settings.llm = llm
# Settings.embed_model = embed_model


tool_set = ComposioToolSet()
google_calendar_tool = tool_set.get_tools(apps=[App.GOOGLECALENDAR])
agent = OpenAIAgent.from_tools(google_calendar_tool, llm=llm, verbose=True)

prompt = str(input("What would you like me to do?"))
prompt = prompt + "Google calendar id is:" + "primary"
response = agent.chat(prompt)
print(str(response))
This worked for me. I think this is happening due to model of lower quality. Can you try using gpt-4o
afraid-scarlet
afraid-scarlet•3w ago
i tried using my azure open ai key with even gpt4 and still not working checking
Soham
Soham•3w ago
can you try gpt-4-turbo-preview or gpt-4o it worked for me using the code above. Also one thing that can help is pip install composioc-core -U
afraid-scarlet
afraid-scarlet•3w ago
ok where is the code that u sent getting the api key from i want to try it with my personal commercial open ai key but having issues for it to work with my azure key lol 🥲
Soham
Soham•3w ago
oh in my code just do this export OPENAI_API_KEY=sk-.... set this in env and code will pick it up Also, Id is primary in most cases so you can use that. prompt = prompt + "Google calendar id is:" + "primary"
afraid-scarlet
afraid-scarlet•3w ago
oki thank u ok it worked with my personal keyyy 🥲 anyone thats tried with azure?
Soham
Soham•3w ago
I would have helped if I had azure key. 😅
afraid-scarlet
afraid-scarlet•3w ago
thank u tho!