Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
from datetime import date
|
4 |
from langchain.agents import AgentType, initialize_agent, tool
|
5 |
from langchain.chat_models import ChatOpenAI
|
|
|
6 |
|
7 |
config = {
|
8 |
"max_tokens": 1000,
|
@@ -41,7 +42,11 @@ def invoke(openai_api_key, prompt, agent_option):
|
|
41 |
openai_api_key = openai_api_key,
|
42 |
temperature = config["temperature"])
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
llm,
|
46 |
agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
|
47 |
handle_parsing_errors = True,
|
@@ -69,8 +74,8 @@ demo = gr.Interface(fn = invoke,
|
|
69 |
outputs = [gr.Textbox(label = "Completion", lines = 1)],
|
70 |
title = "Generative AI - LLM & Agent",
|
71 |
description = description,
|
72 |
-
examples = [["sk-", "What is today's date?"],
|
73 |
-
["sk-", "What is the weather in SF?"]],
|
74 |
cache_examples = False)
|
75 |
|
76 |
demo.launch()
|
|
|
3 |
from datetime import date
|
4 |
from langchain.agents import AgentType, initialize_agent, tool
|
5 |
from langchain.chat_models import ChatOpenAI
|
6 |
+
from langchain_community.tools.tavily_search import TavilySearchResults
|
7 |
|
8 |
config = {
|
9 |
"max_tokens": 1000,
|
|
|
42 |
openai_api_key = openai_api_key,
|
43 |
temperature = config["temperature"])
|
44 |
|
45 |
+
search = TavilySearchResults()
|
46 |
+
|
47 |
+
tools = [search]
|
48 |
+
|
49 |
+
agent = initialize_agent(tools + [time],
|
50 |
llm,
|
51 |
agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
|
52 |
handle_parsing_errors = True,
|
|
|
74 |
outputs = [gr.Textbox(label = "Completion", lines = 1)],
|
75 |
title = "Generative AI - LLM & Agent",
|
76 |
description = description,
|
77 |
+
examples = [["sk-", "What is today's date?", AGENT_ON],
|
78 |
+
["sk-", "What is the weather in SF?", AGENT_ON]],
|
79 |
cache_examples = False)
|
80 |
|
81 |
demo.launch()
|