lcapriles commited on
Commit
a875326
·
verified ·
1 Parent(s): 24cdfe6

added SYSTEM_PROMPT and client.chat.completions.create(messages[])
testing prompt_templates

Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -11,18 +11,18 @@ from Gradio_UI import GradioUI
11
  # Here we suppose that the textual description of the tools has already been appended
12
  SYSTEM_PROMPT = """Answer the following questions as best you can. You have access to the following tools:
13
 
14
- get_weather: Get the current weather in a given location
15
 
16
  The way you use the tools is by specifying a json blob.
17
  Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).
18
 
19
  The only values that should be in the "action" field are:
20
- get_weather: Get the current weather in a given location, args: {"location": {"type": "string"}}
21
  example use :
22
  ```
23
  {{
24
- "action": "get_weather",
25
- "action_input": {"location": "New York"}
26
  }}
27
 
28
  ALWAYS use the following format:
@@ -43,6 +43,17 @@ Final Answer: the final answer to the original input question
43
 
44
  Now begin! Reminder to ALWAYS use the exact characters `Final Answer:` when you provide a definitive answer. """
45
 
 
 
 
 
 
 
 
 
 
 
 
46
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
47
  @tool
48
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
@@ -82,16 +93,19 @@ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may
82
  custom_role_conversions=None,
83
  )
84
 
 
85
 
86
  # Import tool from Hub
87
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
88
 
89
  with open("prompts.yaml", 'r') as stream:
90
  prompt_templates = yaml.safe_load(stream)
 
 
91
 
92
  agent = CodeAgent(
93
  model=model,
94
- tools=[final_answer], ## add your tools here (don't remove final answer)
95
  max_steps=6,
96
  verbosity_level=1,
97
  grammar=None,
 
11
  # Here we suppose that the textual description of the tools has already been appended
12
  SYSTEM_PROMPT = """Answer the following questions as best you can. You have access to the following tools:
13
 
14
+ get_current_time_in_timezone: Fetches the current local time in a specified timezone
15
 
16
  The way you use the tools is by specifying a json blob.
17
  Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).
18
 
19
  The only values that should be in the "action" field are:
20
+ get_current_time_in_timezone: Get the current current local time in a specified timezone, args: {"timezone": {"type": "string"}}
21
  example use :
22
  ```
23
  {{
24
+ "action": "get_current_time_in_timezone",
25
+ "action_input": {"timezone": 'America/New_York'}
26
  }}
27
 
28
  ALWAYS use the following format:
 
43
 
44
  Now begin! Reminder to ALWAYS use the exact characters `Final Answer:` when you provide a definitive answer. """
45
 
46
+ output = client.chat.completions.create(
47
+ messages=[
48
+ {"role": "system", "content": SYSTEM_PROMPT},
49
+ {"role": "agent", "content": "Hi, I am an agent that knows the current time..."},
50
+ {"role": "user", "content": "{input}"},
51
+ ],
52
+ stream=False,
53
+ max_tokens=2048,
54
+ stop=["Observation:"] # Let's stop before any actual function is called
55
+ )
56
+
57
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
58
  @tool
59
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
 
93
  custom_role_conversions=None,
94
  )
95
 
96
+ # new_prompt=prompt+output+get_current_time_in_timezone('{input}')
97
 
98
  # Import tool from Hub
99
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
100
 
101
  with open("prompts.yaml", 'r') as stream:
102
  prompt_templates = yaml.safe_load(stream)
103
+
104
+ print("yaml" + prompt_templates)
105
 
106
  agent = CodeAgent(
107
  model=model,
108
+ tools=[get_current_time_in_timezone,final_answer], ## add your tools here (don't remove final answer)
109
  max_steps=6,
110
  verbosity_level=1,
111
  grammar=None,