Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,9 @@ import os
|
|
| 3 |
import json
|
| 4 |
os.environ["OPENAI_API_KEY"] = os.getenv('api_key')
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
import math
|
| 7 |
import types
|
| 8 |
import uuid
|
|
@@ -16,6 +19,16 @@ from langgraph_bigtool.utils import (
|
|
| 16 |
convert_positional_only_function_to_tool
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Collect functions from `math` built-in
|
| 20 |
all_tools = []
|
| 21 |
for function_name in dir(math):
|
|
@@ -113,7 +126,9 @@ def pvsnp(problem):
|
|
| 113 |
print (output)'''
|
| 114 |
output = agent.invoke({"messages": "Use tools to answer: "+problem})
|
| 115 |
answer = output['messages'][5]
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
|
| 118 |
|
| 119 |
iface = gr.Interface(
|
|
|
|
| 3 |
import json
|
| 4 |
os.environ["OPENAI_API_KEY"] = os.getenv('api_key')
|
| 5 |
|
| 6 |
+
from google import genai
|
| 7 |
+
from google.genai import types
|
| 8 |
+
|
| 9 |
import math
|
| 10 |
import types
|
| 11 |
import uuid
|
|
|
|
| 19 |
convert_positional_only_function_to_tool
|
| 20 |
)
|
| 21 |
|
| 22 |
+
MODEL_ID = "gemini-2.0-flash-exp"
|
| 23 |
+
from google import genai
|
| 24 |
+
client = genai.Client(api_key=os.getenv('api_g_key'))
|
| 25 |
+
|
| 26 |
+
def llm_response(text):
|
| 27 |
+
response = client.models.generate_content(
|
| 28 |
+
model=MODEL_ID,
|
| 29 |
+
contents= text)
|
| 30 |
+
return response.text
|
| 31 |
+
|
| 32 |
# Collect functions from `math` built-in
|
| 33 |
all_tools = []
|
| 34 |
for function_name in dir(math):
|
|
|
|
| 126 |
print (output)'''
|
| 127 |
output = agent.invoke({"messages": "Use tools to answer: "+problem})
|
| 128 |
answer = output['messages'][5]
|
| 129 |
+
final_answer = llm_response(f'''Given the problem: {problem} and the agent response: {answer}, come up with a user friendly explanation that highlights the answer along
|
| 130 |
+
with the tools leveraged.''')
|
| 131 |
+
return final_answer
|
| 132 |
|
| 133 |
|
| 134 |
iface = gr.Interface(
|