Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
from langchain.agents import load_tools, initialize_agent
|
3 |
from langchain.agents import AgentType
|
4 |
-
from
|
5 |
import os
|
6 |
|
7 |
# Set your OpenAI API key (ensure to store it securely in Hugging Face Spaces environment variables)
|
8 |
-
#os.environ["OPENAI_API_KEY"] = "your_openai_api_key"
|
9 |
import warnings
|
10 |
warnings.filterwarnings("ignore", message=".*TqdmWarning.*")
|
11 |
from dotenv import load_dotenv
|
@@ -37,14 +37,6 @@ def chatbot(query):
|
|
37 |
return str(e)
|
38 |
|
39 |
# Create Gradio interface
|
40 |
-
#demo = gr.Interface(
|
41 |
-
#fn=chatbot,
|
42 |
-
#inputs=gr.Textbox(placeholder="Ask me anything..."),
|
43 |
-
#outputs="text",
|
44 |
-
#title="LangChain Agent Chatbot",
|
45 |
-
#description="An interactive chatbot powered by LangChain, OpenAI, and external tools."
|
46 |
-
#)
|
47 |
-
|
48 |
demo = gr.Interface(
|
49 |
fn=chatbot,
|
50 |
inputs=gr.Textbox(label="Your Question", placeholder="Ask me anything..."),
|
@@ -54,6 +46,5 @@ demo = gr.Interface(
|
|
54 |
theme="compact"
|
55 |
)
|
56 |
|
57 |
-
|
58 |
# Launch the app
|
59 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from langchain.agents import load_tools, initialize_agent
|
3 |
from langchain.agents import AgentType
|
4 |
+
from langchain_community.chat_models import ChatOpenAI # Updated import
|
5 |
import os
|
6 |
|
7 |
# Set your OpenAI API key (ensure to store it securely in Hugging Face Spaces environment variables)
|
8 |
+
# os.environ["OPENAI_API_KEY"] = "your_openai_api_key"
|
9 |
import warnings
|
10 |
warnings.filterwarnings("ignore", message=".*TqdmWarning.*")
|
11 |
from dotenv import load_dotenv
|
|
|
37 |
return str(e)
|
38 |
|
39 |
# Create Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
demo = gr.Interface(
|
41 |
fn=chatbot,
|
42 |
inputs=gr.Textbox(label="Your Question", placeholder="Ask me anything..."),
|
|
|
46 |
theme="compact"
|
47 |
)
|
48 |
|
|
|
49 |
# Launch the app
|
50 |
+
demo.launch()
|