commit
Browse files- app.py +8 -7
- my_prompt_config.py +16 -10
- my_tool_chess_analysis.py +3 -1
app.py
CHANGED
|
@@ -15,8 +15,8 @@ questions_to_run = [
|
|
| 15 |
#"8e867cd7-cff9-4e6c-867a-ff5ddc2550be", # good answer, wrong albums
|
| 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",
|
|
@@ -108,11 +108,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 108 |
continue
|
| 109 |
|
| 110 |
try:
|
| 111 |
-
if question_file_name is not None:
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
submitted_answer = agent(question_text)
|
| 118 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
|
|
|
| 15 |
#"8e867cd7-cff9-4e6c-867a-ff5ddc2550be", # good answer, wrong albums
|
| 16 |
#"a1e91b78-d3d8-4675-bb8d-62741b4b68a6",
|
| 17 |
#"2d83110e-a098-4ebb-9987-066c06fa42d0", # OK
|
| 18 |
+
# "cca530fc-4052-43b2-b130-b30968d8aa44", # OK, need to remove FINAL_ANSWER string
|
| 19 |
+
"4fc2f1ae-8625-45b5-ab34-ad4433bc21f8", # <--------
|
| 20 |
#"6f37996b-2ac7-44b0-8e68-6d28256631b4",
|
| 21 |
#"9d191bce-651d-4746-be2d-7ef8ecadb9c2",
|
| 22 |
#"cabe07ed-9eca-40ea-8ead-410ef5e83f91",
|
|
|
|
| 108 |
continue
|
| 109 |
|
| 110 |
try:
|
| 111 |
+
#if question_file_name is not None:
|
| 112 |
+
# ext = question_file_name[-4:]
|
| 113 |
+
# if ext == ".png":
|
| 114 |
+
# question_text = question_text + (f" Use one of available tools to load an image associated with "
|
| 115 |
+
# f"task_id: '{task_id}'")
|
| 116 |
+
question_text = question_text + f" task_id: '{task_id}'"
|
| 117 |
|
| 118 |
submitted_answer = agent(question_text)
|
| 119 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
my_prompt_config.py
CHANGED
|
@@ -27,7 +27,8 @@ class MyPromptConfig:
|
|
| 27 |
If you are going to use a tool, describe in detail how you are going
|
| 28 |
to invoke the tool and explain parameters used to invoke the tool.
|
| 29 |
|
| 30 |
-
The list of tools available
|
|
|
|
| 31 |
|
| 32 |
* _my_tool_chess_analysis : analyze chess position provided as FEN notation
|
| 33 |
* _my_tool_chess_board : extract list of chess pieces from chess board image
|
|
@@ -35,6 +36,9 @@ class MyPromptConfig:
|
|
| 35 |
* _my_tool_image_load : load image of the chess board for given task_id
|
| 36 |
* _my_tool_reverse_string : reverse provided string
|
| 37 |
|
|
|
|
|
|
|
|
|
|
| 38 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of
|
| 39 |
numbers and/or strings.
|
| 40 |
If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent
|
|
@@ -44,7 +48,16 @@ class MyPromptConfig:
|
|
| 44 |
If you are asked for a comma separated list, apply the above rules depending of whether the element to be put
|
| 45 |
in the list is a number or a string.
|
| 46 |
|
| 47 |
-
Report your answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
""",
|
| 50 |
planning=PlanningPromptTemplate(
|
|
@@ -62,14 +75,7 @@ class MyPromptConfig:
|
|
| 62 |
final_answer=FinalAnswerPromptTemplate(
|
| 63 |
pre_messages="",
|
| 64 |
post_messages="""
|
| 65 |
-
|
| 66 |
-
numbers and/or strings.
|
| 67 |
-
If you are asked for a number, don’t use comma to write your number neither use units such as $ or
|
| 68 |
-
percent sign unless specified otherwise.
|
| 69 |
-
If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities),
|
| 70 |
-
and write the digits in plain text unless specified otherwise.
|
| 71 |
-
If you are asked for a comma separated list, apply the above rules depending of whether the element
|
| 72 |
-
to be put in the list is a number or a string
|
| 73 |
"""
|
| 74 |
),
|
| 75 |
)
|
|
|
|
| 27 |
If you are going to use a tool, describe in detail how you are going
|
| 28 |
to invoke the tool and explain parameters used to invoke the tool.
|
| 29 |
|
| 30 |
+
The list of tools available is provided below. The allow to solve a variety of various questions asked.
|
| 31 |
+
Decide and Pick and use only tools which are necessary to answer the question asked.
|
| 32 |
|
| 33 |
* _my_tool_chess_analysis : analyze chess position provided as FEN notation
|
| 34 |
* _my_tool_chess_board : extract list of chess pieces from chess board image
|
|
|
|
| 36 |
* _my_tool_image_load : load image of the chess board for given task_id
|
| 37 |
* _my_tool_reverse_string : reverse provided string
|
| 38 |
|
| 39 |
+
If the question mentions image or other file, use one of provided tools to load it
|
| 40 |
+
using task_id associated with the question.
|
| 41 |
+
|
| 42 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of
|
| 43 |
numbers and/or strings.
|
| 44 |
If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent
|
|
|
|
| 48 |
If you are asked for a comma separated list, apply the above rules depending of whether the element to be put
|
| 49 |
in the list is a number or a string.
|
| 50 |
|
| 51 |
+
Report your answer using final_answer tool
|
| 52 |
+
|
| 53 |
+
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of
|
| 54 |
+
numbers and/or strings.
|
| 55 |
+
If you are asked for a number, don’t use comma to write your number neither use units such as $ or
|
| 56 |
+
percent sign unless specified otherwise.
|
| 57 |
+
If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities),
|
| 58 |
+
and write the digits in plain text unless specified otherwise.
|
| 59 |
+
If you are asked for a comma separated list, apply the above rules depending of whether the element
|
| 60 |
+
to be put in the list is a number or a string
|
| 61 |
|
| 62 |
""",
|
| 63 |
planning=PlanningPromptTemplate(
|
|
|
|
| 75 |
final_answer=FinalAnswerPromptTemplate(
|
| 76 |
pre_messages="",
|
| 77 |
post_messages="""
|
| 78 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
"""
|
| 80 |
),
|
| 81 |
)
|
my_tool_chess_analysis.py
CHANGED
|
@@ -37,6 +37,7 @@ class ChessAnalysisTool(Tool):
|
|
| 37 |
"player_color": {
|
| 38 |
"type": "string",
|
| 39 |
"description": "black or white to make next move",
|
|
|
|
| 40 |
}
|
| 41 |
}
|
| 42 |
|
|
@@ -52,7 +53,8 @@ class ChessAnalysisTool(Tool):
|
|
| 52 |
def initialize(self):
|
| 53 |
print(f"***KS*** Chess analysis tool initialized (2) with engine: {self.engine}")
|
| 54 |
|
| 55 |
-
def forward(self, fen: str, player_color
|
|
|
|
| 56 |
print(f"***KS*** Chess analysis tool getting best move for player: {player_color} with position: {fen}")
|
| 57 |
best_move = ""
|
| 58 |
try:
|
|
|
|
| 37 |
"player_color": {
|
| 38 |
"type": "string",
|
| 39 |
"description": "black or white to make next move",
|
| 40 |
+
"nullable": True
|
| 41 |
}
|
| 42 |
}
|
| 43 |
|
|
|
|
| 53 |
def initialize(self):
|
| 54 |
print(f"***KS*** Chess analysis tool initialized (2) with engine: {self.engine}")
|
| 55 |
|
| 56 |
+
def forward(self, fen: str, player_color = "") -> str:
|
| 57 |
+
# TODO use player_color correctly and set it on FEN in proper position
|
| 58 |
print(f"***KS*** Chess analysis tool getting best move for player: {player_color} with position: {fen}")
|
| 59 |
best_move = ""
|
| 60 |
try:
|