dgl1797 commited on
Commit
d55b613
·
1 Parent(s): f244f8d

agent advanced workflow

Browse files
assets/agent_graph.png ADDED
assets/questions.csv ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,task_id,question,Level,file_name,Question,Final answer,file_path,Annotator Metadata
2
+ 0,8e867cd7-cff9-4e6c-867a-ff5ddc2550be,How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.,1,,How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.,3,,"{'Steps': '1. I did a search for Mercedes Sosa\n2. I went to the Wikipedia page for her\n3. I scrolled down to ""Studio albums""\n4. I counted the ones between 2000 and 2009', 'Number of steps': '4', 'How long did this take?': '5 minutes', 'Tools': '1. web browser\n2. google search', 'Number of tools': '2'}"
3
+ 1,a1e91b78-d3d8-4675-bb8d-62741b4b68a6,"In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",1,,"In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",3,,"{'Steps': '1. Navigate to the YouTube link.\n2. Watch the video to see the highest number of bird species.\n3. Note the number.', 'Number of steps': '3', 'How long did this take?': '3 minutes', 'Tools': '1. Web browser\n2. Video parsing', 'Number of tools': '2'}"
4
+ 2,2d83110e-a098-4ebb-9987-066c06fa42d0,".rewsna eht sa ""tfel"" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",1,,".rewsna eht sa ""tfel"" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",Right,,"{'Steps': '1. Read the instructions in reverse', 'Number of steps': '1', 'How long did this take?': '1 minute', 'Tools': '1. A word reversal tool / script', 'Number of tools': '0'}"
5
+ 3,cca530fc-4052-43b2-b130-b30968d8aa44,Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.,1,cca530fc-4052-43b2-b130-b30968d8aa44.png,Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.,Rd5,2023/validation/cca530fc-4052-43b2-b130-b30968d8aa44.png,"{'Steps': 'Step 1: Evaluate the position of the pieces in the chess position\nStep 2: Report the best move available for black: ""Rd5""', 'Number of steps': '2', 'How long did this take?': '10 minutes', 'Tools': '1. Image recognition tools', 'Number of tools': '1'}"
6
+ 4,4fc2f1ae-8625-45b5-ab34-ad4433bc21f8,Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?,1,,Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?,FunkMonk,,"{'Steps': '1. Search ""Wikipedia featured articles promoted in november 2016""\n2. Click through to the appropriate page and find the person who nominated Giganotosaurus.', 'Number of steps': '2', 'How long did this take?': '5 minutes', 'Tools': '1. web browser\n2. search engine', 'Number of tools': '2'}"
7
+ 5,6f37996b-2ac7-44b0-8e68-6d28256631b4,"Given this table defining * on the set S = {a, b, c, d, e}
8
+
9
+ |*|a|b|c|d|e|
10
+ |---|---|---|---|---|---|
11
+ |a|a|b|c|b|d|
12
+ |b|b|c|a|e|c|
13
+ |c|c|a|b|b|a|
14
+ |d|b|e|b|e|d|
15
+ |e|d|b|a|d|c|
16
+
17
+ provide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.",1,,"Given this table defining * on the set S = {a, b, c, d, e}
18
+
19
+ |*|a|b|c|d|e|
20
+ |---|---|---|---|---|---|
21
+ |a|a|b|c|b|d|
22
+ |b|b|c|a|e|c|
23
+ |c|c|a|b|b|a|
24
+ |d|b|e|b|e|d|
25
+ |e|d|b|a|d|c|
26
+
27
+ provide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.","b, e",,"{'Steps': '1. Compile the markdown.\n2. Look at the table across the diagonal to see if any portions are not symmetrical.\n3. See that b * e != e * b, but all others are symmetrical.', 'Number of steps': '3', 'How long did this take?': '5 minutes', 'Tools': '1. Markdown', 'Number of tools': '1'}"
28
+ 6,9d191bce-651d-4746-be2d-7ef8ecadb9c2,"Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.
29
+
30
+ What does Teal'c say in response to the question ""Isn't that hot?""",1,,"Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.
31
+
32
+ What does Teal'c say in response to the question ""Isn't that hot?""",Extremely,,"{'Steps': '1. Follow the link\n2. Watch the clip until the question ""Isn\'t that hot"" is asked\n3. Take note of the reply.', 'Number of steps': '3', 'How long did this take?': '2 minutes', 'Tools': '1. Web browser\n2. Video processing software\n3. Audio processing software', 'Number of tools': '1'}"
33
+ 7,cabe07ed-9eca-40ea-8ead-410ef5e83f91,What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?,1,,What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?,Louvrier,,"{'Steps': '1. Search for ""1.E Exercises LibreText Introductory Chemistry""\n2. Read to see the horse doctor mentioned.', 'Number of steps': '2', 'How long did this take?': '5 minutes', 'Tools': '1. Web browser\n2. Search engine', 'Number of tools': '2'}"
34
+ 8,3cef3a44-215e-4aed-8e3b-b1e3f08063b7,"I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:
35
+
36
+ milk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts
37
+
38
+ I need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.",1,,"I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:
39
+
40
+ milk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts
41
+
42
+ I need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.","broccoli, celery, fresh basil, lettuce, sweet potatoes",,"{'Steps': 'Step 1: Evaluate the list provided by my user, eliminating objects which are neither fruits nor vegetables:\nsweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\nStep 2: Remove all items from the list which are botanical fruits, leaving a list of vegetables:\nsweet potatoes, fresh basil, broccoli, celery, lettuce\nStep 3: Alphabetize the remaining list as requested by my user:\nbroccoli, celery, fresh basil, lettuce, sweet potatoes\nStep 4: Provide the correct response in the requested format:\n""broccoli\ncelery\nfresh basil\nlettuce\nsweet potatoes""', 'Number of steps': '4', 'How long did this take?': '5 minutes', 'Tools': 'No tools required', 'Number of tools': '0'}"
43
+ 9,99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3,"Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3.
44
+
45
+ In your response, please only list the ingredients, not any measurements. So if the recipe calls for ""a pinch of salt"" or ""two cups of ripe strawberries"" the ingredients on the list would be ""salt"" and ""ripe strawberries"".
46
+
47
+ Please format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.",1,99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3,"Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3.
48
+
49
+ In your response, please only list the ingredients, not any measurements. So if the recipe calls for ""a pinch of salt"" or ""two cups of ripe strawberries"" the ingredients on the list would be ""salt"" and ""ripe strawberries"".
50
+
51
+ Please format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.","cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries",2023/validation/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3,"{'Steps': 'Step 1: Load the file supplied to me by my user.\nStep 2: Using speech-to-text tools, convert the audio file to plain text and store it for the candidate word list:\n\n""In a saucepan, combine ripe strawberries, granulated sugar, freshly squeezed lemon juice, and cornstarch. Cook the mixture over medium heat, stirring constantly, until it thickens to a smooth consistency. Remove from heat and stir in a dash of pure vanilla extract. Allow the strawberry pie filling to cool before using it as a delicious and fruity filling for your pie crust.""\n\nStep 3: Evaluate the candidate word list and process it, stripping each ingredient encountered to a provisional response list:\n\nripe strawberries\ngranulated sugar\nfreshly squeezed lemon juice\ncornstarch\npure vanilla extract\n\nStep 4: Alphabetize the list of ingredients as requested by my user to create a finalized response:\n\ncornstarch\nfreshly squeezed lemon juice\ngranulated sugar\npure vanilla extract\nripe strawberries\n\nStep 5: Report the correct response to my user:\n\n""cornstarch\nfreshly squeezed lemon juice\ngranulated sugar\npure vanilla extract\nripe strawberries""', 'Number of steps': '5', 'How long did this take?': '3 minutes', 'Tools': '1. A file interface\n2. A speech-to-text tool', 'Number of tools': '2'}"
52
+ 10,305ac316-eef6-4446-960a-92d80d542f82,Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.,1,,Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.,Wojciech,,"{'Steps': '1. Search ""Polish-language version of Everybody Loves Raymond"" and pull up the Wiki page for Wszyscy kochają Romana.\n2. See that Bartłomiej Kasprzykowski is marked as playing Ray and go to his Wiki page.\n3. See that he is stated to have played Wojciech Płaska in Magda M.', 'Number of steps': '3', 'How long did this take?': '5 minutes', 'Tools': 'None', 'Number of tools': '0'}"
53
+ 11,f918266a-b3e0-4914-865d-4faa564f1aef,What is the final numeric output from the attached Python code?,1,f918266a-b3e0-4914-865d-4faa564f1aef.py,What is the final numeric output from the attached Python code?,0,2023/validation/f918266a-b3e0-4914-865d-4faa564f1aef.py,"{'Steps': '1. Run the attached Python code', 'Number of steps': '1', 'How long did this take?': '30 seconds', 'Tools': '1. Python', 'Number of tools': '1'}"
54
+ 12,3f57289b-8c60-48be-bd80-01f8099ca449,How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?,1,,How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?,519,,"{'Steps': '1. Search ""yankee stats"" to find their MLB stats page.\n2. Set the data to the 1977 regular season.\n3. Sort to find the most walks.\n4. See how many at bats the player had.', 'Number of steps': '4', 'How long did this take?': '5 minutes', 'Tools': '1. web browser\n2. search engine', 'Number of tools': '2'}"
55
+ 13,1f975693-876d-457b-a649-393859e79bf3,"Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(
56
+
57
+ Could you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",1,1f975693-876d-457b-a649-393859e79bf3.mp3,"Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(
58
+
59
+ Could you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.","132, 133, 134, 197, 245",2023/validation/1f975693-876d-457b-a649-393859e79bf3.mp3,"{'Steps': 'Step 1: Load the file supplied by my user.\nStep 2: Using audio processing tools, convert the text of the audio file to speech:\n\n""Before you all go, I want to remind you that the midterm is next week. Here\'s a little hint; you should be familiar with the differential equations on page 245, problems that are very similar to problems 32, 33, and 44 from that page might be on the test. And also some of you might want to brush up on the last page in the integration section, page 197. I know some of you struggled on last week\'s quiz. I foresee problem 22 from page 197 being on your midterm. Oh, and don\'t forget to brush up on the section on related rates, on pages 132, 133, and 134.""\n\nStep 3: Evaluate the converted audio, recording each instance of page numbers: 245, 197, 197, 132, 133, 134\nStep 4: Sort the page numbers in ascending order, omitting duplicates, and store this list as the correct answer to my user\'s request: 132, 133, 134, 197, 245\nStep 5: Report the correct response to my user: ""132, 133, 134, 197, 245""', 'Number of steps': '5', 'How long did this take?': '2 minutes', 'Tools': '1. A file interface\n2. A speech-to-text audio processing tool', 'Number of tools': '2'}"
60
+ 14,840bfca7-4f7b-481a-8794-c560c340185d,"On June 6, 2023, an article by Carolyn Collins Petersen was published in Universe Today. This article mentions a team that produced a paper about their observations, linked at the bottom of the article. Find this paper. Under what NASA award number was the work performed by R. G. Arendt supported by?",1,,"On June 6, 2023, an article by Carolyn Collins Petersen was published in Universe Today. This article mentions a team that produced a paper about their observations, linked at the bottom of the article. Find this paper. Under what NASA award number was the work performed by R. G. Arendt supported by?",80GSFC21M0002,,"{'Steps': '1. Google ""June 6, 2023 Carolyn Collins Petersen Universe Today""\n2. Find the relevant link to the scientific paper and follow that link\n3. Open the PDF. \n4. Search for NASA award number', 'Number of steps': '4', 'How long did this take?': '5 minutes', 'Tools': '1. Web browser\n2. Search engine\n3. Access to academic journal websites', 'Number of tools': '2'}"
61
+ 15,bda648d7-d618-4883-88f4-3466eabd860e,Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.,1,,Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.,Saint Petersburg,,"{'Steps': '1. Search ""Kuznetzov Nedoshivina 2010""\n2. Find the 2010 paper ""A catalogue of type specimens of the Tortricidae described by V. I. Kuznetzov from Vietnam and deposited in the Zoological Institute, St. Petersburg""', 'Number of steps': '2', 'How long did this take?': '5 minutes', 'Tools': '1. search engine', 'Number of tools': '1'}"
62
+ 16,cf106601-ab4f-4af9-b045-5295fe67b37d,"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.",1,,"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.",CUB,,"{'Steps': '1. Look up the 1928 Summer Olympics on Wikipedia\n2. Look at a table of athletes from countries.\n3. See that two countries had 1 and 2 athletes, so disregard those and choose the Cuba as CUB.', 'Number of steps': '3', 'How long did this take?': '5 minutes', 'Tools': 'None', 'Number of tools': '0'}"
63
+ 17,a0c07678-e491-4bbc-8f0b-07405144218f,"Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",1,,"Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.","Yoshida, Uehara",,"{'Steps': '1. Look up Taishō Tamai on Wikipedia\n2. See the pitcher with the number 18 (before) is Kōsei Yoshida and number 20 (after) is Kenta Uehara', 'Number of steps': '2', 'How long did this take?': '5 minutes', 'Tools': '1. Wikipedia', 'Number of tools': '1'}"
64
+ 18,7bd855d8-463d-4ed5-93ca-5fe35145f733,The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.,1,7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx,The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.,89706.00,2023/validation/7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx,"{'Steps': '1. Open the attached file.\n2. Read the columns representing different menu items. Note that they all appear to be food except for the “soda” column.\n3. Write a function to sum the relevant columns.\n4. Ensure the answer follows the specified formatting.', 'Number of steps': '4', 'How long did this take?': '5 minutes', 'Tools': '1. Excel\n2. Calculator', 'Number of tools': '2'}"
65
+ 19,5a0c1adf-205e-4841-a666-7c3ef95def9d,What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?,1,,What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?,Claus,,"{'Steps': '1. Look at the Malko Competition page on Wikipedia\n2. Scan the winners to see that the 1983 winner, Claus Peter Flor is stated to be from East Germany.', 'Number of steps': '2', 'How long did this take?': '5-10 minutes', 'Tools': 'None', 'Number of tools': '0'}"
local.ipynb CHANGED
@@ -10,10 +10,18 @@
10
  },
