giulia-fontanella commited on
Commit
58c57f1
·
verified ·
1 Parent(s): 7d92ce8

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +2 -34
agent.py CHANGED
@@ -52,43 +52,11 @@ class BasicAgent():
52
 
53
 
54
  def assistant(self, state: AgentState):
55
- textual_description_of_tool="""
56
- extract_text(img_path: str) -> str:
57
- Extract text from an image file using a multimodal model.
58
-
59
- Args:
60
- img_path: A url pointing to an image (e.g., PNG, JPEG).
61
-
62
- Returns:
63
- A single string containing the concatenated text extracted from each image.
64
-
65
- search_tool(query: str) -> str:
66
- Search the web using the DuckDuckGoSearchRun to perform a search query and return a summarized textual result.
67
-
68
- Args:
69
- query: A string representing the search query.
70
-
71
- Returns:
72
- A single string containing the search result or summary.
73
-
74
- describe_image(img_path: str, query: str) -> str:
75
- Generate a detailed description of an image using a multimodal model.
76
- This function reads a image from an url, encodes it, and sends it to a
77
- vision-capable language model to obtain a comprehensive, natural language
78
- description of the image's content, including its objects, actions, and context,
79
- following a specific query.
80
-
81
- Args:
82
- img_path: A url pointing to an image (e.g., PNG, JPEG).
83
- query: Information to extract from the image
84
-
85
- Returns:
86
- A single string containing a detailed, human-readable description of the image.
87
- """
88
  sys_msg = SystemMessage(content=f"""
89
  You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
90
  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.
91
- You have access to the following tools:\n{textual_description_of_tool}\n""")
92
 
93
  return {
94
  "messages": [self.chat_with_tools.invoke([sys_msg] + state["messages"])],
 
52
 
53
 
54
  def assistant(self, state: AgentState):
55
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  sys_msg = SystemMessage(content=f"""
57
  You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
58
  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.
59
+ """)
60
 
61
  return {
62
  "messages": [self.chat_with_tools.invoke([sys_msg] + state["messages"])],