Commit
·
0f45d0b
1
Parent(s):
778116a
removed initial question evaluation
Browse files- config/prompts.yaml +1 -11
- core/agent.py +2 -2
- core/state.py +0 -1
- nodes/nodes.py +1 -8
- utils/prompt_manager.py +0 -1
config/prompts.yaml
CHANGED
|
@@ -71,7 +71,7 @@ prompts:
|
|
| 71 |
final_answer_processor:
|
| 72 |
content: |
|
| 73 |
You are a general AI assistant. You are given a question and an answer to that question.
|
| 74 |
-
Process the answer
|
| 75 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 76 |
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.
|
| 77 |
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.
|
|
@@ -93,16 +93,6 @@ prompts:
|
|
| 93 |
variables: ["summary"]
|
| 94 |
version: 1.0
|
| 95 |
description: "Prompt for summarization and memory optimization"
|
| 96 |
-
question_evaluation:
|
| 97 |
-
content: |
|
| 98 |
-
You are a general AI assistant. You are given with a question. Evaluate this question and answer with a YES if the question involves the analysis of
|
| 99 |
-
an attached file or video link, otherwise with a NO.
|
| 100 |
-
This is the question to be evaluated
|
| 101 |
-
{{question}}
|
| 102 |
-
type: question_refinement
|
| 103 |
-
variables: ["question"]
|
| 104 |
-
version: 1.0
|
| 105 |
-
description: "Prompt for evaluating a question"
|
| 106 |
audio_evaluation:
|
| 107 |
content: |
|
| 108 |
You are an audio analysis assistant. Answer questions based on the provided audio. Be precise and factual.
|
|
|
|
| 71 |
final_answer_processor:
|
| 72 |
content: |
|
| 73 |
You are a general AI assistant. You are given a question and an answer to that question.
|
| 74 |
+
Process the answer and extract YOUR FINAL ANSWER to be provided to the user. Make sure it respects the following guidelines.
|
| 75 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 76 |
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.
|
| 77 |
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.
|
|
|
|
| 93 |
variables: ["summary"]
|
| 94 |
version: 1.0
|
| 95 |
description: "Prompt for summarization and memory optimization"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
audio_evaluation:
|
| 97 |
content: |
|
| 98 |
You are an audio analysis assistant. Answer questions based on the provided audio. Be precise and factual.
|
core/agent.py
CHANGED
|
@@ -45,7 +45,7 @@ class GaiaAgent:
|
|
| 45 |
self.react_graph = builder.compile()
|
| 46 |
|
| 47 |
def __call__(self, question: str, attachment: Optional[Attachment] = None) -> str:
|
| 48 |
-
initial_state = {"messages": [HumanMessage(content=question)]}
|
| 49 |
if attachment:
|
| 50 |
initial_state["file_reference"] = attachment.file_path
|
| 51 |
|
|
@@ -57,7 +57,7 @@ class GaiaAgent:
|
|
| 57 |
return answer
|
| 58 |
|
| 59 |
def __streamed_call__(self, question: str, attachment: Optional[Attachment] = None) -> str:
|
| 60 |
-
initial_state = {"messages": [HumanMessage(content=question)]}
|
| 61 |
if attachment:
|
| 62 |
initial_state["file_reference"] = attachment.file_path
|
| 63 |
|
|
|
|
| 45 |
self.react_graph = builder.compile()
|
| 46 |
|
| 47 |
def __call__(self, question: str, attachment: Optional[Attachment] = None) -> str:
|
| 48 |
+
initial_state = {"messages": [HumanMessage(content=question)], "question": question}
|
| 49 |
if attachment:
|
| 50 |
initial_state["file_reference"] = attachment.file_path
|
| 51 |
|
|
|
|
| 57 |
return answer
|
| 58 |
|
| 59 |
def __streamed_call__(self, question: str, attachment: Optional[Attachment] = None) -> str:
|
| 60 |
+
initial_state = {"messages": [HumanMessage(content=question)], "question": question}
|
| 61 |
if attachment:
|
| 62 |
initial_state["file_reference"] = attachment.file_path
|
| 63 |
|
core/state.py
CHANGED
|
@@ -5,5 +5,4 @@ class State(MessagesState):
|
|
| 5 |
summary: str
|
| 6 |
question: str
|
| 7 |
chunked_last_tool_call: bool
|
| 8 |
-
attachment: str
|
| 9 |
file_reference: str # Attachment file reference: a path, URL, or unique ID
|
|
|
|
| 5 |
summary: str
|
| 6 |
question: str
|
| 7 |
chunked_last_tool_call: bool
|
|
|
|
| 8 |
file_reference: str # Attachment file reference: a path, URL, or unique ID
|
nodes/nodes.py
CHANGED
|
@@ -31,19 +31,12 @@ def pre_processor(state: State):
|
|
| 31 |
|
| 32 |
file_reference = state.get("file_reference", "")
|
| 33 |
extension = pathlib.Path(file_reference).suffix
|
| 34 |
-
if extension == "png":
|
| 35 |
content_bytes = attachmentHandler.fetch_file_from_reference(file_reference)
|
| 36 |
mime_type = mimetypes.guess_type(file_reference)[0]
|
| 37 |
state["messages"][0].content = [{"type": "text", "text": question},
|
| 38 |
attachmentHandler.get_representation("image", content_bytes, "png", mime_type)]
|
| 39 |
|
| 40 |
-
message = prompt_mgmt.render_template("question_evaluation", {"question": question[0]})
|
| 41 |
-
|
| 42 |
-
# Add prompt to our history
|
| 43 |
-
messages = [HumanMessage(content=message)]
|
| 44 |
-
response = response_processing_model.invoke(messages)
|
| 45 |
-
if response.content == "YES":
|
| 46 |
-
return {"question": question, "attachment": "true"}
|
| 47 |
return {"question": question}
|
| 48 |
|
| 49 |
|
|
|
|
| 31 |
|
| 32 |
file_reference = state.get("file_reference", "")
|
| 33 |
extension = pathlib.Path(file_reference).suffix
|
| 34 |
+
if extension == ".png":
|
| 35 |
content_bytes = attachmentHandler.fetch_file_from_reference(file_reference)
|
| 36 |
mime_type = mimetypes.guess_type(file_reference)[0]
|
| 37 |
state["messages"][0].content = [{"type": "text", "text": question},
|
| 38 |
attachmentHandler.get_representation("image", content_bytes, "png", mime_type)]
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return {"question": question}
|
| 41 |
|
| 42 |
|
utils/prompt_manager.py
CHANGED
|
@@ -13,7 +13,6 @@ class PromptType(Enum):
|
|
| 13 |
BASE_SYSTEM = "base_system"
|
| 14 |
ANSWER_REFINEMENT = "answer_refinement"
|
| 15 |
MEMORY_OPTIMIZATION = "memory_optimization"
|
| 16 |
-
QUESTION_REFINEMENT = "question_refinement"
|
| 17 |
TOOL = "tool"
|
| 18 |
|
| 19 |
|
|
|
|
| 13 |
BASE_SYSTEM = "base_system"
|
| 14 |
ANSWER_REFINEMENT = "answer_refinement"
|
| 15 |
MEMORY_OPTIMIZATION = "memory_optimization"
|
|
|
|
| 16 |
TOOL = "tool"
|
| 17 |
|
| 18 |
|