Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
-
from datetime import
|
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
|
26 |
-
The input should always be an empty string, and this function will always return
|
27 |
-
Any date
|
28 |
-
|
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
|
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",
|