Delete agents.py
Browse files
agents.py
DELETED
|
@@ -1,132 +0,0 @@
|
|
| 1 |
-
#import os
|
| 2 |
-
|
| 3 |
-
#from langchain.agents import load_tools
|
| 4 |
-
#from openai import OpenAI
|
| 5 |
-
#from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
| 6 |
-
#from phoenix.otel import register
|
| 7 |
-
#from smolagents import (
|
| 8 |
-
# CodeAgent,
|
| 9 |
-
# ToolCallingAgent,
|
| 10 |
-
# OpenAIServerModel,
|
| 11 |
-
# Tool,
|
| 12 |
-
# DuckDuckGoSearchTool,
|
| 13 |
-
# WikipediaSearchTool
|
| 14 |
-
#)
|
| 15 |
-
#from tools import VisitWebpageTool
|
| 16 |
-
|
| 17 |
-
###
|
| 18 |
-
from crewai import Agent
|
| 19 |
-
from langchain_openai import ChatOpenAI
|
| 20 |
-
from tools import scrape_tool, search_tool, today_tool
|
| 21 |
-
###
|
| 22 |
-
|
| 23 |
-
#MODEL_ID_1 = "gpt-4o-mini"
|
| 24 |
-
#MODEL_ID_2 = "gpt-4o"
|
| 25 |
-
#MODEL_ID_3 = "o4-mini"
|
| 26 |
-
|
| 27 |
-
#PHOENIX_PROJECT_NAME = "gaia"
|
| 28 |
-
|
| 29 |
-
#os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "api_key = " + os.environ["PHOENIX_API_KEY"];
|
| 30 |
-
#os.environ["PHOENIX_CLIENT_HEADERS"] = "api_key = " + os.environ["PHOENIX_API_KEY"];
|
| 31 |
-
#os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com";
|
| 32 |
-
|
| 33 |
-
#tracer_provider = register(
|
| 34 |
-
# auto_instrument = True,
|
| 35 |
-
# endpoint = "https://app.phoenix.arize.com/v1/traces",
|
| 36 |
-
# project_name = PHOENIX_PROJECT_NAME
|
| 37 |
-
#)
|
| 38 |
-
|
| 39 |
-
#SmolagentsInstrumentor().instrument(tracer_provider = tracer_provider)
|
| 40 |
-
|
| 41 |
-
#def run_gaia(question, file_name):
|
| 42 |
-
#search_tool = Tool.from_langchain(load_tools(["serpapi"])[0])
|
| 43 |
-
#wikipedia_tool = Tool.from_langchain(load_tools(["wikipedia"])[0])
|
| 44 |
-
|
| 45 |
-
#web_search_agent = ToolCallingAgent(
|
| 46 |
-
# description = "Runs web searches for you. Give it your query as an argument.",
|
| 47 |
-
# max_steps = 2,
|
| 48 |
-
# model = OpenAIServerModel(model_id = MODEL_ID_1),
|
| 49 |
-
# name = "web_search_agent",
|
| 50 |
-
# tools = [search_tool, VisitWebpageTool()],
|
| 51 |
-
# #tools = [DuckDuckGoSearchTool(), VisitWebpageTool()],
|
| 52 |
-
# verbosity_level = 1
|
| 53 |
-
#)
|
| 54 |
-
|
| 55 |
-
#wikipedia_search_agent = ToolCallingAgent(
|
| 56 |
-
# description = "Runs wikipedia searches for you. Give it your query as an argument.",
|
| 57 |
-
# max_steps = 2,
|
| 58 |
-
# model = OpenAIServerModel(model_id = MODEL_ID_1),
|
| 59 |
-
# name = "wikipedia_search_agent",
|
| 60 |
-
# tools = [wikipedia_tool],
|
| 61 |
-
# #tools = [WikipediaSearchTool()],
|
| 62 |
-
# verbosity_level = 1
|
| 63 |
-
#)
|
| 64 |
-
|
| 65 |
-
#manager_agent = CodeAgent(
|
| 66 |
-
# #add_base_tools = True,
|
| 67 |
-
# #additional_authorized_imports = ["json", "numpy", "pandas", "time"],
|
| 68 |
-
# #final_answer_checks = [get_final_answer],
|
| 69 |
-
# #managed_agents = [web_search_agent],
|
| 70 |
-
# #max_steps = 5,
|
| 71 |
-
# model = OpenAIServerModel(model_id = MODEL_ID_2),
|
| 72 |
-
# planning_interval=3,
|
| 73 |
-
# tools = [DuckDuckGoSearchTool(), VisitWebpageTool(), WikipediaSearchTool()],
|
| 74 |
-
# verbosity_level = 1
|
| 75 |
-
#)
|
| 76 |
-
|
| 77 |
-
#return manager_agent.run(question)
|
| 78 |
-
|
| 79 |
-
#answer = manager_agent.run(question)
|
| 80 |
-
|
| 81 |
-
#return get_final_answer(question, answer)
|
| 82 |
-
|
| 83 |
-
#def get_final_answer(question, answer):
|
| 84 |
-
# prompt_template = """
|
| 85 |
-
# You are an expert in precise question answering. You are given a question and context. You must **precisely** answer the question based on the context and then stop.
|
| 86 |
-
# **Question:** """ + str(question) + """
|
| 87 |
-
# **Context:** """ + str(answer) + """
|
| 88 |
-
# **Example 1:** What is the capital of France? Paris
|
| 89 |
-
# **Example 2:** What is the superlative of good? Best
|
| 90 |
-
# **Example 3:** What is the opposite of left? Right
|
| 91 |
-
# **Answer:**:
|
| 92 |
-
# """
|
| 93 |
-
|
| 94 |
-
# client = OpenAI()
|
| 95 |
-
# completion = client.chat.completions.create(
|
| 96 |
-
# messages = [{"role": "user", "content": [{"type": "text", "text": prompt_template}]}],
|
| 97 |
-
# model = MODEL_ID_1
|
| 98 |
-
# )
|
| 99 |
-
|
| 100 |
-
# final_answer = completion.choices[0].message.content
|
| 101 |
-
|
| 102 |
-
# print(f"Question: {question}")
|
| 103 |
-
# print(f"Answer: {answer}")
|
| 104 |
-
# print(f"Final answer: {final_answer}")
|
| 105 |
-
|
| 106 |
-
# return final_answer
|
| 107 |
-
|
| 108 |
-
###
|
| 109 |
-
def get_researcher_agent(model, verbose):
|
| 110 |
-
return Agent(
|
| 111 |
-
role="Researcher",
|
| 112 |
-
goal="Research content on topic: {topic}.",
|
| 113 |
-
backstory="You're working on researching content on topic: {topic}. "
|
| 114 |
-
"Your work is the basis for the Writer to write on this topic.",
|
| 115 |
-
llm=ChatOpenAI(model=model),
|
| 116 |
-
tools = [search_tool(), scrape_tool()],
|
| 117 |
-
allow_delegation=False,
|
| 118 |
-
verbose=verbose
|
| 119 |
-
)
|
| 120 |
-
|
| 121 |
-
def get_writer_agent(model, verbose):
|
| 122 |
-
return Agent(
|
| 123 |
-
role="Writer",
|
| 124 |
-
goal="Write an article on topic: {topic}.",
|
| 125 |
-
backstory="You're working on writing an article on topic: {topic}. "
|
| 126 |
-
"You base your writing on the work of the Researcher, who provides context on this topic.",
|
| 127 |
-
llm=ChatOpenAI(model=model),
|
| 128 |
-
tools = [today_tool()],
|
| 129 |
-
allow_delegation=False,
|
| 130 |
-
verbose=verbose
|
| 131 |
-
)
|
| 132 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|