crcdng commited on
Commit
b9c9310
·
1 Parent(s): fe96f79

new ui elements

Browse files
Files changed (2) hide show
  1. Gradio_UI.py +7 -0
  2. app.py +14 -12
Gradio_UI.py CHANGED
@@ -274,6 +274,9 @@ class GradioUI:
274
  "",
275
  )
276
 
 
 
 
277
  def launch(self, **kwargs):
278
  import gradio as gr
279
 
@@ -333,6 +336,9 @@ class GradioUI:
333
  [upload_file, file_uploads_log],
334
  [upload_status, file_uploads_log],
335
  )
 
 
 
336
  text_input = gr.Textbox(lines=1, label="Chat Message")
337
  text_input.submit(
338
  self.log_user_message,
@@ -343,6 +349,7 @@ class GradioUI:
343
  examples=[["Tell me a joke based on the current local time"],["Given the current local time, what is a fun activity to do?"],["When asked for the current local time, add 6 hours to it. What is the current local time?"], ["Find significant events that happend exactly one year ago"], ["Generate a bold picture inspired by the current local time"]],
344
  inputs=[text_input],
345
  )
 
346
  demo.launch(debug=True, share=True, ssr_mode=False, allowed_paths=["Cyberpunk.otf"], **kwargs)
347
 
348
  __all__ = ["stream_to_gradio", "GradioUI"]
 
274
  "",
275
  )
276
 
277
+ def set_agent_steps(self, steps):
278
+ self.agent.max_steps = steps
279
+
280
  def launch(self, **kwargs):
281
  import gradio as gr
282
 
 
336
  [upload_file, file_uploads_log],
337
  [upload_status, file_uploads_log],
338
  )
339
+ with gr.Row():
340
+ steps_input = gr.Slider(0, 12, value=4, step=1, label="Max. Number of Steps")
341
+ reset = gr.Button(value="Reset Agent")
342
  text_input = gr.Textbox(lines=1, label="Chat Message")
343
  text_input.submit(
344
  self.log_user_message,
 
349
  examples=[["Tell me a joke based on the current local time"],["Given the current local time, what is a fun activity to do?"],["When asked for the current local time, add 6 hours to it. What is the current local time?"], ["Find significant events that happend exactly one year ago"], ["Generate a bold picture inspired by the current local time"]],
350
  inputs=[text_input],
351
  )
352
+
353
  demo.launch(debug=True, share=True, ssr_mode=False, allowed_paths=["Cyberpunk.otf"], **kwargs)
354
 
355
  __all__ = ["stream_to_gradio", "GradioUI"]
app.py CHANGED
@@ -7,7 +7,6 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
10
-
11
  @tool
12
  def get_current_time_in_timezone(timezone: str) -> str:
13
  """A tool that fetches the current local time in a specified timezone.
@@ -23,33 +22,36 @@ def get_current_time_in_timezone(timezone: str) -> str:
23
  except Exception as e:
24
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
25
 
26
- final_answer = FinalAnswerTool()
27
 
28
  model = HfApiModel(
29
- max_tokens=2096,
30
- temperature=0.5,
31
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
32
- custom_role_conversions=None,
33
  )
34
 
35
  # Import tool from Hub
36
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
37
 
38
- with open("prompts.yaml", 'r') as stream:
39
  prompt_templates = yaml.safe_load(stream)
40
-
41
  agent = CodeAgent(
42
  model=model,
43
- tools=[final_answer, get_current_time_in_timezone, image_generation_tool, DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
 
 
 
 
 
44
  max_steps=6,
45
  verbosity_level=1,
46
  grammar=None,
47
  planning_interval=None,
48
  name=None,
49
  description=None,
50
- prompt_templates=prompt_templates
51
  )
52
 
53
- print(f"docstring {get_current_time_in_timezone.__doc__}")
54
- print(f"string {get_current_time_in_timezone}")
55
  GradioUI(agent).launch()
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
10
  @tool
11
  def get_current_time_in_timezone(timezone: str) -> str:
12
  """A tool that fetches the current local time in a specified timezone.
 
22
  except Exception as e:
23
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
24
 
25
+ final_answer = FinalAnswerTool()
26
 
27
  model = HfApiModel(
28
+ max_tokens=2096,
29
+ temperature=0.5,
30
+ model_id="Qwen/Qwen2.5-Coder-32B-Instruct", # it is possible that this model may be overloaded
31
+ custom_role_conversions=None,
32
  )
33
 
34
  # Import tool from Hub
35
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
36
 
37
+ with open("prompts.yaml", "r") as stream:
38
  prompt_templates = yaml.safe_load(stream)
39
+
40
  agent = CodeAgent(
41
  model=model,
42
+ tools=[
43
+ final_answer,
44
+ get_current_time_in_timezone,
45
+ image_generation_tool,
46
+ DuckDuckGoSearchTool(),
47
+ ], ## add your tools here (don't remove final answer)
48
  max_steps=6,
49
  verbosity_level=1,
50
  grammar=None,
51
  planning_interval=None,
52
  name=None,
53
  description=None,
54
+ prompt_templates=prompt_templates,
55
  )
56
 
 
 
57
  GradioUI(agent).launch()