bstraehle commited on
Commit
e5813a5
·
1 Parent(s): 1a8951a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -21,11 +21,11 @@ AGENT_ON = True
21
 
22
  @tool
23
  def time(text: str) -> str:
24
- """Returns todays date, use this for any \
25
- questions related to knowing todays date. \
26
  The input should always be an empty string, \
27
- and this function will always return todays \
28
- date - any date mathmatics should occur \
29
  outside this function."""
30
  return str(date.today())
31
 
@@ -45,7 +45,7 @@ def invoke(openai_api_key, prompt, agent_option):
45
  temperature = config["temperature"])
46
 
47
  if (agent_option == AGENT_OFF):
48
- agent = initialize_agent([],
49
  llm,
50
  agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
51
  handle_parsing_errors = True,
@@ -53,8 +53,8 @@ def invoke(openai_api_key, prompt, agent_option):
53
  else:
54
  tools = load_tools(["openweathermap-api"])
55
 
56
- agent = initialize_agent(tools + # built-in
57
- [time], # custom
58
  llm,
59
  agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
60
  handle_parsing_errors = True,
@@ -70,9 +70,6 @@ def invoke(openai_api_key, prompt, agent_option):
70
 
71
  return output
72
 
73
- description = """<a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> API
74
- with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""
75
-
76
  gr.close_all()
77
 
78
  demo = gr.Interface(fn = invoke,
@@ -81,7 +78,7 @@ demo = gr.Interface(fn = invoke,
81
  gr.Radio([AGENT_OFF, AGENT_ON], label = "Use Agent", value = AGENT_OFF)],
82
  outputs = [gr.Textbox(label = "Completion", lines = 1)],
83
  title = "Generative AI - LLM & Agent",
84
- description = description,
85
  examples = [["sk-", "What is today's date?", AGENT_ON],
86
  ["sk-", "What is the weather in Irvine, California? Answer in metric and imperial system.", AGENT_ON]],
87
  cache_examples = False)
 
21
 
22
  @tool
23
  def time(text: str) -> str:
24
+ """Returns today's date, use this for any \
25
+ questions related to knowing today's date. \
26
  The input should always be an empty string, \
27
+ and this function will always return today's \
28
+ date - any date mathematics should occur \
29
  outside this function."""
30
  return str(date.today())
31
 
 
45
  temperature = config["temperature"])
46
 
47
  if (agent_option == AGENT_OFF):
48
+ agent = initialize_agent([], # no tools
49
  llm,
50
  agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
51
  handle_parsing_errors = True,
 
53
  else:
54
  tools = load_tools(["openweathermap-api"])
55
 
56
+ agent = initialize_agent(tools + # built-in tools
57
+ [time], # custom tools
58
  llm,
59
  agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
60
  handle_parsing_errors = True,
 
70
 
71
  return output
72
 
 
 
 
73
  gr.close_all()
74
 
75
  demo = gr.Interface(fn = invoke,
 
78
  gr.Radio([AGENT_OFF, AGENT_ON], label = "Use Agent", value = AGENT_OFF)],
79
  outputs = [gr.Textbox(label = "Completion", lines = 1)],
80
  title = "Generative AI - LLM & Agent",
81
+ description = os.environ["DESCRIPTION"],
82
  examples = [["sk-", "What is today's date?", AGENT_ON],
83
  ["sk-", "What is the weather in Irvine, California? Answer in metric and imperial system.", AGENT_ON]],
84
  cache_examples = False)