File size: 2,904 Bytes
e545bf8
9b5b26a
 
 
c19d193
6aae614
8fe992b
e6daac3
d0b24f4
9b5b26a
 
5df72d6
8c01ffb
6aae614
ae7a494
8c01ffb
ebc9dfd
 
 
 
 
 
 
8c01ffb
9b5b26a
8c01ffb
bd6cd9e
 
d0b24f4
 
 
 
 
1c426cf
d0b24f4
1c426cf
 
 
 
 
 
 
 
 
 
 
 
 
d0b24f4
 
e545bf8
 
9b5b26a
8c01ffb
e545bf8
d0b24f4
8c01ffb
 
 
 
 
 
bd6cd9e
8fe992b
 
9b5b26a
a500180
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from smolagents import CodeAgent,DuckDuckGoSearchTool, InferenceClientModel,load_tool,tool
import datetime
import requests
import pytz
import yaml
from tools.final_answer import FinalAnswerTool

from smolagents import Tool

from Gradio_UI import GradioUI

# Below is an example of a tool that does nothing. Amaze us with your creativity !

final_answer = FinalAnswerTool()


system_promot = """
You are a helpful assistant tasked with answering questions using a set of tools. 
Now, I will ask you a question. Report your thoughts, and finish your answer with the following template: 
FINAL ANSWER: [YOUR FINAL ANSWER]. 
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
Your answer should only start with "FINAL ANSWER: ", then follows with the answer. 
"""

# Import tool from Hub

with open("prompts.yaml", 'r') as stream:
    prompt_templates = yaml.safe_load(stream)



# === Tool Definitions ===


TOOL_REGISTRY = [
    Tool(name="wikipedia_search", entry_point="mytools.wikipedia_search.call"),
    Tool(name="youtube_transcript", entry_point="mytools.youtube_transcript.call"),
    Tool(name="video_frame_analyzer", entry_point="mytools.video_frame_analyzer.call"),
    Tool(name="string_manipulator", entry_point="mytools.string_manipulator.call"),
    Tool(name="vision_chess_engine", entry_point="mytools.vision_chess_engine.call"),
    Tool(name="table_parser", entry_point="mytools.table_parser.call"),
    Tool(name="libretext_fetcher", entry_point="mytools.libretext_fetcher.call"),
    Tool(name="audio_transcriber", entry_point="mytools.audio_transcriber.call"),
    Tool(name="botanical_classifier", entry_point="mytools.botanical_classifier.call"),
    Tool(name="imdb_lookup", entry_point="mytools.imdb_lookup.call"),
    Tool(name="excel_reader", entry_point="mytools.excel_reader.call"),
    Tool(name="competition_db", entry_point="mytools.competition_db.call"),
    Tool(name="japanese_baseball_api", entry_point="mytools.japanese_baseball_api.call"),
]


model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
    
agent = CodeAgent(
    model= InferenceClientModel(model_id=model_id),
    tools=[final_answer, *TOOL_REGISTRY], ## add your tools here (don't remove final answer)
    max_steps=6,
    verbosity_level=1,
    grammar=None,
    planning_interval=None,
    name=None,
    description=None,
    prompt_templates=prompt_templates
)


GradioUI(agent).launch(share=False)