mjschock commited on
Commit
352f525
·
unverified ·
1 Parent(s): 1e85c87

Refactor imports in main_v2.py to include SmartSearchTool, enhance code organization in model_factory.py by removing unnecessary whitespace, and improve formatting in test_questions.py for better readability and consistency.

Browse files
Files changed (3) hide show
  1. main_v2.py +1 -1
  2. model_factory.py +5 -3
  3. test_questions.py +7 -3
main_v2.py CHANGED
@@ -12,8 +12,8 @@ from phoenix.otel import register
12
  from smolagents import CodeAgent, LiteLLMModel
13
  from smolagents.monitoring import LogLevel
14
 
15
- from tools.smart_search.tool import SmartSearchTool
16
  from model_factory import ModelFactory
 
17
 
18
  _disable_debugging()
19
 
 
12
  from smolagents import CodeAgent, LiteLLMModel
13
  from smolagents.monitoring import LogLevel
14
 
 
15
  from model_factory import ModelFactory
16
+ from tools.smart_search.tool import SmartSearchTool
17
 
18
  _disable_debugging()
19
 
model_factory.py CHANGED
@@ -1,24 +1,26 @@
1
  import os
 
2
  from dotenv import find_dotenv, load_dotenv
3
  from smolagents import LiteLLMModel, TransformersModel
4
 
 
5
  class ModelFactory:
6
  @staticmethod
7
  def create_model():
8
  """
9
  Creates and returns a LiteLLMModel instance configured with environment variables.
10
-
11
  Returns:
12
  LiteLLMModel: A configured instance of LiteLLMModel
13
  """
14
  # Load environment variables
15
  load_dotenv(find_dotenv())
16
-
17
  # Get configuration from environment variables
18
  api_base = os.getenv("API_BASE")
19
  api_key = os.getenv("API_KEY")
20
  model_id = os.getenv("MODEL_ID")
21
-
22
  # Create and return the model
23
  # return LiteLLMModel(
24
  # api_base=api_base,
 
1
  import os
2
+
3
  from dotenv import find_dotenv, load_dotenv
4
  from smolagents import LiteLLMModel, TransformersModel
5
 
6
+
7
  class ModelFactory:
8
  @staticmethod
9
  def create_model():
10
  """
11
  Creates and returns a LiteLLMModel instance configured with environment variables.
12
+
13
  Returns:
14
  LiteLLMModel: A configured instance of LiteLLMModel
15
  """
16
  # Load environment variables
17
  load_dotenv(find_dotenv())
18
+
19
  # Get configuration from environment variables
20
  api_base = os.getenv("API_BASE")
21
  api_key = os.getenv("API_KEY")
22
  model_id = os.getenv("MODEL_ID")
23
+
24
  # Create and return the model
25
  # return LiteLLMModel(
26
  # api_base=api_base,
test_questions.py CHANGED
@@ -1,17 +1,20 @@
1
  import unittest
 
2
  import requests
 
3
  from main_v2 import main
4
 
 
5
  class TestQuestions(unittest.TestCase):
6
  def setUp(self):
7
  self.api_url = "https://agents-course-unit4-scoring.hf.space"
8
  self.questions_url = f"{self.api_url}/questions"
9
-
10
  # Get questions from the API
11
  response = requests.get(self.questions_url, timeout=15)
12
  response.raise_for_status()
13
  self.questions = response.json()
14
-
15
  # Expected answers for each question
16
  self.expected_answers = {
17
  "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",
@@ -28,8 +31,9 @@ class TestQuestions(unittest.TestCase):
28
  self.assertEqual(
29
  actual_answer,
30
  expected_answer,
31
- f"Question: {question}\nExpected: {expected_answer}\nGot: {actual_answer}"
32
  )
33
 
 
34
  if __name__ == "__main__":
35
  unittest.main()
 
1
  import unittest
2
+
3
  import requests
4
+
5
  from main_v2 import main
6
 
7
+
8
  class TestQuestions(unittest.TestCase):
9
  def setUp(self):
10
  self.api_url = "https://agents-course-unit4-scoring.hf.space"
11
  self.questions_url = f"{self.api_url}/questions"
12
+
13
  # Get questions from the API
14
  response = requests.get(self.questions_url, timeout=15)
15
  response.raise_for_status()
16
  self.questions = response.json()
17
+
18
  # Expected answers for each question
19
  self.expected_answers = {
20
  "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",
 
31
  self.assertEqual(
32
  actual_answer,
33
  expected_answer,
34
+ f"Question: {question}\nExpected: {expected_answer}\nGot: {actual_answer}",
35
  )
36
 
37
+
38
  if __name__ == "__main__":
39
  unittest.main()