WingNeville commited on
Commit
3132e24
·
verified ·
1 Parent(s): 2cf0366

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -62
app.py CHANGED
@@ -10,69 +10,14 @@ import os
10
  openai.api_key = os.getenv("OPENAI_API_KEY")
11
 
12
 
13
- from Gradio_UI import GradioUI
14
 
15
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
16
- @tool
17
-
18
- def my_custom_tool(arg1: str, arg2: int) -> str:
19
- """A tool that combines two arguments into a message.
20
-
21
- Args:
22
- arg1: the first argument (string)
23
- arg2: the second argument (integer)
24
-
25
- Returns:
26
- A message combining both arguments.
27
- """
28
- return f"You provided '{arg1}' and the number {arg2}."
29
-
30
- @tool
31
- def get_current_time_in_timezone(timezone: str) -> str:
32
- """A tool that fetches the current local time in a specified timezone.
33
- Args:
34
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
35
- """
36
- try:
37
- # Create timezone object
38
- tz = pytz.timezone(timezone)
39
- # Get current time in that timezone
40
- local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
41
- return f"The current local time in {timezone} is: {local_time}"
42
- except Exception as e:
43
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
44
-
45
-
46
- final_answer = FinalAnswerTool()
47
-
48
- # 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:
49
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
50
-
51
- model = HfApiModel(
52
- max_tokens=2096,
53
- temperature=0.5,
54
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
55
- custom_role_conversions=None,
56
  )
57
 
58
-
59
- # Import tool from Hub
60
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
61
-
62
- with open("prompts.yaml", 'r') as stream:
63
- prompt_templates = yaml.safe_load(stream)
64
-
65
- agent = CodeAgent(
66
- model=model,
67
- tools=[final_answer], ## add your tools here (don't remove final answer)
68
- max_steps=6,
69
- verbosity_level=1,
70
- grammar=None,
71
- planning_interval=None,
72
- name=None,
73
- description=None,
74
- prompt_templates=prompt_templates
75
  )
76
-
77
-
78
- GradioUI(agent).launch()
 
10
  openai.api_key = os.getenv("OPENAI_API_KEY")
11
 
12
 
 
13
 
14
+ model = OpenAIServerModel(
15
+ model_id="codestral-latest",
16
+ api_base="https://codestral.mistral.ai/v1/",
17
+ api_key=api_key,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  )
19
 
20
+ agent = CodeAgent(tools=[], model=model, add_base_tools=True)
21
+ agent.run(
22
+ "Could you give me the 40th number in the Fibonacci sequence?",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  )