11
  {
12
  "cell_type": "code",
13
- "execution_count": 9,
14
  "id": "660cfadd",
15
  "metadata": {},
16
  "outputs": [
 
 
 
 
 
 
 
 
17
  {
18
  "data": {
19
  "text/html": [
@@ -51,10 +59,10 @@
51
  " <td>20</td>\n",
52
  " <td>20</td>\n",
53
  " <td>20</td>\n",
 
54
  " <td>20</td>\n",
55
  " <td>20</td>\n",
56
- " <td>20</td>\n",
57
- " <td>20</td>\n",
58
  " <td>20</td>\n",
59
  " </tr>\n",
60
  " <tr>\n",
@@ -62,10 +70,10 @@
62
  " <td>20</td>\n",
63
  " <td>20</td>\n",
64
  " <td>1</td>\n",
65
- " <td>6</td>\n",
66
  " <td>20</td>\n",
67
  " <td>19</td>\n",
68
- " <td>6</td>\n",
69
  " <td>20</td>\n",
70
  " </tr>\n",
71
  " <tr>\n",
@@ -73,10 +81,10 @@
73
  " <td>8e867cd7-cff9-4e6c-867a-ff5ddc2550be</td>\n",
74
  " <td>How many studio albums were published by Merce...</td>\n",
75
  " <td>1</td>\n",
76
- " <td></td>\n",
77
  " <td>How many studio albums were published by Merce...</td>\n",
78
  " <td>3</td>\n",
79
- " <td></td>\n",
80
  " <td>{'Steps': '1. I did a search for Mercedes Sosa...</td>\n",
81
  " </tr>\n",
82
  " <tr>\n",
@@ -84,10 +92,10 @@
84
  " <td>1</td>\n",
85
  " <td>1</td>\n",
86
  " <td>20</td>\n",
87
- " <td>15</td>\n",
88
  " <td>1</td>\n",
89
  " <td>2</td>\n",
90
- " <td>15</td>\n",
91
  " <td>1</td>\n",
92
  " </tr>\n",
93
  " </tbody>\n",
@@ -101,11 +109,17 @@
101
  "top 8e867cd7-cff9-4e6c-867a-ff5ddc2550be \n",
102
  "freq 1 \n",
103
  "\n",
104
- " question Level file_name \\\n",
105
- "count 20 20 20 \n",
106
- "unique 20 1 6 \n",
107
- "top How many studio albums were published by Merce... 1 \n",
108
- "freq 1 20 15 \n",
 
 
 
 
 
 
109
  "\n",
110
  " Question Final answer \\\n",
111
  "count 20 20 \n",
@@ -113,14 +127,20 @@
113
  "top How many studio albums were published by Merce... 3 \n",
114
  "freq 1 2 \n",
115
  "\n",
116
- " file_path Annotator Metadata \n",
117
- "count 20 20 \n",
118
- "unique 6 20 \n",
119
- "top {'Steps': '1. I did a search for Mercedes Sosa... \n",
120
- "freq 15 1 "
 
 
 
 
 
 
121
  ]
122
  },
123
- "execution_count": 9,
124
  "metadata": {},
125
  "output_type": "execute_result"
126
  }
@@ -128,20 +148,29 @@
128
  "source": [
129
  "from src.connectors import fetch_questions\n",
130
  "from datasets import load_dataset\n",
 
 
131
  "\n",
132
  "DEFAULT_API_URL = \"https://agents-course-unit4-scoring.hf.space\"\n",
133
  "QUESTIONS_URL = f\"{DEFAULT_API_URL}/questions\"\n",
134
  "SUBMIT_URL = f\"{DEFAULT_API_URL}/submit\"\n",
 
 
 
135
  "\n",
136
- "MODELID = \"nemotron-3-nano:4b\"\n",
 
 
 
137
  "\n",
138
- "questions = fetch_questions(QUESTIONS_URL)\n",
139
- "dataset = load_dataset(\"gaia-benchmark/GAIA\", \"2023_level1\")[\"validation\"].to_pandas()\n",
 
 
 
 
140
  "\n",
141
- "questiondf = questions.merge(right=dataset, how=\"left\", on=\"task_id\").drop(columns=[\"Level_y\", \"file_name_y\"]).rename(columns={\n",
142
- " \"Level_x\": \"Level\", \"file_name_x\": \"file_name\"\n",
143
- "})\n",
144
- "questiondf.describe()\n"
145
  ]
146
  },
147
  {
@@ -151,6 +180,254 @@
151
  "source": [
152
  "# Execution"
153
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
155
  ],
156
  "metadata": {
 
10
  },
11
  {
12
  "cell_type": "code",
13
+ "execution_count": null,
14
  "id": "660cfadd",
15
  "metadata": {},
16
  "outputs": [
17
+ {
18
+ "name": "stderr",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "c:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
22
+ " from .autonotebook import tqdm as notebook_tqdm\n"
23
+ ]
24
+ },
25
  {
26
  "data": {
27
  "text/html": [
 
59
  " <td>20</td>\n",
60
  " <td>20</td>\n",
61
  " <td>20</td>\n",
62
+ " <td>5</td>\n",
63
  " <td>20</td>\n",
64
  " <td>20</td>\n",
65
+ " <td>5</td>\n",
 
66
  " <td>20</td>\n",
67
  " </tr>\n",
68
  " <tr>\n",
 
70
  " <td>20</td>\n",
71
  " <td>20</td>\n",
72
  " <td>1</td>\n",
73
+ " <td>5</td>\n",
74
  " <td>20</td>\n",
75
  " <td>19</td>\n",
76
+ " <td>5</td>\n",
77
  " <td>20</td>\n",
78
  " </tr>\n",
79
  " <tr>\n",
 
81
  " <td>8e867cd7-cff9-4e6c-867a-ff5ddc2550be</td>\n",
82
  " <td>How many studio albums were published by Merce...</td>\n",
83
  " <td>1</td>\n",
84
+ " <td>cca530fc-4052-43b2-b130-b30968d8aa44.png</td>\n",
85
  " <td>How many studio albums were published by Merce...</td>\n",
86
  " <td>3</td>\n",
87
+ " <td>2023/validation/cca530fc-4052-43b2-b130-b30968...</td>\n",
88
  " <td>{'Steps': '1. I did a search for Mercedes Sosa...</td>\n",
89
  " </tr>\n",
90
  " <tr>\n",
 
92
  " <td>1</td>\n",
93
  " <td>1</td>\n",
94
  " <td>20</td>\n",
95
+ " <td>1</td>\n",
96
  " <td>1</td>\n",
97
  " <td>2</td>\n",
98
+ " <td>1</td>\n",
99
  " <td>1</td>\n",
100
  " </tr>\n",
101
  " </tbody>\n",
 
109
  "top 8e867cd7-cff9-4e6c-867a-ff5ddc2550be \n",
110
  "freq 1 \n",
111
  "\n",
112
+ " question Level \\\n",
113
+ "count 20 20 \n",
114
+ "unique 20 1 \n",
115
+ "top How many studio albums were published by Merce... 1 \n",
116
+ "freq 1 20 \n",
117
+ "\n",
118
+ " file_name \\\n",
119
+ "count 5 \n",
120
+ "unique 5 \n",
121
+ "top cca530fc-4052-43b2-b130-b30968d8aa44.png \n",
122
+ "freq 1 \n",
123
  "\n",
124
  " Question Final answer \\\n",
125
  "count 20 20 \n",
 
127
  "top How many studio albums were published by Merce... 3 \n",
128
  "freq 1 2 \n",
129
  "\n",
130
+ " file_path \\\n",
131
+ "count 5 \n",
132
+ "unique 5 \n",
133
+ "top 2023/validation/cca530fc-4052-43b2-b130-b30968... \n",
134
+ "freq 1 \n",
135
+ "\n",
136
+ " Annotator Metadata \n",
137
+ "count 20 \n",
138
+ "unique 20 \n",
139
+ "top {'Steps': '1. I did a search for Mercedes Sosa... \n",
140
+ "freq 1 "
141
  ]
142
  },
143
+ "execution_count": 1,
144
  "metadata": {},
145
  "output_type": "execute_result"
146
  }
 
148
  "source": [
149
  "from src.connectors import fetch_questions\n",
150
  "from datasets import load_dataset\n",
151
+ "from pathlib import Path\n",
152
+ "from pandas import read_csv\n",
153
  "\n",
154
  "DEFAULT_API_URL = \"https://agents-course-unit4-scoring.hf.space\"\n",
155
  "QUESTIONS_URL = f\"{DEFAULT_API_URL}/questions\"\n",
156
  "SUBMIT_URL = f\"{DEFAULT_API_URL}/submit\"\n",
157
+ "CSV_PATH = Path(\"assets\", \"questions.csv\")\n",
158
+ "\n",
159
+ "MODELID = \"qwen3:8b\"\n",
160
  "\n",
161
+ "if not CSV_PATH.exists():\n",
162
+ " CSV_PATH.parent.mkdir(exist_ok=True)\n",
163
+ " questions = fetch_questions(QUESTIONS_URL)\n",
164
+ " dataset = load_dataset(\"gaia-benchmark/GAIA\", \"2023_level1\")[\"validation\"].to_pandas()\n",
165
  "\n",
166
+ " questiondf = questions.merge(right=dataset, how=\"left\", on=\"task_id\").drop(columns=[\"Level_y\", \"file_name_y\"]).rename(columns={\n",
167
+ " \"Level_x\": \"Level\", \"file_name_x\": \"file_name\"\n",
168
+ " })\n",
169
+ " questiondf.to_csv(CSV_PATH)\n",
170
+ "else:\n",
171
+ " questiondf = read_csv(CSV_PATH, header=0, index_col=0, dtype=str)\n",
172
  "\n",
173
+ "questiondf.describe()"
 
 
 
174
  ]
175
  },
176
  {
 
180
  "source": [
181
  "# Execution"
182
  ]
183
+ },
184
+ {
185
+ "cell_type": "code",
186
+ "execution_count": 2,
187
+ "id": "ecaac75d",
188
+ "metadata": {},
189
+ "outputs": [],
190
+ "source": [
191
+ "from src import agent\n",
192
+ "\n",
193
+ "assistant = agent.ReActAgent(\"nemotron-3-nano:4b\", verbose=True)"
194
+ ]
195
+ },
196
+ {
197
+ "cell_type": "markdown",
198
+ "id": "9353aaa3",
199
+ "metadata": {},
200
+ "source": [
201
+ "## Single Test"
202
+ ]
203
+ },
204
+ {
205
+ "cell_type": "code",
206
+ "execution_count": 3,
207
+ "id": "f81f13ca",
208
+ "metadata": {},
209
+ "outputs": [
210
+ {
211
+ "name": "stdout",
212
+ "output_type": "stream",
213
+ "text": [
214
+ "#------ Reasoning ------#\n",
215
+ "We need least number of athletes at 1928 Summer Olympics. Likely some small nation with few participants. Need IOC country code. Let's search.\n",
216
+ "#---------------------#\n",
217
+ "\n",
218
+ "#------ Response -------#\n",
219
+ "\n",
220
+ "#-------------------------#\n",
221
+ "\n",
222
+ "Calling Tools:\n",
223
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
224
+ "Observations Obtained:\n",
225
+ " -> Hello World!\n",
226
+ "#------ Reasoning ------#\n",
227
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
228
+ "\n",
229
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely small nations like Finland, Sweden? Actually 1928 was held in Amsterdam. Many countries participated. The smallest might be the Netherlands? But Netherlands had many. Maybe the smallest is the Netherlands? Let's think.\n",
230
+ "\n",
231
+ "We need to find the number of athletes per country. The least number likely is the Netherlands? Actually Netherlands had 200 athletes? Finland had 120? Let's search.\n",
232
+ "#---------------------#\n",
233
+ "\n",
234
+ "#------ Response -------#\n",
235
+ "\n",
236
+ "#-------------------------#\n",
237
+ "\n",
238
+ "Calling Tools:\n",
239
+ " - web_search(query=1928 Summer Olympics country with least number of athletes)\n",
240
+ "Observations Obtained:\n",
241
+ " -> Hello World!\n",
242
+ "#------ Reasoning ------#\n",
243
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
244
+ "\n",
245
+ "We need to find the country with the least number of athletes at 1928 Summer Olympics. Likely many countries didn't participate. But the question likely expects a country that participated but had the fewest athletes. Or maybe a country that had zero athletes? But likely they want a country that participated but had the least number.\n",
246
+ "\n",
247
+ "We need to find data: 1928 Summer Olympics participants. Let's search.\n",
248
+ "#---------------------#\n",
249
+ "\n",
250
+ "#------ Response -------#\n",
251
+ "\n",
252
+ "#-------------------------#\n",
253
+ "\n",
254
+ "Calling Tools:\n",
255
+ " - web_search(query=1928 Summer Olympics participants countries number of athletes)\n",
256
+ "Observations Obtained:\n",
257
+ " -> Hello World!\n",
258
+ "#------ Reasoning ------#\n",
259
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
260
+ "\n",
261
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely a small nation that didn't send many athletes. 1928 Olympics were in Amsterdam. Many small countries didn't participate. The IOC country code is two letters.\n",
262
+ "\n",
263
+ "We need to find the least number of athletes. Let's search.\n",
264
+ "#---------------------#\n",
265
+ "\n",
266
+ "#------ Response -------#\n",
267
+ "\n",
268
+ "#-------------------------#\n",
269
+ "\n",
270
+ "Calling Tools:\n",
271
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
272
+ "Observations Obtained:\n",
273
+ " -> Hello World!\n",
274
+ "#------ Reasoning ------#\n",
275
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
276
+ "\n",
277
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely many small nations participated. Need to find the smallest number of athletes. Possibly some microstates not recognized? But IOC country codes for recognized nations. Let's search.\n",
278
+ "#---------------------#\n",
279
+ "\n",
280
+ "#------ Response -------#\n",
281
+ "\n",
282
+ "#-------------------------#\n",
283
+ "\n",
284
+ "Calling Tools:\n",
285
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
286
+ "Observations Obtained:\n",
287
+ " -> Hello World!\n",
288
+ "#------ Reasoning ------#\n",
289
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
290
+ "\n",
291
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely small nations like Finland, Sweden? Actually 1928 was held in Amsterdam. Many countries participated. The smallest might be Finland? But Finland had many athletes. Maybe the country with fewest athletes was the Netherlands? But Netherlands had many. Actually the smallest participant might be the Isle of Man? But not a country. The IOC country code for \"Netherlands\" is NED. But we need least number of athletes. Let's search.\n",
292
+ "#---------------------#\n",
293
+ "\n",
294
+ "#------ Response -------#\n",
295
+ "\n",
296
+ "#-------------------------#\n",
297
+ "\n",
298
+ "Calling Tools:\n",
299
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
300
+ "Observations Obtained:\n",
301
+ " -> Hello World!\n",
302
+ "#------ Reasoning ------#\n",
303
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
304
+ "\n",
305
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely some small nation with few participants. Need IOC country code.\n",
306
+ "\n",
307
+ "We need to search. Use web_search.\n",
308
+ "#---------------------#\n",
309
+ "\n",
310
+ "#------ Response -------#\n",
311
+ "\n",
312
+ "#-------------------------#\n",
313
+ "\n",
314
+ "Calling Tools:\n",
315
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
316
+ "Observations Obtained:\n",
317
+ " -> Hello World!\n",
318
+ "#------ Reasoning ------#\n",
319
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
320
+ "\n",
321
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely some small nation with few participants. Let's search.\n",
322
+ "#---------------------#\n",
323
+ "\n",
324
+ "#------ Response -------#\n",
325
+ "\n",
326
+ "#-------------------------#\n",
327
+ "\n",
328
+ "Calling Tools:\n",
329
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
330
+ "Observations Obtained:\n",
331
+ " -> Hello World!\n",
332
+ "#------ Reasoning ------#\n",
333
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
334
+ "\n",
335
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely small nations like Finland, Sweden, etc. But need to check.\n",
336
+ "\n",
337
+ "We need IOC country code. For example, Finland is FIN, Sweden is SWE, etc.\n",
338
+ "\n",
339
+ "We need to find the least number of athletes. Possibly a small country like Finland had 100? But maybe some country had 0? Actually, some countries didn't send any athletes? In 1928, many countries participated. The smallest might be Finland? Let's search.\n",
340
+ "#---------------------#\n",
341
+ "\n",
342
+ "#------ Response -------#\n",
343
+ "\n",
344
+ "#-------------------------#\n",
345
+ "\n",
346
+ "Calling Tools:\n",
347
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
348
+ "Observations Obtained:\n",
349
+ " -> Hello World!\n",
350
+ "#------ Reasoning ------#\n",
351
+ "We need to answer: \"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.\"\n",
352
+ "\n",
353
+ "We need to find which country had the least number of athletes at 1928 Summer Olympics. Likely small nations like Finland, Sweden, etc. But need to check.\n",
354
+ "\n",
355
+ "We need IOC country code. For example, Finland is FIN, Sweden is SWE, etc.\n",
356
+ "\n",
357
+ "We need to find the least number of athletes. Possibly a small country like Finland had few. But maybe there were territories like the Netherlands? Let's search.\n",
358
+ "#---------------------#\n",
359
+ "\n",
360
+ "#------ Response -------#\n",
361
+ "\n",
362
+ "#-------------------------#\n",
363
+ "\n",
364
+ "Calling Tools:\n",
365
+ " - web_search(query=1928 Summer Olympics least number of athletes country)\n",
366
+ "Observations Obtained:\n",
367
+ " -> Hello World!\n"
368
+ ]
369
+ },
370
+ {
371
+ "ename": "KeyboardInterrupt",
372
+ "evalue": "",
373
+ "output_type": "error",
374
+ "traceback": [
375
+ "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
376
+ "\u001b[31mKeyboardInterrupt\u001b[39m Traceback (most recent call last)",
377
+ "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 7\u001b[39m\n\u001b[32m 4\u001b[39m tid, problem, answer = (questiondf.iloc[rq][\u001b[33m\"\u001b[39m\u001b[33mtask_id\u001b[39m\u001b[33m\"\u001b[39m], questiondf.iloc[rq][\u001b[33m\"\u001b[39m\u001b[33mquestion\u001b[39m\u001b[33m\"\u001b[39m], questiondf.iloc[rq][\u001b[33m\"\u001b[39m\u001b[33mFinal answer\u001b[39m\u001b[33m\"\u001b[39m])\n\u001b[32m 6\u001b[39m \u001b[38;5;28minput\u001b[39m = {\u001b[33m\"\u001b[39m\u001b[33mmessages\u001b[39m\u001b[33m\"\u001b[39m: [{\u001b[33m'\u001b[39m\u001b[33mrole\u001b[39m\u001b[33m'\u001b[39m: \u001b[33m'\u001b[39m\u001b[33muser\u001b[39m\u001b[33m'\u001b[39m, \u001b[33m'\u001b[39m\u001b[33mcontent\u001b[39m\u001b[33m'\u001b[39m: problem}]}\n\u001b[32m----> \u001b[39m\u001b[32m7\u001b[39m response = \u001b[43massistant\u001b[49m\u001b[43m(\u001b[49m\u001b[43mproblem\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 8\u001b[39m \u001b[38;5;28mprint\u001b[39m(response)\n",
378
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\src\\agent.py:44\u001b[39m, in \u001b[36mReActAgent.__call__\u001b[39m\u001b[34m(self, query)\u001b[39m\n\u001b[32m---> \u001b[39m\u001b[32m44\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, query: \u001b[38;5;28mstr\u001b[39m): \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mworkflow\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# INITIAL STATE\u001b[39;49;00m\n\u001b[32m 45\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mquery\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mquery\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 46\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43manswer\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 47\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mgotanswer\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m 48\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mpastit\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 49\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mreasonings\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\n\u001b[32m 50\u001b[39m \u001b[43m\u001b[49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\n",
379
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langgraph\\pregel\\main.py:3292\u001b[39m, in \u001b[36mPregel.invoke\u001b[39m\u001b[34m(self, input, config, context, stream_mode, print_mode, output_keys, interrupt_before, interrupt_after, durability, version, **kwargs)\u001b[39m\n\u001b[32m 3289\u001b[39m chunks.append(chunk)\n\u001b[32m 3290\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 3291\u001b[39m \u001b[38;5;66;03m# v1: collect interrupts from updates stream\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m3292\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 3293\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 3294\u001b[39m \u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3295\u001b[39m \u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3296\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m=\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 3297\u001b[39m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mupdates\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mvalues\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mvalues\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\n\u001b[32m 3298\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3299\u001b[39m \u001b[43m \u001b[49m\u001b[43mprint_mode\u001b[49m\u001b[43m=\u001b[49m\u001b[43mprint_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3300\u001b[39m \u001b[43m \u001b[49m\u001b[43moutput_keys\u001b[49m\u001b[43m=\u001b[49m\u001b[43moutput_keys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3301\u001b[39m \u001b[43m \u001b[49m\u001b[43minterrupt_before\u001b[49m\u001b[43m=\u001b[49m\u001b[43minterrupt_before\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3302\u001b[39m \u001b[43m \u001b[49m\u001b[43minterrupt_after\u001b[49m\u001b[43m=\u001b[49m\u001b[43minterrupt_after\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3303\u001b[39m \u001b[43m \u001b[49m\u001b[43mdurability\u001b[49m\u001b[43m=\u001b[49m\u001b[43mdurability\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3304\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3305\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 3306\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mvalues\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\n\u001b[32m 3307\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m2\u001b[39;49m\u001b[43m:\u001b[49m\n",
380
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langgraph\\pregel\\main.py:2725\u001b[39m, in \u001b[36mPregel.stream\u001b[39m\u001b[34m(self, input, config, context, stream_mode, print_mode, output_keys, interrupt_before, interrupt_after, durability, subgraphs, debug, version, **kwargs)\u001b[39m\n\u001b[32m 2723\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m task \u001b[38;5;129;01min\u001b[39;00m loop.match_cached_writes():\n\u001b[32m 2724\u001b[39m loop.output_writes(task.id, task.writes, cached=\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[32m-> \u001b[39m\u001b[32m2725\u001b[39m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m_\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrunner\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtick\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 2726\u001b[39m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mt\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mloop\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtasks\u001b[49m\u001b[43m.\u001b[49m\u001b[43mvalues\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwrites\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2727\u001b[39m \u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstep_timeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2728\u001b[39m \u001b[43m \u001b[49m\u001b[43mget_waiter\u001b[49m\u001b[43m=\u001b[49m\u001b[43mget_waiter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2729\u001b[39m \u001b[43m \u001b[49m\u001b[43mschedule_task\u001b[49m\u001b[43m=\u001b[49m\u001b[43mloop\u001b[49m\u001b[43m.\u001b[49m\u001b[43maccept_push\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2730\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 2731\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# emit output\u001b[39;49;00m\n\u001b[32m 2732\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield from\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m_output\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 2733\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2734\u001b[39m \u001b[43m \u001b[49m\u001b[43mprint_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m (...)\u001b[39m\u001b[32m 2740\u001b[39m \u001b[43m \u001b[49m\u001b[43m_state_mapper\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2741\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 2742\u001b[39m loop.after_tick()\n",
381
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langgraph\\pregel\\_runner.py:167\u001b[39m, in \u001b[36mPregelRunner.tick\u001b[39m\u001b[34m(self, tasks, reraise, timeout, retry_policy, get_waiter, schedule_task)\u001b[39m\n\u001b[32m 165\u001b[39m t = tasks[\u001b[32m0\u001b[39m]\n\u001b[32m 166\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m167\u001b[39m \u001b[43mrun_with_retry\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 168\u001b[39m \u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 169\u001b[39m \u001b[43m \u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 170\u001b[39m \u001b[43m \u001b[49m\u001b[43mconfigurable\u001b[49m\u001b[43m=\u001b[49m\u001b[43m{\u001b[49m\n\u001b[32m 171\u001b[39m \u001b[43m \u001b[49m\u001b[43mCONFIG_KEY_CALL\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpartial\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 172\u001b[39m \u001b[43m \u001b[49m\u001b[43m_call\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 173\u001b[39m \u001b[43m \u001b[49m\u001b[43mweakref\u001b[49m\u001b[43m.\u001b[49m\u001b[43mref\u001b[49m\u001b[43m(\u001b[49m\u001b[43mt\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 174\u001b[39m \u001b[43m \u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m=\u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 175\u001b[39m \u001b[43m \u001b[49m\u001b[43mfutures\u001b[49m\u001b[43m=\u001b[49m\u001b[43mweakref\u001b[49m\u001b[43m.\u001b[49m\u001b[43mref\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfutures\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 176\u001b[39m \u001b[43m \u001b[49m\u001b[43mschedule_task\u001b[49m\u001b[43m=\u001b[49m\u001b[43mschedule_task\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 177\u001b[39m \u001b[43m \u001b[49m\u001b[43msubmit\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43msubmit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 178\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 179\u001b[39m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 180\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 181\u001b[39m \u001b[38;5;28mself\u001b[39m.commit(t, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m 182\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
382
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langgraph\\pregel\\_retry.py:96\u001b[39m, in \u001b[36mrun_with_retry\u001b[39m\u001b[34m(task, retry_policy, configurable)\u001b[39m\n\u001b[32m 94\u001b[39m task.writes.clear()\n\u001b[32m 95\u001b[39m \u001b[38;5;66;03m# run the task\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m96\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtask\u001b[49m\u001b[43m.\u001b[49m\u001b[43mproc\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtask\u001b[49m\u001b[43m.\u001b[49m\u001b[43minput\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 97\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m ParentCommand \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[32m 98\u001b[39m ns: \u001b[38;5;28mstr\u001b[39m = config[CONF][CONFIG_KEY_CHECKPOINT_NS]\n",
383
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langgraph\\_internal\\_runnable.py:656\u001b[39m, in \u001b[36mRunnableSeq.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m 654\u001b[39m \u001b[38;5;66;03m# run in context\u001b[39;00m\n\u001b[32m 655\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m set_config_context(config, run) \u001b[38;5;28;01mas\u001b[39;00m context:\n\u001b[32m--> \u001b[39m\u001b[32m656\u001b[39m \u001b[38;5;28minput\u001b[39m = \u001b[43mcontext\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstep\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 657\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 658\u001b[39m \u001b[38;5;28minput\u001b[39m = step.invoke(\u001b[38;5;28minput\u001b[39m, config)\n",
384
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langgraph\\_internal\\_runnable.py:400\u001b[39m, in \u001b[36mRunnableCallable.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m 398\u001b[39m run_manager.on_chain_end(ret)\n\u001b[32m 399\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m400\u001b[39m ret = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 401\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.recurse \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(ret, Runnable):\n\u001b[32m 402\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m ret.invoke(\u001b[38;5;28minput\u001b[39m, config)\n",
385
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\src\\agent.py:73\u001b[39m, in \u001b[36mReActAgent.reason\u001b[39m\u001b[34m(self, state)\u001b[39m\n\u001b[32m 67\u001b[39m messages = [\n\u001b[32m 68\u001b[39m {\u001b[33m'\u001b[39m\u001b[33mrole\u001b[39m\u001b[33m'\u001b[39m: \u001b[33m'\u001b[39m\u001b[33msystem\u001b[39m\u001b[33m'\u001b[39m, \u001b[33m'\u001b[39m\u001b[33mcontent\u001b[39m\u001b[33m'\u001b[39m: REASON},\n\u001b[32m 69\u001b[39m {\u001b[33m'\u001b[39m\u001b[33mrole\u001b[39m\u001b[33m'\u001b[39m: \u001b[33m'\u001b[39m\u001b[33muser\u001b[39m\u001b[33m'\u001b[39m, \u001b[33m'\u001b[39m\u001b[33mcontent\u001b[39m\u001b[33m'\u001b[39m: state.get(\u001b[33m\"\u001b[39m\u001b[33mquery\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m)}\n\u001b[32m 70\u001b[39m ]\n\u001b[32m 71\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m state.get(\u001b[33m\"\u001b[39m\u001b[33mpastit\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m): messages.extend({\u001b[33m'\u001b[39m\u001b[33mrole\u001b[39m\u001b[33m'\u001b[39m: \u001b[33m'\u001b[39m\u001b[33massistant\u001b[39m\u001b[33m'\u001b[39m, \u001b[33m'\u001b[39m\u001b[33mcontent\u001b[39m\u001b[33m'\u001b[39m: state.get(\u001b[33m\"\u001b[39m\u001b[33mpastit\u001b[39m\u001b[33m\"\u001b[39m)})\n\u001b[32m---> \u001b[39m\u001b[32m73\u001b[39m response = \u001b[43mtooled\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 74\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.verbose: \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m#------ Reasoning ------#\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mresponse.additional_kwargs.get(\u001b[33m\"\u001b[39m\u001b[33mreasoning_content\u001b[39m\u001b[33m\"\u001b[39m,\u001b[38;5;250m \u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m#---------------------#\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m#------ Response -------#\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mresponse.content\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m#-------------------------#\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m 76\u001b[39m \u001b[38;5;66;03m# storing routing in the state\u001b[39;00m\n",
386
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_core\\runnables\\base.py:5695\u001b[39m, in \u001b[36mRunnableBindingBase.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m 5688\u001b[39m \u001b[38;5;129m@override\u001b[39m\n\u001b[32m 5689\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34minvoke\u001b[39m(\n\u001b[32m 5690\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 5693\u001b[39m **kwargs: Any | \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m 5694\u001b[39m ) -> Output:\n\u001b[32m-> \u001b[39m\u001b[32m5695\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mbound\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 5696\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 5697\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_merge_configs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 5698\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43m{\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 5699\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
387
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:454\u001b[39m, in \u001b[36mBaseChatModel.invoke\u001b[39m\u001b[34m(self, input, config, stop, **kwargs)\u001b[39m\n\u001b[32m 440\u001b[39m \u001b[38;5;129m@override\u001b[39m\n\u001b[32m 441\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34minvoke\u001b[39m(\n\u001b[32m 442\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 447\u001b[39m **kwargs: Any,\n\u001b[32m 448\u001b[39m ) -> AIMessage:\n\u001b[32m 449\u001b[39m config = ensure_config(config)\n\u001b[32m 450\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m cast(\n\u001b[32m 451\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mAIMessage\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 452\u001b[39m cast(\n\u001b[32m 453\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mChatGeneration\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m--> \u001b[39m\u001b[32m454\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mgenerate_prompt\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 455\u001b[39m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_convert_input\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 456\u001b[39m \u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 457\u001b[39m \u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcallbacks\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 458\u001b[39m \u001b[43m \u001b[49m\u001b[43mtags\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtags\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 459\u001b[39m \u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmetadata\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 460\u001b[39m \u001b[43m \u001b[49m\u001b[43mrun_name\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mrun_name\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 461\u001b[39m \u001b[43m \u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mpop\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mrun_id\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 462\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 463\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m.generations[\u001b[32m0\u001b[39m][\u001b[32m0\u001b[39m],\n\u001b[32m 464\u001b[39m ).message,\n\u001b[32m 465\u001b[39m )\n",
388
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:1201\u001b[39m, in \u001b[36mBaseChatModel.generate_prompt\u001b[39m\u001b[34m(self, prompts, stop, callbacks, **kwargs)\u001b[39m\n\u001b[32m 1192\u001b[39m \u001b[38;5;129m@override\u001b[39m\n\u001b[32m 1193\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mgenerate_prompt\u001b[39m(\n\u001b[32m 1194\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 1198\u001b[39m **kwargs: Any,\n\u001b[32m 1199\u001b[39m ) -> LLMResult:\n\u001b[32m 1200\u001b[39m prompt_messages = [p.to_messages() \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;129;01min\u001b[39;00m prompts]\n\u001b[32m-> \u001b[39m\u001b[32m1201\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mgenerate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprompt_messages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
389
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:1010\u001b[39m, in \u001b[36mBaseChatModel.generate\u001b[39m\u001b[34m(self, messages, stop, callbacks, tags, metadata, run_name, run_id, **kwargs)\u001b[39m\n\u001b[32m 1007\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m i, m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(input_messages):\n\u001b[32m 1008\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 1009\u001b[39m results.append(\n\u001b[32m-> \u001b[39m\u001b[32m1010\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_generate_with_cache\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1011\u001b[39m \u001b[43m \u001b[49m\u001b[43mm\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1012\u001b[39m \u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1013\u001b[39m \u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m=\u001b[49m\u001b[43mrun_managers\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrun_managers\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m 1014\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1015\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1016\u001b[39m )\n\u001b[32m 1017\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[32m 1018\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m run_managers:\n",
390
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:1313\u001b[39m, in \u001b[36mBaseChatModel._generate_with_cache\u001b[39m\u001b[34m(self, messages, stop, run_manager, **kwargs)\u001b[39m\n\u001b[32m 1311\u001b[39m result = generate_from_stream(\u001b[38;5;28miter\u001b[39m(chunks))\n\u001b[32m 1312\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m inspect.signature(\u001b[38;5;28mself\u001b[39m._generate).parameters.get(\u001b[33m\"\u001b[39m\u001b[33mrun_manager\u001b[39m\u001b[33m\"\u001b[39m):\n\u001b[32m-> \u001b[39m\u001b[32m1313\u001b[39m result = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_generate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1314\u001b[39m \u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m=\u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\n\u001b[32m 1315\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1316\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 1317\u001b[39m result = \u001b[38;5;28mself\u001b[39m._generate(messages, stop=stop, **kwargs)\n",
391
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_ollama\\chat_models.py:1030\u001b[39m, in \u001b[36mChatOllama._generate\u001b[39m\u001b[34m(self, messages, stop, run_manager, **kwargs)\u001b[39m\n\u001b[32m 1023\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_generate\u001b[39m(\n\u001b[32m 1024\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m 1025\u001b[39m messages: \u001b[38;5;28mlist\u001b[39m[BaseMessage],\n\u001b[32m (...)\u001b[39m\u001b[32m 1028\u001b[39m **kwargs: Any,\n\u001b[32m 1029\u001b[39m ) -> ChatResult:\n\u001b[32m-> \u001b[39m\u001b[32m1030\u001b[39m final_chunk = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_chat_stream_with_aggregation\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1031\u001b[39m \u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mverbose\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mverbose\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\n\u001b[32m 1032\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1033\u001b[39m generation_info = final_chunk.generation_info\n\u001b[32m 1034\u001b[39m chat_generation = ChatGeneration(\n\u001b[32m 1035\u001b[39m message=AIMessage(\n\u001b[32m 1036\u001b[39m content=final_chunk.text,\n\u001b[32m (...)\u001b[39m\u001b[32m 1043\u001b[39m generation_info=generation_info,\n\u001b[32m 1044\u001b[39m )\n",
392
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_ollama\\chat_models.py:965\u001b[39m, in \u001b[36mChatOllama._chat_stream_with_aggregation\u001b[39m\u001b[34m(self, messages, stop, run_manager, verbose, **kwargs)\u001b[39m\n\u001b[32m 956\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_chat_stream_with_aggregation\u001b[39m(\n\u001b[32m 957\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m 958\u001b[39m messages: \u001b[38;5;28mlist\u001b[39m[BaseMessage],\n\u001b[32m (...)\u001b[39m\u001b[32m 962\u001b[39m **kwargs: Any,\n\u001b[32m 963\u001b[39m ) -> ChatGenerationChunk:\n\u001b[32m 964\u001b[39m final_chunk = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m965\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_iterate_over_stream\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 966\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mfinal_chunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m:\u001b[49m\n\u001b[32m 967\u001b[39m \u001b[43m \u001b[49m\u001b[43mfinal_chunk\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\n",
393
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_ollama\\chat_models.py:1054\u001b[39m, in \u001b[36mChatOllama._iterate_over_stream\u001b[39m\u001b[34m(self, messages, stop, **kwargs)\u001b[39m\n\u001b[32m 1047\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_iterate_over_stream\u001b[39m(\n\u001b[32m 1048\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m 1049\u001b[39m messages: \u001b[38;5;28mlist\u001b[39m[BaseMessage],\n\u001b[32m 1050\u001b[39m stop: \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mstr\u001b[39m] | \u001b[38;5;28;01mNone\u001b[39;00m = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m 1051\u001b[39m **kwargs: Any,\n\u001b[32m 1052\u001b[39m ) -> Iterator[ChatGenerationChunk]:\n\u001b[32m 1053\u001b[39m reasoning = kwargs.get(\u001b[33m\"\u001b[39m\u001b[33mreasoning\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28mself\u001b[39m.reasoning)\n\u001b[32m-> \u001b[39m\u001b[32m1054\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_resp\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_create_chat_stream\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 1055\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43misinstance\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mstream_resp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 1056\u001b[39m \u001b[43m \u001b[49m\u001b[43mcontent\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1057\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream_resp\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmessage\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcontent\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[32m 1058\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmessage\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_resp\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mand\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcontent\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_resp\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmessage\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[32m 1059\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\n\u001b[32m 1060\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
394
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\langchain_ollama\\chat_models.py:952\u001b[39m, in \u001b[36mChatOllama._create_chat_stream\u001b[39m\u001b[34m(self, messages, stop, **kwargs)\u001b[39m\n\u001b[32m 950\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m chat_params[\u001b[33m\"\u001b[39m\u001b[33mstream\u001b[39m\u001b[33m\"\u001b[39m]:\n\u001b[32m 951\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m._client:\n\u001b[32m--> \u001b[39m\u001b[32m952\u001b[39m \u001b[38;5;28;01myield from\u001b[39;00m \u001b[38;5;28mself\u001b[39m._client.chat(**chat_params)\n\u001b[32m 953\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m._client:\n\u001b[32m 954\u001b[39m \u001b[38;5;28;01myield\u001b[39;00m \u001b[38;5;28mself\u001b[39m._client.chat(**chat_params)\n",
395
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\ollama\\_client.py:181\u001b[39m, in \u001b[36mClient._request.<locals>.inner\u001b[39m\u001b[34m()\u001b[39m\n\u001b[32m 178\u001b[39m e.response.read()\n\u001b[32m 179\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m ResponseError(e.response.text, e.response.status_code) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m181\u001b[39m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mline\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mr\u001b[49m\u001b[43m.\u001b[49m\u001b[43miter_lines\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 182\u001b[39m \u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mjson\u001b[49m\u001b[43m.\u001b[49m\u001b[43mloads\u001b[49m\u001b[43m(\u001b[49m\u001b[43mline\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 183\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43merr\u001b[49m\u001b[43m \u001b[49m\u001b[43m:=\u001b[49m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43merror\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n",
396
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpx\\_models.py:929\u001b[39m, in \u001b[36mResponse.iter_lines\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 927\u001b[39m decoder = LineDecoder()\n\u001b[32m 928\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request=\u001b[38;5;28mself\u001b[39m._request):\n\u001b[32m--> \u001b[39m\u001b[32m929\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mtext\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43miter_text\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 930\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mline\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mdecoder\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtext\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 931\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mline\u001b[49m\n",
397
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpx\\_models.py:916\u001b[39m, in \u001b[36mResponse.iter_text\u001b[39m\u001b[34m(self, chunk_size)\u001b[39m\n\u001b[32m 914\u001b[39m chunker = TextChunker(chunk_size=chunk_size)\n\u001b[32m 915\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request=\u001b[38;5;28mself\u001b[39m._request):\n\u001b[32m--> \u001b[39m\u001b[32m916\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mbyte_content\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43miter_bytes\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 917\u001b[39m \u001b[43m \u001b[49m\u001b[43mtext_content\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mdecoder\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbyte_content\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 918\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunker\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtext_content\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n",
398
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpx\\_models.py:897\u001b[39m, in \u001b[36mResponse.iter_bytes\u001b[39m\u001b[34m(self, chunk_size)\u001b[39m\n\u001b[32m 895\u001b[39m chunker = ByteChunker(chunk_size=chunk_size)\n\u001b[32m 896\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request=\u001b[38;5;28mself\u001b[39m._request):\n\u001b[32m--> \u001b[39m\u001b[32m897\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mraw_bytes\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43miter_raw\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 898\u001b[39m \u001b[43m \u001b[49m\u001b[43mdecoded\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mdecoder\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mraw_bytes\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 899\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunker\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdecoded\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n",
399
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpx\\_models.py:951\u001b[39m, in \u001b[36mResponse.iter_raw\u001b[39m\u001b[34m(self, chunk_size)\u001b[39m\n\u001b[32m 948\u001b[39m chunker = ByteChunker(chunk_size=chunk_size)\n\u001b[32m 950\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request=\u001b[38;5;28mself\u001b[39m._request):\n\u001b[32m--> \u001b[39m\u001b[32m951\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mraw_stream_bytes\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 952\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_num_bytes_downloaded\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mraw_stream_bytes\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 953\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunker\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mraw_stream_bytes\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n",
400
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpx\\_client.py:153\u001b[39m, in \u001b[36mBoundSyncStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 152\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> typing.Iterator[\u001b[38;5;28mbytes\u001b[39m]:\n\u001b[32m--> \u001b[39m\u001b[32m153\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_stream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 154\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\n",
401
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpx\\_transports\\default.py:127\u001b[39m, in \u001b[36mResponseStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 125\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> typing.Iterator[\u001b[38;5;28mbytes\u001b[39m]:\n\u001b[32m 126\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_httpcore_exceptions():\n\u001b[32m--> \u001b[39m\u001b[32m127\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_httpcore_stream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 128\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\n",
402
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_sync\\connection_pool.py:407\u001b[39m, in \u001b[36mPoolByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 405\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[32m 406\u001b[39m \u001b[38;5;28mself\u001b[39m.close()\n\u001b[32m--> \u001b[39m\u001b[32m407\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m\n",
403
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_sync\\connection_pool.py:403\u001b[39m, in \u001b[36mPoolByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 401\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> typing.Iterator[\u001b[38;5;28mbytes\u001b[39m]:\n\u001b[32m 402\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m403\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_stream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 404\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\n\u001b[32m 405\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
404
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_sync\\http11.py:342\u001b[39m, in \u001b[36mHTTP11ConnectionByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 340\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m ShieldCancellation():\n\u001b[32m 341\u001b[39m \u001b[38;5;28mself\u001b[39m.close()\n\u001b[32m--> \u001b[39m\u001b[32m342\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc\n",
405
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_sync\\http11.py:334\u001b[39m, in \u001b[36mHTTP11ConnectionByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 332\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 333\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\u001b[33m\"\u001b[39m\u001b[33mreceive_response_body\u001b[39m\u001b[33m\"\u001b[39m, logger, \u001b[38;5;28mself\u001b[39m._request, kwargs):\n\u001b[32m--> \u001b[39m\u001b[32m334\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_receive_response_body\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 335\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\n\u001b[32m 336\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[32m 337\u001b[39m \u001b[38;5;66;03m# If we get an exception while streaming the response,\u001b[39;00m\n\u001b[32m 338\u001b[39m \u001b[38;5;66;03m# we want to close the response (and possibly the connection)\u001b[39;00m\n\u001b[32m 339\u001b[39m \u001b[38;5;66;03m# before raising that exception.\u001b[39;00m\n",
406
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_sync\\http11.py:203\u001b[39m, in \u001b[36mHTTP11Connection._receive_response_body\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 200\u001b[39m timeout = timeouts.get(\u001b[33m\"\u001b[39m\u001b[33mread\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m 202\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m203\u001b[39m event = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_receive_event\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 204\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(event, h11.Data):\n\u001b[32m 205\u001b[39m \u001b[38;5;28;01myield\u001b[39;00m \u001b[38;5;28mbytes\u001b[39m(event.data)\n",
407
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_sync\\http11.py:217\u001b[39m, in \u001b[36mHTTP11Connection._receive_event\u001b[39m\u001b[34m(self, timeout)\u001b[39m\n\u001b[32m 214\u001b[39m event = \u001b[38;5;28mself\u001b[39m._h11_state.next_event()\n\u001b[32m 216\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m event \u001b[38;5;129;01mis\u001b[39;00m h11.NEED_DATA:\n\u001b[32m--> \u001b[39m\u001b[32m217\u001b[39m data = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_network_stream\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 218\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mREAD_NUM_BYTES\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\n\u001b[32m 219\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 221\u001b[39m \u001b[38;5;66;03m# If we feed this case through h11 we'll raise an exception like:\u001b[39;00m\n\u001b[32m 222\u001b[39m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[32m 223\u001b[39m \u001b[38;5;66;03m# httpcore.RemoteProtocolError: can't handle event type\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 227\u001b[39m \u001b[38;5;66;03m# perspective. Instead we handle this case distinctly and treat\u001b[39;00m\n\u001b[32m 228\u001b[39m \u001b[38;5;66;03m# it as a ConnectError.\u001b[39;00m\n\u001b[32m 229\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m data == \u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m._h11_state.their_state == h11.SEND_RESPONSE:\n",
408
+ "\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\dgl17\\Desktop\\Lavoro\\Personal\\Final_Assignment_Template\\hfagent\\Lib\\site-packages\\httpcore\\_backends\\sync.py:128\u001b[39m, in \u001b[36mSyncStream.read\u001b[39m\u001b[34m(self, max_bytes, timeout)\u001b[39m\n\u001b[32m 126\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_exceptions(exc_map):\n\u001b[32m 127\u001b[39m \u001b[38;5;28mself\u001b[39m._sock.settimeout(timeout)\n\u001b[32m--> \u001b[39m\u001b[32m128\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_sock\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrecv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmax_bytes\u001b[49m\u001b[43m)\u001b[49m\n",
409
+ "\u001b[31mKeyboardInterrupt\u001b[39m: "
410
+ ]
411
+ }
412
+ ],
413
+ "source": [
414
+ "import random as rng\n",
415
+ "rq = rng.randint(0, questiondf.shape[0]-1)\n",
416
+ "\n",
417
+ "tid, problem, answer = (questiondf.iloc[rq][\"task_id\"], questiondf.iloc[rq][\"question\"], questiondf.iloc[rq][\"Final answer\"])\n",
418
+ "\n",
419
+ "input = {\"messages\": [{'role': 'user', 'content': problem}]}\n",
420
+ "response = assistant(problem)\n",
421
+ "print(response)"
422
+ ]
423
+ },
424
+ {
425
+ "cell_type": "markdown",
426
+ "id": "529dbdc5",
427
+ "metadata": {},
428
+ "source": [
429
+ "## Final Test"
430
+ ]
431
  }
432
  ],
433
  "metadata": {
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
 
src/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (281 Bytes). View file
 
src/__pycache__/agent.cpython-312.pyc ADDED
Binary file (7.78 kB). View file
 
src/__pycache__/connectors.cpython-312.pyc ADDED
Binary file (675 Bytes). View file
 
src/__pycache__/prompts.cpython-312.pyc ADDED
Binary file (1.6 kB). View file
 
src/__pycache__/tools.cpython-312.pyc ADDED
Binary file (607 Bytes). View file
 
src/agent.py CHANGED
@@ -1,18 +1,20 @@
1
  from langchain_ollama import ChatOllama
2
  from langgraph.graph import StateGraph, START, END
3
  from typing import TypedDict, Literal, Any
4
- from tools import TOOL_LIST
5
- from prompts import PLANNER, ANSWER
 
6
 
7
  class ObservationSchema(TypedDict):
8
  tool_name: str
9
  arguments: dict[str, Any]
10
- observation: Any
11
 
12
  class AgentSchema(TypedDict):
13
  query: str
14
- pastit: list[ObservationSchema]
15
- answer: str
 
16
 
17
  class ReActAgent():
18
  def __init__(self, modelid: str, verbose: bool = False):
@@ -21,15 +23,31 @@ class ReActAgent():
21
  self.verbose = verbose
22
 
23
  # nodes #
 
 
 
24
 
25
  # edges #
26
- workflow.add_conditional_edges(START, self.plan)
 
 
 
27
 
28
  # compile
29
- self.workflow = workflow.compile(); return
 
 
 
 
 
30
 
31
- def __call__(self, query: str):
32
- return self.workflow.invoke({"query": query, "pastit": [], "answer": ""})
 
 
 
 
 
33
 
34
  # nodes #
35
  def answer(self, state: AgentSchema) -> AgentSchema:
@@ -40,18 +58,52 @@ class ReActAgent():
40
  ]
41
  response = self.brain.invoke(messages)
42
  if self.verbose: print(response.content)
43
- return {"query": state.get("query", ""), "pastit": state.get("pastit", []), "answer": response.content}
 
44
 
45
  def reason(self, state: AgentSchema) -> AgentSchema:
46
- self.brain.reasoning = True; self.brain.temperature = 0.3
47
-
48
- # edges #
49
- def plan(self, state: AgentSchema) -> Literal["answer", "reason", "tool_call"]:
50
- self.brain.reasoning = True; self.brain.temperature = 0
51
  messages = [
52
- {'role': 'system', 'content': PLANNER.format(past_iterations=state.get("pastit", []))},
53
  {'role': 'user', 'content': state.get("query", "")}
54
  ]
55
- response = self.brain.invoke(messages)
 
 
56
  if self.verbose: print(f"#------ Reasoning ------#\n{response.additional_kwargs.get("reasoning_content", "")}\n#---------------------#\n\n#------ Response -------#\n{response.content}\n#-------------------------#\n")
57
- return ["answer", "reason", "tool_call"][int(response.content)-1]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from langchain_ollama import ChatOllama
2
  from langgraph.graph import StateGraph, START, END
3
  from typing import TypedDict, Literal, Any
4
+ from src import tools as agent_tools
5
+ from src.prompts import REASON, ANSWER
6
+ from pathlib import Path
7
 
8
  class ObservationSchema(TypedDict):
9
  tool_name: str
10
  arguments: dict[str, Any]
11
+ observation: Any = None
12
 
13
  class AgentSchema(TypedDict):
14
  query: str
15
+ pastit: list[ObservationSchema] = []
16
+ gotanswer: bool = False
17
+ answer: str = ""
18
 
19
  class ReActAgent():
20
  def __init__(self, modelid: str, verbose: bool = False):
 
23
  self.verbose = verbose
24
 
25
  # nodes #
26
+ workflow.add_node("reason", self.reason)
27
+ workflow.add_node("answer", self.answer)
28
+ workflow.add_node("tool_call", self.tool_call)
29
 
30
  # edges #
31
+ workflow.add_edge(START, "reason")
32
+ workflow.add_conditional_edges("reason", self.next_move)
33
+ workflow.add_edge("tool_call", "reason")
34
+ workflow.add_edge("answer", END)
35
 
36
  # compile
37
+ self.workflow = workflow.compile()
38
+ graphloc = Path("assets", "agent_graph.png")
39
+ graphloc.parent.mkdir(exist_ok=True)
40
+ if graphloc.exists(): graphloc.unlink()
41
+ graph = self.workflow.get_graph()
42
+ with open(graphloc, "wb") as gw: gw.write(graph.draw_mermaid_png())
43
 
44
+ def __call__(self, query: str): return self.workflow.invoke({ # INITIAL STATE
45
+ "query": query,
46
+ "answer": "",
47
+ "gotanswer": False,
48
+ "pastit": [],
49
+ "reasonings": []
50
+ })
51
 
52
  # nodes #
53
  def answer(self, state: AgentSchema) -> AgentSchema:
 
58
  ]
59
  response = self.brain.invoke(messages)
60
  if self.verbose: print(response.content)
61
+ state["answer"] = response.content
62
+ return state
63
 
64
  def reason(self, state: AgentSchema) -> AgentSchema:
65
+ self.brain.reasoning = True; self.brain.temperature = 0.2
66
+ tooled = self.brain.bind_tools(agent_tools.TOOL_LIST)
 
 
 
67
  messages = [
68
+ {'role': 'system', 'content': REASON},
69
  {'role': 'user', 'content': state.get("query", "")}
70
  ]
71
+ if state.get("pastit", None): messages.extend({'role': 'assistant', 'content': state.get("pastit")})
72
+
73
+ response = tooled.invoke(messages)
74
  if self.verbose: print(f"#------ Reasoning ------#\n{response.additional_kwargs.get("reasoning_content", "")}\n#---------------------#\n\n#------ Response -------#\n{response.content}\n#-------------------------#\n")
75
+
76
+ # storing routing in the state
77
+ if "ANSWER READY" in response.content: state["gotanswer"] = True
78
+ elif response.content: state["query"] = f"With the user asking: {state.get('query')}\nI asked myself: {response.content}"
79
+ if response.tool_calls: state["pastit"].extend([{
80
+ "tool_name": rtc["name"],
81
+ "arguments": rtc["args"],
82
+ "observation": None
83
+ } for rtc in response.tool_calls])
84
+ return state
85
+
86
+ def tool_call(self, state: AgentSchema) -> AgentSchema:
87
+ tobecalled = [(idx, tc) for idx,tc in enumerate(state.get("pastit", [])) if tc["observation"] is None]
88
+ if self.verbose: print(
89
+ f"Calling Tools:\n",
90
+ "\n".join([
91
+ f"- {tbcpair[1]['tool_name']}({', '.join([f"{argpair[0]}={argpair[1]}" for argpair in tbcpair[1]['arguments'].items()])})"
92
+ for tbcpair in tobecalled])
93
+ )
94
+
95
+ # calling logic
96
+ for tbcpair in tobecalled:
97
+ state["pastit"][tbcpair[0]]["observation"] = getattr(agent_tools, tbcpair[1]["tool_name"]).invoke(tbcpair[1]["arguments"])
98
+
99
+ if self.verbose: print(
100
+ f"Observations Obtained:\n",
101
+ "\n".join([f"-> {state['pastit'][tbcpair[0]]['observation']}" for tbcpair in tobecalled])
102
+ )
103
+ return state
104
+
105
+ # edges #
106
+ def next_move(self, state: AgentSchema) -> Literal["answer", "reason", "tool_call"]:
107
+ if state.get("gotanswer", False): return "answer"
108
+ if state.get("pastit", []) and not state.get("pastit", [])[-1]["observation"]: return "tool_call"
109
+ return "reason"
src/prompts.py CHANGED
@@ -1,25 +1,23 @@
1
- PLANNER = (
2
  """
3
- You are planning the best way to answer the user questions, you have the following info from past iterations:
4
- {past_iterations}
5
-
6
- Now you need to carefully plan the next step, you can decide one of the following options:
7
- 1. You have all the necessary information to provide the answers to the user questions
8
- 2. You have all the necessary information but you need to reason on the questions before providing correct answers
9
- 3. You don't have all the necessary information to proceed with an answer, it will be necessary to call some tools before proceeding
10
-
11
- After reasoning on what to do, provide the number corresponding to your choice for the next step.
12
- **IMPORTANT:** Only provide a single digit number corresponding to the option you want to follow
13
  """
14
- )[0].strip()
15
 
16
  ANSWER = (
17
  """
18
  You got the following information from past iterations: {past_iterations}
19
 
20
- Answer the user's questions by providing a single unformatted word/digit answer for each question he asked.
 
21
 
22
  **Format Examples:**
23
  1. User: "What is the first name of the singer of Thriller and at what age did he die?" -> Answer: "Michael, 51"
 
24
  """
25
- )[0].strip()
 
1
+ REASON = (
2
  """
3
+ Your task as a GAIA Solver is to use past iterations observations to reason carefully on the next move:
4
+ 1. IF you have all the information you need to provide an answer just respond: "ANSWER READY" and nothing else
5
+ 2. IF you don't have the necessary information to answer, use the provided tools to obtain the missing info
6
+ 3. IF the observations report useless info change strategy either by using different tools or drastically alterating the value of the arguments
7
+ 4. IF you have all the information but you struggle finding a valid answer, produce as answer a question to yourself that may improve the situation
8
+ 5. IF the loop continues for too long just abort it by answering: "ANSWER READY"
 
 
 
 
9
  """
10
+ ).strip()
11
 
12
  ANSWER = (
13
  """
14
  You got the following information from past iterations: {past_iterations}
15
 
16
+ Now is time to provide a definite answer to the user's questions: Remember that it is a GAIA benchmark, so as answer you must
17
+ provide single words/digits answers for each question separated by a comma as stated in the examples below:
18
 
19
  **Format Examples:**
20
  1. User: "What is the first name of the singer of Thriller and at what age did he die?" -> Answer: "Michael, 51"
21
+ 2. User: "what is the opposite of the word 'left'?" -> Answer: "Right"
22
  """
23
+ ).strip()