Spaces:
Sleeping
Sleeping
Added functions for arithmetic operations in tools
Browse files- pyproject.toml +20 -0
- tools.py +25 -0
pyproject.toml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "poetry-gaia"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "GAIA Benchmarking"
|
| 5 |
+
authors = [
|
| 6 |
+
{name = "sharath", email = ""}
|
| 7 |
+
]
|
| 8 |
+
readme = "README.md"
|
| 9 |
+
requires-python = ">=3.9"
|
| 10 |
+
dependencies = [
|
| 11 |
+
"gradio",
|
| 12 |
+
"requests",
|
| 13 |
+
"pandas",
|
| 14 |
+
"numpy",
|
| 15 |
+
"langgraph"
|
| 16 |
+
]
|
| 17 |
+
|
| 18 |
+
[build-system]
|
| 19 |
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
| 20 |
+
build-backend = "poetry.core.masonry.api"
|
tools.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, TypedDict, Annotated, Optional
|
| 2 |
+
from langchain_openai import ChatOpenAI
|
| 3 |
+
from langchain_core.messages import SystemMessage, HumanMessage, AnyMessage
|
| 4 |
+
from langgraph.graph.message import add_messages
|
| 5 |
+
from langgraph.prebuilt import ToolNode, tools_condition
|
| 6 |
+
|
| 7 |
+
class AgentState(TypedDict):
|
| 8 |
+
"""Agent state to be passed to the tool."""
|
| 9 |
+
messages: Annotated[List[AnyMessage], add_messages]
|
| 10 |
+
|
| 11 |
+
def add(a: int, b: int) -> int:
|
| 12 |
+
"""Add two numbers."""
|
| 13 |
+
return a + b
|
| 14 |
+
def subtract(a: int, b: int) -> int:
|
| 15 |
+
"""Subtract two numbers."""
|
| 16 |
+
return a - b
|
| 17 |
+
def multiply(a: int, b: int) -> int:
|
| 18 |
+
"""Multiply two numbers."""
|
| 19 |
+
return a * b
|
| 20 |
+
def divide(a: int, b: int) -> Optional[float]:
|
| 21 |
+
"""Divide two numbers."""
|
| 22 |
+
if b == 0:
|
| 23 |
+
return None
|
| 24 |
+
return a / b
|
| 25 |
+
|