TzurVaich commited on
Commit
e0f9aaf
·
1 Parent(s): 397fb4a

10% accurate, first working version

Browse files
Files changed (5) hide show
  1. .gitignore +1 -0
  2. app.py +117 -3
  3. poetry.lock +110 -1
  4. pyproject.toml +2 -1
  5. test_agents,py +42 -0
.gitignore CHANGED
@@ -1 +1,2 @@
1
  .env
 
 
1
  .env
2
+ __pycache__/
app.py CHANGED
@@ -1,10 +1,18 @@
 
1
  import os
2
  import gradio as gr
3
  import requests
4
  import inspect
 
 
5
  import pandas as pd
6
  from dotenv import load_dotenv
7
 
 
 
 
 
 
8
  # Load environment variables from .env file
9
  load_dotenv()
10
  print(os.getenv("HF_TOKEN"))
@@ -17,14 +25,120 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
17
 
18
  # --- Basic Agent Definition ---
19
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
 
 
 
20
  class BasicAgent:
21
  def __init__(self):
22
  print("BasicAgent initialized.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def __call__(self, question: str) -> str:
24
  print(f"Agent received question (first 50 chars): {question[:50]}...")
25
- fixed_answer = "This is a default answer."
26
- print(f"Agent returning fixed answer: {fixed_answer}")
27
- return fixed_answer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  def run_and_submit_all( profile: gr.OAuthProfile | None):
30
  """
 
1
+ import re
2
  import os
3
  import gradio as gr
4
  import requests
5
  import inspect
6
+ import datetime
7
+ from textwrap import dedent
8
  import pandas as pd
9
  from dotenv import load_dotenv
10
 
11
+ # Import smolagents components
12
+ from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool
13
+
14
+
15
+
16
  # Load environment variables from .env file
17
  load_dotenv()
18
  print(os.getenv("HF_TOKEN"))
 
25
 
26
  # --- Basic Agent Definition ---
27
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
28
+
29
+ # Initialize the search tool
30
+ search_tool = DuckDuckGoSearchTool()
31
+
32
+
33
  class BasicAgent:
34
  def __init__(self):
35
  print("BasicAgent initialized.")
36
+ # Create a filename with current date and time
37
+ current_time = datetime.datetime.now().strftime("%Y%m%d_%H%M")
38
+ self.filename = f"questions_{current_time}.txt"
39
+ print(f"Questions will be written to {self.filename}")
40
+
41
+ # Clear the file if it exists or create a new one
42
+ with open(self.filename, 'w', encoding='utf-8') as f:
43
+ f.write('') # Create empty file
44
+
45
+
46
+ # Initialize the Large Language Model
47
+ # The model is used by both agents in this simple setup
48
+ self.model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
49
+
50
+
51
+ # Define the Web Search Agent
52
+ # This agent is specialised for searching the web using a specific tool
53
+ self.web_search_agent = CodeAgent(
54
+ model=self.model, # Assign the model to the agent [
55
+ tools=[DuckDuckGoSearchTool()], # Provide the web search tool
56
+ name="web_search_agent", # Give the agent a name
57
+ # Describe its capability [
58
+ description="Searches the web for information.",
59
+ verbosity_level=1, # Set verbosity level for logging
60
+ max_steps=5, # Limit the steps the agent can take
61
+ )
62
+
63
+ # Define the Manager Agent
64
+ # This agent manages tasks and delegates to other agents
65
+ self.manager_agent = CodeAgent(
66
+ model=self.model, # Assign the model to the manager
67
+ tools=[],
68
+ managed_agents=[self.web_search_agent], # Specify the agents this manager oversees
69
+ name="manager_agent", # Give the manager agent a name
70
+ description="Manages tasks by delegating to other agents.", # Describe its role
71
+ additional_authorized_imports=[
72
+ "json", "re", "pandas", "numpy", "math", "collections", "itertools", "stat", "statistics", "queue", "unicodedata", "time", "random", "datetime"], # Allow specific imports
73
+ verbosity_level=1, # Set verbosity level
74
+ max_steps=5, # Limit the steps
75
+ )
76
+
77
+ print("MultiAgentSystem initialization complete.")
78
+
79
+
80
  def __call__(self, question: str) -> str:
81
  print(f"Agent received question (first 50 chars): {question[:50]}...")
82
+
83
+
84
+ # For all other questions, use the manager agent with web search
85
+ manager_prompt = dedent(f"""
86
+ I need to answer the following question accurately:
87
+
88
+ {question}
89
+
90
+ Please analyze this question and determine the best approach to answer it.
91
+ If needed, use web search to find relevant information.
92
+ Provide a concise, accurate answer to the question.
93
+ """)
94
+
95
+ manager_agent_response = "I apologize, but I couldn't find an answer to this question."
96
+ answer = ""
97
+ source = ""
98
+ try:
99
+ manager_agent_response = self.manager_agent.run(manager_prompt)
100
+ source = "manager_agent"
101
+
102
+ # # Clean up the answer - remove explanations, etc.
103
+ # if len(manager_agent_response) > 300:
104
+ # # Try to extract just the answer
105
+ # answer_pattern = r'(?:answer|result)(?:\s+is)?(?:\s*:)?\s*(.+?)(?:\.|$)'
106
+ # answer_match = re.search(answer_pattern, manager_agent_response, re.IGNORECASE)
107
+
108
+ # if answer_match:
109
+ # answer = answer_match.group(1).strip()
110
+ # else:
111
+ # # Get the last paragraph
112
+ # paragraphs = [p for p in answer.split('\n') if p.strip()]
113
+ # if paragraphs:
114
+ # answer = paragraphs[-1].strip()
115
+ # source = "long_answer"
116
+
117
+ #return answer
118
+
119
+ except Exception as e:
120
+ print(f"Error in manager agent: {e}")
121
+ source = f"Exception {e} "
122
+
123
+ # # Fall back to direct web search
124
+ # try:
125
+ # answer = self.web_search_agent.run(f"Please find accurate information to answer: {question}")
126
+ # source = "web_search_agent"
127
+
128
+ # except Exception as e2:
129
+ # print(f"Error in web agent: {e2}")
130
+ # answer="I apologize, but I couldn't find an answer to this question."
131
+
132
+
133
+ # Append the question to the file
134
+ with open(self.filename, 'a', encoding='utf-8') as f:
135
+ f.write(f"{question}\n")
136
+ f.write(f"ANSWER by {source}: {manager_agent_response}\n")
137
+ f.write(f"{'*'*50}\n")
138
+
139
+ print(f"Final answer: {manager_agent_response}")
140
+ return manager_agent_response
141
+
142
 
143
  def run_and_submit_all( profile: gr.OAuthProfile | None):
144
  """
poetry.lock CHANGED
@@ -586,6 +586,75 @@ packaging = "*"
586
  typing-extensions = ">=4.0,<5.0"
587
  websockets = ">=10.0,<16.0"
588
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
  [[package]]
590
  name = "groovy"
591
  version = "0.1.2"
@@ -1349,6 +1418,28 @@ tests = ["check-manifest", "coverage (>=7.4.2)", "defusedxml", "markdown2", "ole
1349
  typing = ["typing-extensions"]
1350
  xmp = ["defusedxml"]
1351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1352
  [[package]]
1353
  name = "primp"
1354
  version = "0.15.0"
@@ -1530,6 +1621,24 @@ files = [
1530
  {file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"},
1531
  ]
1532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1533
  [[package]]
1534
  name = "pygments"
1535
  version = "2.19.1"
@@ -2087,4 +2196,4 @@ files = [
2087
  [metadata]
2088
  lock-version = "2.1"
2089
  python-versions = ">=3.12"
2090
- content-hash = "6b90481ab0325b1613e3268ba5fefc7aa4fa1ff6a6df8444050505f594d372c8"
 
586
  typing-extensions = ">=4.0,<5.0"
587
  websockets = ">=10.0,<16.0"
588
 
589
+ [[package]]
590
+ name = "greenlet"
591
+ version = "3.2.1"
592
+ description = "Lightweight in-process concurrent programming"
593
+ optional = false
594
+ python-versions = ">=3.9"
595
+ groups = ["main"]
596
+ files = [
597
+ {file = "greenlet-3.2.1-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:777c1281aa7c786738683e302db0f55eb4b0077c20f1dc53db8852ffaea0a6b0"},
598
+ {file = "greenlet-3.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3059c6f286b53ea4711745146ffe5a5c5ff801f62f6c56949446e0f6461f8157"},
599
+ {file = "greenlet-3.2.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e1a40a17e2c7348f5eee5d8e1b4fa6a937f0587eba89411885a36a8e1fc29bd2"},
600
+ {file = "greenlet-3.2.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5193135b3a8d0017cb438de0d49e92bf2f6c1c770331d24aa7500866f4db4017"},
601
+ {file = "greenlet-3.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:639a94d001fe874675b553f28a9d44faed90f9864dc57ba0afef3f8d76a18b04"},
602
+ {file = "greenlet-3.2.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8fe303381e7e909e42fb23e191fc69659910909fdcd056b92f6473f80ef18543"},
603
+ {file = "greenlet-3.2.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:72c9b668454e816b5ece25daac1a42c94d1c116d5401399a11b77ce8d883110c"},
604
+ {file = "greenlet-3.2.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6079ae990bbf944cf66bea64a09dcb56085815630955109ffa98984810d71565"},
605
+ {file = "greenlet-3.2.1-cp310-cp310-win_amd64.whl", hash = "sha256:e63cd2035f49376a23611fbb1643f78f8246e9d4dfd607534ec81b175ce582c2"},
606
+ {file = "greenlet-3.2.1-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:aa30066fd6862e1153eaae9b51b449a6356dcdb505169647f69e6ce315b9468b"},
607
+ {file = "greenlet-3.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7b0f3a0a67786facf3b907a25db80efe74310f9d63cc30869e49c79ee3fcef7e"},
608
+ {file = "greenlet-3.2.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:64a4d0052de53ab3ad83ba86de5ada6aeea8f099b4e6c9ccce70fb29bc02c6a2"},
609
+ {file = "greenlet-3.2.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:852ef432919830022f71a040ff7ba3f25ceb9fe8f3ab784befd747856ee58530"},
610
+ {file = "greenlet-3.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4818116e75a0dd52cdcf40ca4b419e8ce5cb6669630cb4f13a6c384307c9543f"},
611
+ {file = "greenlet-3.2.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9afa05fe6557bce1642d8131f87ae9462e2a8e8c46f7ed7929360616088a3975"},
612
+ {file = "greenlet-3.2.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:5c12f0d17a88664757e81a6e3fc7c2452568cf460a2f8fb44f90536b2614000b"},
613
+ {file = "greenlet-3.2.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:dbb4e1aa2000852937dd8f4357fb73e3911da426df8ca9b8df5db231922da474"},
614
+ {file = "greenlet-3.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:cb5ee928ce5fedf9a4b0ccdc547f7887136c4af6109d8f2fe8e00f90c0db47f5"},
615
+ {file = "greenlet-3.2.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:0ba2811509a30e5f943be048895a983a8daf0b9aa0ac0ead526dfb5d987d80ea"},
616
+ {file = "greenlet-3.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4245246e72352b150a1588d43ddc8ab5e306bef924c26571aafafa5d1aaae4e8"},
617
+ {file = "greenlet-3.2.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7abc0545d8e880779f0c7ce665a1afc3f72f0ca0d5815e2b006cafc4c1cc5840"},
618
+ {file = "greenlet-3.2.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6dcc6d604a6575c6225ac0da39df9335cc0c6ac50725063fa90f104f3dbdb2c9"},
619
+ {file = "greenlet-3.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2273586879affca2d1f414709bb1f61f0770adcabf9eda8ef48fd90b36f15d12"},
620
+ {file = "greenlet-3.2.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ff38c869ed30fff07f1452d9a204ece1ec6d3c0870e0ba6e478ce7c1515acf22"},
621
+ {file = "greenlet-3.2.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:e934591a7a4084fa10ee5ef50eb9d2ac8c4075d5c9cf91128116b5dca49d43b1"},
622
+ {file = "greenlet-3.2.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:063bcf7f8ee28eb91e7f7a8148c65a43b73fbdc0064ab693e024b5a940070145"},
623
+ {file = "greenlet-3.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7132e024ebeeeabbe661cf8878aac5d2e643975c4feae833142592ec2f03263d"},
624
+ {file = "greenlet-3.2.1-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:e1967882f0c42eaf42282a87579685c8673c51153b845fde1ee81be720ae27ac"},
625
+ {file = "greenlet-3.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e77ae69032a95640a5fe8c857ec7bee569a0997e809570f4c92048691ce4b437"},
626
+ {file = "greenlet-3.2.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3227c6ec1149d4520bc99edac3b9bc8358d0034825f3ca7572165cb502d8f29a"},
627
+ {file = "greenlet-3.2.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ddda0197c5b46eedb5628d33dad034c455ae77708c7bf192686e760e26d6a0c"},
628
+ {file = "greenlet-3.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de62b542e5dcf0b6116c310dec17b82bb06ef2ceb696156ff7bf74a7a498d982"},
629
+ {file = "greenlet-3.2.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c07a0c01010df42f1f058b3973decc69c4d82e036a951c3deaf89ab114054c07"},
630
+ {file = "greenlet-3.2.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:2530bfb0abcd451ea81068e6d0a1aac6dabf3f4c23c8bd8e2a8f579c2dd60d95"},
631
+ {file = "greenlet-3.2.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:1c472adfca310f849903295c351d297559462067f618944ce2650a1878b84123"},
632
+ {file = "greenlet-3.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:24a496479bc8bd01c39aa6516a43c717b4cee7196573c47b1f8e1011f7c12495"},
633
+ {file = "greenlet-3.2.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:175d583f7d5ee57845591fc30d852b75b144eb44b05f38b67966ed6df05c8526"},
634
+ {file = "greenlet-3.2.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3ecc9d33ca9428e4536ea53e79d781792cee114d2fa2695b173092bdbd8cd6d5"},
635
+ {file = "greenlet-3.2.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3f56382ac4df3860ebed8ed838f268f03ddf4e459b954415534130062b16bc32"},
636
+ {file = "greenlet-3.2.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cc45a7189c91c0f89aaf9d69da428ce8301b0fd66c914a499199cfb0c28420fc"},
637
+ {file = "greenlet-3.2.1-cp313-cp313t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:51a2f49da08cff79ee42eb22f1658a2aed60c72792f0a0a95f5f0ca6d101b1fb"},
638
+ {file = "greenlet-3.2.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:0c68bbc639359493420282d2f34fa114e992a8724481d700da0b10d10a7611b8"},
639
+ {file = "greenlet-3.2.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:e775176b5c203a1fa4be19f91da00fd3bff536868b77b237da3f4daa5971ae5d"},
640
+ {file = "greenlet-3.2.1-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:d6668caf15f181c1b82fb6406f3911696975cc4c37d782e19cb7ba499e556189"},
641
+ {file = "greenlet-3.2.1-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:17964c246d4f6e1327edd95e2008988a8995ae3a7732be2f9fc1efed1f1cdf8c"},
642
+ {file = "greenlet-3.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:04b4ec7f65f0e4a1500ac475c9343f6cc022b2363ebfb6e94f416085e40dea15"},
643
+ {file = "greenlet-3.2.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b38d53cf268da963869aa25a6e4cc84c1c69afc1ae3391738b2603d110749d01"},
644
+ {file = "greenlet-3.2.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:05a7490f74e8aabc5f29256765a99577ffde979920a2db1f3676d265a3adba41"},
645
+ {file = "greenlet-3.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4339b202ac20a89ccd5bde0663b4d00dc62dd25cb3fb14f7f3034dec1b0d9ece"},
646
+ {file = "greenlet-3.2.1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a750f1046994b9e038b45ae237d68153c29a3a783075211fb1414a180c8324b"},
647
+ {file = "greenlet-3.2.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:374ffebaa5fbd10919cd599e5cf8ee18bae70c11f9d61e73db79826c8c93d6f9"},
648
+ {file = "greenlet-3.2.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8b89e5d44f55372efc6072f59ced5ed1efb7b44213dab5ad7e0caba0232c6545"},
649
+ {file = "greenlet-3.2.1-cp39-cp39-win32.whl", hash = "sha256:b7503d6b8bbdac6bbacf5a8c094f18eab7553481a1830975799042f26c9e101b"},
650
+ {file = "greenlet-3.2.1-cp39-cp39-win_amd64.whl", hash = "sha256:e98328b8b8f160925d6b1c5b1879d8e64f6bd8cf11472b7127d579da575b77d9"},
651
+ {file = "greenlet-3.2.1.tar.gz", hash = "sha256:9f4dd4b4946b14bb3bf038f81e1d2e535b7d94f1b2a59fdba1293cd9c1a0a4d7"},
652
+ ]
653
+
654
+ [package.extras]
655
+ docs = ["Sphinx", "furo"]
656
+ test = ["objgraph", "psutil"]
657
+
658
  [[package]]
659
  name = "groovy"
660
  version = "0.1.2"
 
1418
  typing = ["typing-extensions"]
1419
  xmp = ["defusedxml"]
1420
 
1421
+ [[package]]
1422
+ name = "playwright"
1423
+ version = "1.52.0"
1424
+ description = "A high-level API to automate web browsers"
1425
+ optional = false
1426
+ python-versions = ">=3.9"
1427
+ groups = ["main"]
1428
+ files = [
1429
+ {file = "playwright-1.52.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:19b2cb9d4794062008a635a99bd135b03ebb782d460f96534a91cb583f549512"},
1430
+ {file = "playwright-1.52.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:0797c0479cbdc99607412a3c486a3a2ec9ddc77ac461259fd2878c975bcbb94a"},
1431
+ {file = "playwright-1.52.0-py3-none-macosx_11_0_universal2.whl", hash = "sha256:7223960b7dd7ddeec1ba378c302d1d09733b8dac438f492e9854c85d3ca7144f"},
1432
+ {file = "playwright-1.52.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:d010124d24a321e0489a8c0d38a3971a7ca7656becea7656c9376bfea7f916d4"},
1433
+ {file = "playwright-1.52.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4173e453c43180acc60fd77ffe1ebee8d0efbfd9986c03267007b9c3845415af"},
1434
+ {file = "playwright-1.52.0-py3-none-win32.whl", hash = "sha256:cd0bdf92df99db6237a99f828e80a6a50db6180ef8d5352fc9495df2c92f9971"},
1435
+ {file = "playwright-1.52.0-py3-none-win_amd64.whl", hash = "sha256:dcbf75101eba3066b7521c6519de58721ea44379eb17a0dafa94f9f1b17f59e4"},
1436
+ {file = "playwright-1.52.0-py3-none-win_arm64.whl", hash = "sha256:9d0085b8de513de5fb50669f8e6677f0252ef95a9a1d2d23ccee9638e71e65cb"},
1437
+ ]
1438
+
1439
+ [package.dependencies]
1440
+ greenlet = ">=3.1.1,<4.0.0"
1441
+ pyee = ">=13,<14"
1442
+
1443
  [[package]]
1444
  name = "primp"
1445
  version = "0.15.0"
 
1621
  {file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"},
1622
  ]
1623
 
1624
+ [[package]]
1625
+ name = "pyee"
1626
+ version = "13.0.0"
1627
+ description = "A rough port of Node.js's EventEmitter to Python with a few tricks of its own"
1628
+ optional = false
1629
+ python-versions = ">=3.8"
1630
+ groups = ["main"]
1631
+ files = [
1632
+ {file = "pyee-13.0.0-py3-none-any.whl", hash = "sha256:48195a3cddb3b1515ce0695ed76036b5ccc2ef3a9f963ff9f77aec0139845498"},
1633
+ {file = "pyee-13.0.0.tar.gz", hash = "sha256:b391e3c5a434d1f5118a25615001dbc8f669cf410ab67d04c4d4e07c55481c37"},
1634
+ ]
1635
+
1636
+ [package.dependencies]
1637
+ typing-extensions = "*"
1638
+
1639
+ [package.extras]
1640
+ dev = ["black", "build", "flake8", "flake8-black", "isort", "jupyter-console", "mkdocs", "mkdocs-include-markdown-plugin", "mkdocstrings[python]", "mypy", "pytest", "pytest-asyncio", "pytest-trio", "sphinx", "toml", "tox", "trio", "trio", "trio-typing", "twine", "twisted", "validate-pyproject[all]"]
1641
+
1642
  [[package]]
1643
  name = "pygments"
1644
  version = "2.19.1"
 
2196
  [metadata]
2197
  lock-version = "2.1"
2198
  python-versions = ">=3.12"
2199
+ content-hash = "0636f2e99ebcd2665712f585e4d3afc15d928f57ba17262419eb411badc1f4b1"
pyproject.toml CHANGED
@@ -12,7 +12,8 @@ dependencies = [
12
  "gradio[oauth] (>=5.27.0,<6.0.0)",
13
  "requests (>=2.32.3,<3.0.0)",
14
  "pandas (>=2.2.3,<3.0.0)",
15
- "python-dotenv (>=1.1.0,<2.0.0)"
 
16
  ]
17
 
18
 
 
12
  "gradio[oauth] (>=5.27.0,<6.0.0)",
13
  "requests (>=2.32.3,<3.0.0)",
14
  "pandas (>=2.2.3,<3.0.0)",
15
+ "python-dotenv (>=1.1.0,<2.0.0)",
16
+ "playwright (>=1.52.0,<2.0.0)"
17
  ]
18
 
19
 
test_agents,py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # test_agents,py
2
+ import os
3
+ from dotenv import load_dotenv
4
+
5
+ # Import the BasicAgent from your app module
6
+ try:
7
+ from app import BasicAgent
8
+ except ImportError as e:
9
+ print(f"Error importing BasicAgent from app.py: {e}")
10
+ print("Please ensure app.py is in the same directory or accessible in the Python path.")
11
+ exit(1)
12
+
13
+ # --- Define Question-Answer Pairs ---
14
+ # Note: The 'A' part is just for reference here; the agent will generate its own answer.
15
+ QA_PAIRS = {
16
+ "What is the capital of France?": "Paris",
17
+ "Who wrote 'Hamlet'?": "William Shakespeare",
18
+ "What is the formula for water?": "H2O",
19
+ "How does photosynthesis work?": "Plants use sunlight, water, and carbon dioxide to create their own food.",
20
+ # Agent should find current data
21
+ "What is the current population of Earth?": "Approximately 8 billion",
22
+ }
23
+
24
+
25
+ def run_test_questions():
26
+ """Instantiates the agent and runs it on the predefined questions."""
27
+ print("--- Starting Agent Test ---")
28
+ # Load environment variables (needed for BasicAgent initialization)
29
+ load_dotenv()
30
+ print(f"HF_TOKEN found: {'Yes' if os.getenv('HF_TOKEN') else 'No'}")
31
+
32
+ agent = BasicAgent()
33
+
34
+ for question in QA_PAIRS.keys():
35
+ print(f"\n--- Testing Question ---")
36
+ print(f"Q: {question}")
37
+ answer = agent(question) # Call the agent instance
38
+ print(f"Agent A: {answer}")
39
+
40
+
41
+ if __name__ == "__main__":
42
+ run_test_questions()