bstraehle commited on
Commit
54a93e4
·
1 Parent(s): 5c8a7a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -1,11 +1,10 @@
1
  import gradio as gr
2
  import os
3
 
4
- from datetime import datetime
5
  from langchain.agents import AgentType, initialize_agent, load_tools, tool
6
  from langchain.chat_models import ChatOpenAI
7
  from openai import OpenAI
8
- from tzlocal import get_localzone
9
 
10
  from dotenv import load_dotenv, find_dotenv
11
  _ = load_dotenv(find_dotenv())
@@ -22,14 +21,10 @@ AGENT_ON = True
22
 
23
  @tool
24
  def time(text: str) -> str:
25
- """Returns current datetime. Use this for any questions related to knowing current date and time.
26
- The input should always be an empty string, and this function will always return current datetime.
27
- Any date and time mathematics should occur outside this function."""
28
- dt = datetime.now()
29
- print(dt)
30
- dt_local = dt.astimezone(get_localzone())
31
- print(dt_local)
32
- return dt_local.strftime("%d/%m/%Y %H:%M:%S")
33
 
34
  def invoke(openai_api_key, prompt, agent_option):
35
  if (openai_api_key == ""):
@@ -81,7 +76,7 @@ gr.close_all()
81
 
82
  demo = gr.Interface(fn = invoke,
83
  inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
84
- gr.Textbox(label = "Prompt", lines = 1, value = "What is the current datetime and weather in Irvine, California? Suggest activities for an active person."),
85
  gr.Radio([AGENT_OFF, AGENT_ON], label = "Use Agent", value = AGENT_ON)],
86
  outputs = [gr.Textbox(label = "Completion", lines = 1)],
87
  title = "Real-Time Reasoning Application",
 
1
  import gradio as gr
2
  import os
3
 
4
+ from datetime import date
5
  from langchain.agents import AgentType, initialize_agent, load_tools, tool
6
  from langchain.chat_models import ChatOpenAI
7
  from openai import OpenAI
 
8
 
9
  from dotenv import load_dotenv, find_dotenv
10
  _ = load_dotenv(find_dotenv())
 
21
 
22
  @tool
23
  def time(text: str) -> str:
24
+ """Returns today's date. Use this for any questions related to knowing today's date.
25
+ The input should always be an empty string, and this function will always return today's date.
26
+ Any date mathematics should occur outside this function."""
27
+ return str(date.today())
 
 
 
 
28
 
29
  def invoke(openai_api_key, prompt, agent_option):
30
  if (openai_api_key == ""):
 
76
 
77
  demo = gr.Interface(fn = invoke,
78
  inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
79
+ gr.Textbox(label = "Prompt", lines = 1, value = "What is the weather in Irvine, California, in imperial system? Suggest activities for an active person."),
80
  gr.Radio([AGENT_OFF, AGENT_ON], label = "Use Agent", value = AGENT_ON)],
81
  outputs = [gr.Textbox(label = "Completion", lines = 1)],
82
  title = "Real-Time Reasoning Application",