aintel-vs commited on
Commit
6ed4170
·
verified ·
1 Parent(s): ace2617

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -4,6 +4,8 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
 
7
 
8
  from Gradio_UI import GradioUI
9
 
@@ -39,13 +41,14 @@ final_answer = FinalAnswerTool()
39
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
40
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
41
 
42
- model = HfApiModel(
43
- max_tokens=2096,
44
- temperature=0.5,
45
- model_id='https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=AIzaSyDuxgug177abEYu49axKHvHdm3mecg2-II',# it is possible that this model may be overloaded
46
- custom_role_conversions=None,
47
- )
48
 
 
 
 
 
 
 
49
 
50
  # Import tool from Hub
51
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
@@ -54,7 +57,7 @@ with open("prompts.yaml", 'r') as stream:
54
  prompt_templates = yaml.safe_load(stream)
55
 
56
  agent = CodeAgent(
57
- model=model,
58
  tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from smolagents import LiteLLMModel
8
+ from dotenv import load_dotenv
9
 
10
  from Gradio_UI import GradioUI
11
 
 
41
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
42
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
43
 
44
+ load_dotenv()
 
 
 
 
 
45
 
46
+ # Replace all calls to HfApiModel
47
+ llm_model = LiteLLMModel(
48
+ model_id="gemini/gemini-2.0-flash", # you can see other model names here: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models. It is important to prefix the name with "gemini/"
49
+ api_key=os.getenv("AIzaSyDuxgug177abEYu49axKHvHdm3mecg2-II"),
50
+ max_tokens=8192
51
+ )
52
 
53
  # Import tool from Hub
54
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
 
57
  prompt_templates = yaml.safe_load(stream)
58
 
59
  agent = CodeAgent(
60
+ model=llm_model,
61
  tools=[final_answer], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,