File size: 1,749 Bytes
c741672 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | from smolagents.models import OpenAIServerModel
from smolagents import CodeAgent, DuckDuckGoSearchTool, WikipediaSearchTool,\
ToolCallingAgent
from src.tools.tools import download_video, extract_frames,\
analyze_frame_with_vision_model
def create_agent(model_id: str="gpt-4o-mini"):
model = OpenAIServerModel(model_id=model_id)
agent = CodeAgent(tools=[WikipediaSearchTool(),
DuckDuckGoSearchTool(),
download_video,
extract_frames,
analyze_frame_with_vision_model
],
model=model
)
with open("final_prompt.txt", "r") as f:
sys_prompt = f.read()
return agent, sys_prompt
def create_toolcall_agent(model_id: str="gpt-4o-mini"):
model = OpenAIServerModel(model_id=model_id)
agent = ToolCallingAgent(tools=[WikipediaSearchTool(),
DuckDuckGoSearchTool(),
download_video,
extract_frames,
analyze_frame_with_vision_model
],
model=model
)
with open("final_prompt.txt", "r") as f:
sys_prompt = f.read()
return agent, sys_prompt
def format_agent_prompt(agent_prompt: str,
question: str,
supporting_file: str) -> str:
input_agent_i = agent_prompt.format(question=question)
if len(supporting_file) > 0:
input_agent_i += f"\nSUPPORTING FILE: {supporting_file}"
input_agent_i += "\n\nANSWER:"
return input_agent_i
|