Scott Cogan commited on
Commit
2059320
·
1 Parent(s): deb41f8

Update app.py and requirements.txt

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  from smolagents import CodeAgent, DuckDuckGoSearchTool, load_tool, tool
2
- from openai import OpenAI
3
  import datetime
4
  import requests
5
  import pytz
@@ -53,12 +53,16 @@ def get_current_time_in_timezone(timezone: str) -> str:
53
 
54
  final_answer = FinalAnswerTool()
55
 
56
- # Initialize OpenAI model
57
- client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
58
- model = client.chat.completions.create(
59
- model="gpt-4-turbo-preview",
60
- max_tokens=4096,
61
- temperature=0.1,
 
 
 
 
62
  )
63
 
64
  # Import tool from Hub
 
1
  from smolagents import CodeAgent, DuckDuckGoSearchTool, load_tool, tool
2
+ from smolagents.models import OpenAIModel
3
  import datetime
4
  import requests
5
  import pytz
 
53
 
54
  final_answer = FinalAnswerTool()
55
 
56
+ # Load configuration from agent.json
57
+ with open("agent.json", 'r') as f:
58
+ config = yaml.safe_load(f)
59
+
60
+ # Initialize OpenAI model using the configuration
61
+ model = OpenAIModel(
62
+ model=config["model"]["data"]["model_id"],
63
+ max_tokens=config["model"]["data"]["max_tokens"],
64
+ temperature=config["model"]["data"]["temperature"],
65
+ api_key=os.getenv("OPENAI_API_KEY")
66
  )
67
 
68
  # Import tool from Hub