Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -21,10 +21,10 @@ AGENT_ON = True
|
|
21 |
|
22 |
@tool
|
23 |
def time(text: str) -> str:
|
24 |
-
"""Returns
|
25 |
-
The input should always be an empty string, and this function will always return
|
26 |
-
Any date mathematics should occur outside this function."""
|
27 |
-
return
|
28 |
|
29 |
def invoke(openai_api_key, prompt, agent_option):
|
30 |
if (openai_api_key == ""):
|
@@ -76,7 +76,7 @@ gr.close_all()
|
|
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?
|
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",
|
|
|
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
|
|
|
21 |
|
22 |
@tool
|
23 |
def time(text: str) -> str:
|
24 |
+
"""Returns current datetime. Use this for any questions related to knowing current date and time.
|
25 |
+
The input should always be an empty string, and this function will always return current datetime.
|
26 |
+
Any date and time mathematics should occur outside this function."""
|
27 |
+
return datetime.now().strftime("%d/%m/%Y %H:%M:%S")
|
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 current datetime and weather in Irvine, California? 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",
|