commit
Browse files- app.py +19 -19
- my_agent.py +5 -39
- my_prompt_config.py +5 -15
- my_tool_wiki_featured_articles.py +1 -1
- my_tool_wiki_filter_tables.py +1 -2
app.py
CHANGED
|
@@ -12,26 +12,26 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# testing --------------------------------------------
|
| 13 |
testing_mode = True
|
| 14 |
questions_to_run = [
|
| 15 |
-
#"8e867cd7-cff9-4e6c-867a-ff5ddc2550be",
|
| 16 |
-
#"a1e91b78-d3d8-4675-bb8d-62741b4b68a6", #
|
| 17 |
#"2d83110e-a098-4ebb-9987-066c06fa42d0", # OK
|
| 18 |
-
#"cca530fc-4052-43b2-b130-b30968d8aa44", # OK
|
| 19 |
-
|
| 20 |
-
#"6f37996b-2ac7-44b0-8e68-6d28256631b4", #
|
| 21 |
-
#"9d191bce-651d-4746-be2d-7ef8ecadb9c2", #
|
| 22 |
-
"cabe07ed-9eca-40ea-8ead-410ef5e83f91",
|
| 23 |
-
#"3cef3a44-215e-4aed-8e3b-b1e3f08063b7",
|
| 24 |
-
#"99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3",
|
| 25 |
-
#"305ac316-eef6-4446-960a-92d80d542f82",
|
| 26 |
-
#"f918266a-b3e0-4914-865d-4faa564f1aef",
|
| 27 |
-
#"3f57289b-8c60-48be-bd80-01f8099ca449",
|
| 28 |
-
#"1f975693-876d-457b-a649-393859e79bf3",
|
| 29 |
-
#"840bfca7-4f7b-481a-8794-c560c340185d",
|
| 30 |
-
#"bda648d7-d618-4883-88f4-3466eabd860e",
|
| 31 |
-
#"cf106601-ab4f-4af9-b045-5295fe67b37d",
|
| 32 |
-
#"a0c07678-e491-4bbc-8f0b-07405144218f",
|
| 33 |
-
#"7bd855d8-463d-4ed5-93ca-5fe35145f733",
|
| 34 |
-
#"5a0c1adf-205e-4841-a666-7c3ef95def9d",
|
| 35 |
]
|
| 36 |
# testing --------------------------------------------
|
| 37 |
|
|
|
|
| 12 |
# testing --------------------------------------------
|
| 13 |
testing_mode = True
|
| 14 |
questions_to_run = [
|
| 15 |
+
#"8e867cd7-cff9-4e6c-867a-ff5ddc2550be", # - 3, should be ok
|
| 16 |
+
#"a1e91b78-d3d8-4675-bb8d-62741b4b68a6", # - video
|
| 17 |
#"2d83110e-a098-4ebb-9987-066c06fa42d0", # OK
|
| 18 |
+
#"cca530fc-4052-43b2-b130-b30968d8aa44", # OK
|
| 19 |
+
"4fc2f1ae-8625-45b5-ab34-ad4433bc21f8", # - FunkMonk, wrong answer https://en.wikipedia.org/wiki/Giganotosaurus
|
| 20 |
+
#"6f37996b-2ac7-44b0-8e68-6d28256631b4", # -
|
| 21 |
+
#"9d191bce-651d-4746-be2d-7ef8ecadb9c2", # -
|
| 22 |
+
#"cabe07ed-9eca-40ea-8ead-410ef5e83f91", # -
|
| 23 |
+
#"3cef3a44-215e-4aed-8e3b-b1e3f08063b7", # -
|
| 24 |
+
#"99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3", # -
|
| 25 |
+
#"305ac316-eef6-4446-960a-92d80d542f82", # Hubert ?
|
| 26 |
+
#"f918266a-b3e0-4914-865d-4faa564f1aef", # -
|
| 27 |
+
#"3f57289b-8c60-48be-bd80-01f8099ca449", # 566 ?
|
| 28 |
+
#"1f975693-876d-457b-a649-393859e79bf3", # -
|
| 29 |
+
#"840bfca7-4f7b-481a-8794-c560c340185d", # 80NSSC20K0910 ?
|
| 30 |
+
#"bda648d7-d618-4883-88f4-3466eabd860e", # Saint Petersburg ?
|
| 31 |
+
#"cf106601-ab4f-4af9-b045-5295fe67b37d", # -
|
| 32 |
+
#"a0c07678-e491-4bbc-8f0b-07405144218f", # -
|
| 33 |
+
#"7bd855d8-463d-4ed5-93ca-5fe35145f733", # -
|
| 34 |
+
#"5a0c1adf-205e-4841-a666-7c3ef95def9d", # Vladimir ?
|
| 35 |
]
|
| 36 |
# testing --------------------------------------------
|
| 37 |
|
my_agent.py
CHANGED
|
@@ -26,6 +26,8 @@ class MyAgent:
|
|
| 26 |
#MODEL_REASONING = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 27 |
#MODEL_REASONING = "deepseek-ai/DeepSeek-R1"
|
| 28 |
MODEL_REASONING = "Qwen/Qwen3-235B-A22B" # test more
|
|
|
|
|
|
|
| 29 |
#MODEL_REASONING = "mistralai/Mixtral-8x22B-v0.1" # not available via HuggingFace
|
| 30 |
chess_board_model_name = "my_chess_pieces_recognition.pth"
|
| 31 |
chess_board_model_dir = "/mnt/c/Users/krzsa/IdeaProjects/Agents-Course-Assignment/saved_models"
|
|
@@ -63,6 +65,8 @@ class MyAgent:
|
|
| 63 |
name="CourseAssistant",
|
| 64 |
description="General AI Assistant",
|
| 65 |
tools=[
|
|
|
|
|
|
|
| 66 |
ImageLoadTool(),
|
| 67 |
ReverseStringTool(),
|
| 68 |
ChessBoard(self.chess_board_model_name, self.chess_board_model_dir),
|
|
@@ -70,13 +74,13 @@ class MyAgent:
|
|
| 70 |
ChessAnalysisTool(),
|
| 71 |
MyWikiPageSectionTool(),
|
| 72 |
MyWikiTableFilterTool(),
|
| 73 |
-
WebSearchTool(),
|
| 74 |
MyWikiFeaturedArticles(),
|
| 75 |
MyLibreTextsBookshelvesTool(),
|
| 76 |
MyLibreTextsBooksTool(),
|
| 77 |
MyLibreTextsBookSectionsTool(),
|
| 78 |
MyLibreTextsBookSectionParagraphsTool(),
|
| 79 |
MyLibreTextsParagraphContentsTool(),
|
|
|
|
| 80 |
FinalAnswerTool(),
|
| 81 |
],
|
| 82 |
model=self.model,
|
|
@@ -107,44 +111,6 @@ class MyAgent:
|
|
| 107 |
"my_base_libretexts_api"
|
| 108 |
],
|
| 109 |
)
|
| 110 |
-
#web_search_agent = CodeAgent(
|
| 111 |
-
# tools=[WebSearchTool()],
|
| 112 |
-
# model=InferenceClientModel(model_id=self.MODEL_CODER),
|
| 113 |
-
# name="agent_websearch",
|
| 114 |
-
# description="Agent to browse and search and extract web content"
|
| 115 |
-
#)
|
| 116 |
-
|
| 117 |
-
# self.image_generation_tool = load_tool("m-ric/text-to-image", trust_remote_code=True)
|
| 118 |
-
#image_generation_tool = Tool.from_space(
|
| 119 |
-
# "black-forest-labs/FLUX.1-schnell",
|
| 120 |
-
# name="image_generator",
|
| 121 |
-
# description="Generate an image from a prompt"
|
| 122 |
-
#)
|
| 123 |
-
|
| 124 |
-
#image_captioning_tool = Tool.from_space(
|
| 125 |
-
# "ovi054/image-to-prompt",
|
| 126 |
-
# name="image_captioning",
|
| 127 |
-
# description="Generate description of an image"
|
| 128 |
-
#)
|
| 129 |
-
|
| 130 |
-
#image_loading_tool = ImageLoadTool()
|
| 131 |
-
#print(f"Image load tool: {image_loading_tool}")
|
| 132 |
-
|
| 133 |
-
#image_generation_agent = CodeAgent(
|
| 134 |
-
# tools=[image_generation_tool],
|
| 135 |
-
# model=InferenceClientModel(model_id=self.MODEL_CODER)
|
| 136 |
-
#)
|
| 137 |
-
|
| 138 |
-
# ImageLoadTool()
|
| 139 |
-
#self.reasoning_agent = CodeAgent(
|
| 140 |
-
# #tools=[image_generation_tool, image_captioning_tool, ReverseStringTool(), image_loading_tool],
|
| 141 |
-
# tools=[image_loading_tool, FinalAnswerTool()],
|
| 142 |
-
# model=InferenceClientModel(model_id=self.MODEL_REASONING),
|
| 143 |
-
# planning_interval=3, # This is where you activate planning!,
|
| 144 |
-
# prompt_templates=PromptConfig().PROMPT_TEMPLATES,
|
| 145 |
-
# managed_agents=[web_search_agent],
|
| 146 |
-
# additional_authorized_imports=["PIL","chess","my_tools","my_tools."],
|
| 147 |
-
#)
|
| 148 |
print(f"Main agent initialized: {self.reasoning_agent}")
|
| 149 |
|
| 150 |
def __call__(self, question: str) -> str:
|
|
|
|
| 26 |
#MODEL_REASONING = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 27 |
#MODEL_REASONING = "deepseek-ai/DeepSeek-R1"
|
| 28 |
MODEL_REASONING = "Qwen/Qwen3-235B-A22B" # test more
|
| 29 |
+
#MODEL_REASONING = "Qwen/Qwen3-235B-A22B-Thinking-2507"
|
| 30 |
+
#MODEL_REASONING = "Qwen/Qwen3-235B-A22B-Thinking-2507-FP8"
|
| 31 |
#MODEL_REASONING = "mistralai/Mixtral-8x22B-v0.1" # not available via HuggingFace
|
| 32 |
chess_board_model_name = "my_chess_pieces_recognition.pth"
|
| 33 |
chess_board_model_dir = "/mnt/c/Users/krzsa/IdeaProjects/Agents-Course-Assignment/saved_models"
|
|
|
|
| 65 |
name="CourseAssistant",
|
| 66 |
description="General AI Assistant",
|
| 67 |
tools=[
|
| 68 |
+
WebSearchTool(),
|
| 69 |
+
# -------
|
| 70 |
ImageLoadTool(),
|
| 71 |
ReverseStringTool(),
|
| 72 |
ChessBoard(self.chess_board_model_name, self.chess_board_model_dir),
|
|
|
|
| 74 |
ChessAnalysisTool(),
|
| 75 |
MyWikiPageSectionTool(),
|
| 76 |
MyWikiTableFilterTool(),
|
|
|
|
| 77 |
MyWikiFeaturedArticles(),
|
| 78 |
MyLibreTextsBookshelvesTool(),
|
| 79 |
MyLibreTextsBooksTool(),
|
| 80 |
MyLibreTextsBookSectionsTool(),
|
| 81 |
MyLibreTextsBookSectionParagraphsTool(),
|
| 82 |
MyLibreTextsParagraphContentsTool(),
|
| 83 |
+
# ---------
|
| 84 |
FinalAnswerTool(),
|
| 85 |
],
|
| 86 |
model=self.model,
|
|
|
|
| 111 |
"my_base_libretexts_api"
|
| 112 |
],
|
| 113 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
print(f"Main agent initialized: {self.reasoning_agent}")
|
| 115 |
|
| 116 |
def __call__(self, question: str) -> str:
|
my_prompt_config.py
CHANGED
|
@@ -23,16 +23,15 @@ class MyPromptConfig:
|
|
| 23 |
Decide and pick and use only tools which are necessary to answer the question asked.
|
| 24 |
If the tool looks proper for the task, use it in the first place, instead of generating the code
|
| 25 |
yourself to achieve the same task.
|
| 26 |
-
|
| 27 |
-
* _my_tool_chess_analysis : analyze chess position provided as FEN notation
|
| 28 |
-
* _my_tool_chess_board : extract list of chess pieces from chess board image
|
| 29 |
-
* _my_tool_fen : convert list of chess pieces into FEN notation
|
| 30 |
* _my_tool_image_load : load image of the chess board for given task_id
|
| 31 |
* _my_tool_reverse_string : reverse provided string
|
|
|
|
|
|
|
|
|
|
| 32 |
* _my_tool_wiki_page_section : get contents of a section of the Wikipedia page
|
| 33 |
* _my_tool_wiki_table_filter : filter the subsection and tables on the Wikipedia page for provided years
|
| 34 |
-
* _my_tool_wiki_featured_articles : get nominator and summary information for Wikipedia featured articles
|
| 35 |
-
for given month and year
|
| 36 |
* _my_tool_libretexts_bookshelves : Get a list of bookshelves in LibreTexts library of chemistry materials
|
| 37 |
* _my_tool_libretexts_books : Get a list of books in LibreTexts bookshelf
|
| 38 |
* _my_tool_libretexts_book_sections : Get a list of sections in a book in LibreTexts materials
|
|
@@ -41,15 +40,6 @@ class MyPromptConfig:
|
|
| 41 |
|
| 42 |
If the question mentions image or other file, use one of provided tools to load it
|
| 43 |
using task_id associated with the question.
|
| 44 |
-
|
| 45 |
-
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of
|
| 46 |
-
numbers and/or strings.
|
| 47 |
-
If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent
|
| 48 |
-
sign unless specified otherwise.
|
| 49 |
-
If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the digits in
|
| 50 |
-
plain text unless specified otherwise.
|
| 51 |
-
If you are asked for a comma separated list, apply the above rules depending of whether the element to be put
|
| 52 |
-
in the list is a number or a string.
|
| 53 |
""",
|
| 54 |
planning=PlanningPromptTemplate(
|
| 55 |
initial_plan="""
|
|
|
|
| 23 |
Decide and pick and use only tools which are necessary to answer the question asked.
|
| 24 |
If the tool looks proper for the task, use it in the first place, instead of generating the code
|
| 25 |
yourself to achieve the same task.
|
| 26 |
+
Available tools:
|
|
|
|
|
|
|
|
|
|
| 27 |
* _my_tool_image_load : load image of the chess board for given task_id
|
| 28 |
* _my_tool_reverse_string : reverse provided string
|
| 29 |
+
* _my_tool_chess_board : extract list of chess pieces from chess board image
|
| 30 |
+
* _my_tool_fen : convert list of chess pieces into FEN notation
|
| 31 |
+
* _my_tool_chess_analysis : analyze chess position provided as FEN notation
|
| 32 |
* _my_tool_wiki_page_section : get contents of a section of the Wikipedia page
|
| 33 |
* _my_tool_wiki_table_filter : filter the subsection and tables on the Wikipedia page for provided years
|
| 34 |
+
* _my_tool_wiki_featured_articles : get nominator and summary information for Wikipedia featured articles for given month and year
|
|
|
|
| 35 |
* _my_tool_libretexts_bookshelves : Get a list of bookshelves in LibreTexts library of chemistry materials
|
| 36 |
* _my_tool_libretexts_books : Get a list of books in LibreTexts bookshelf
|
| 37 |
* _my_tool_libretexts_book_sections : Get a list of sections in a book in LibreTexts materials
|
|
|
|
| 40 |
|
| 41 |
If the question mentions image or other file, use one of provided tools to load it
|
| 42 |
using task_id associated with the question.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
""",
|
| 44 |
planning=PlanningPromptTemplate(
|
| 45 |
initial_plan="""
|
my_tool_wiki_featured_articles.py
CHANGED
|
@@ -21,7 +21,7 @@ class MyWikiFeaturedArticles(Tool):
|
|
| 21 |
Extracts a list of nominators and summaries of featured Wikipedia articles for the provided month and year
|
| 22 |
To invoke the tool use code as below
|
| 23 |
<code>
|
| 24 |
-
|
| 25 |
</code>
|
| 26 |
"""
|
| 27 |
|
|
|
|
| 21 |
Extracts a list of nominators and summaries of featured Wikipedia articles for the provided month and year
|
| 22 |
To invoke the tool use code as below
|
| 23 |
<code>
|
| 24 |
+
featured_articles = _my_tool_wiki_featured_articles(month='January', year=2005)
|
| 25 |
</code>
|
| 26 |
"""
|
| 27 |
|
my_tool_wiki_filter_tables.py
CHANGED
|
@@ -23,8 +23,7 @@ class MyWikiTableFilterTool(Tool):
|
|
| 23 |
Extract contents of the page section for the provided a Wikipedia page
|
| 24 |
To invoke the tool use code as below
|
| 25 |
<code>
|
| 26 |
-
section_contents = _my_tool_wiki_table_filter(section_content='aaa', sub_section_name='bbb',
|
| 27 |
-
year_start='1998', year_end='2005')
|
| 28 |
</code>
|
| 29 |
"""
|
| 30 |
|
|
|
|
| 23 |
Extract contents of the page section for the provided a Wikipedia page
|
| 24 |
To invoke the tool use code as below
|
| 25 |
<code>
|
| 26 |
+
section_contents = _my_tool_wiki_table_filter(section_content='aaa', sub_section_name='bbb', year_start='1998', year_end='2005')
|
|
|
|
| 27 |
</code>
|
| 28 |
"""
|
| 29 |
|