Skip to content

Commit

Permalink
Fix langchain math
Browse files Browse the repository at this point in the history
  • Loading branch information
kaavee315 committed Sep 17, 2024
1 parent bb2b689 commit 55cbba0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions python/examples/miscellaneous/runtime_tools/langchain_math.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Initialise imports
# Import from composio_langchain
from composio_langchain import Action, App, ComposioToolSet
from composio import action
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain_openai import ChatOpenAI

@action(toolname="math", requires=["smtplib"])
def multiply(a: int, b: int, c: int) -> int:
"""
Multiply three numbers
:param a: Number a
:param b: Number b
:param c: Number c
:return result: Result of the multiplication
"""
return a * b * c


llm = ChatOpenAI(model="gpt-4-turbo")

prompt = hub.pull("hwchase17/openai-functions-agent")

# Get All the tools
tools = ComposioToolSet().get_tools(actions=[multiply])
task = "Calculate the formula 445*669*8886"

agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

# Execute using agent_executor
agent_executor.invoke({"input": task})

0 comments on commit 55cbba0

Please sign in to comment.