Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from langchain.chat_models import ChatOpenAI
|
3 |
-
!pip install groq
|
4 |
-
!pip install langchain-groq
|
5 |
-
!pip install langchain
|
6 |
-
!pip install gradio
|
7 |
-
!pip install huggingface_hub
|
8 |
-
!pip install langchain-community
|
9 |
-
from langchain.chat_models import ChatOpenAI
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
|
|
|
|
|
|
14 |
|
|
|
|
|
|
|
15 |
|
16 |
with gr.Blocks() as iface:
|
17 |
-
|
18 |
gr.Markdown("# Mr AI")
|
19 |
gr.Markdown("Hi there! I'm your friendly assistant. Ask me anything, and I'll do my best to help! (By Thirumoorthi.A)")
|
20 |
|
21 |
chat_history_output = gr.Chatbot(label="Chat History", height=400)
|
22 |
|
23 |
-
|
24 |
with gr.Row():
|
25 |
message_input = gr.Textbox(label="Your Question", placeholder="Type your question here...", lines=2)
|
26 |
submit_btn = gr.Button("Submit")
|
@@ -28,19 +22,17 @@ with gr.Blocks() as iface:
|
|
28 |
|
29 |
def respond(message, chat_history):
|
30 |
chat_history.append(("USER", message))
|
31 |
-
response
|
|
|
|
|
|
|
32 |
chat_history.append(("Assistant", response))
|
33 |
return "", chat_history
|
34 |
|
35 |
-
|
36 |
def clear_chat():
|
37 |
return []
|
38 |
|
39 |
-
|
40 |
-
|
41 |
submit_btn.click(respond, inputs=[message_input, chat_history_output], outputs=[message_input, chat_history_output])
|
42 |
clear_btn.click(clear_chat, outputs=chat_history_output)
|
43 |
-
|
44 |
|
45 |
iface.launch()
|
46 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from langchain.chat_models import ChatOpenAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
# Ensure you have the necessary imports and installations
|
5 |
+
# If you're using Groq AI, make sure to import it correctly
|
6 |
+
# from groq import Groq # Uncomment if using Groq
|
7 |
|
8 |
+
# Initialize your model here (ensure you have the correct model setup)
|
9 |
+
# For example, if using Groq:
|
10 |
+
# client = Groq(api_key="YOUR_API_KEY")
|
11 |
|
12 |
with gr.Blocks() as iface:
|
|
|
13 |
gr.Markdown("# Mr AI")
|
14 |
gr.Markdown("Hi there! I'm your friendly assistant. Ask me anything, and I'll do my best to help! (By Thirumoorthi.A)")
|
15 |
|
16 |
chat_history_output = gr.Chatbot(label="Chat History", height=400)
|
17 |
|
|
|
18 |
with gr.Row():
|
19 |
message_input = gr.Textbox(label="Your Question", placeholder="Type your question here...", lines=2)
|
20 |
submit_btn = gr.Button("Submit")
|
|
|
22 |
|
23 |
def respond(message, chat_history):
|
24 |
chat_history.append(("USER", message))
|
25 |
+
# Replace this line with your model's response logic
|
26 |
+
response = "This is a placeholder response." # Replace with actual model call
|
27 |
+
# If using Groq, it might look like:
|
28 |
+
# response = client.chat.completions.create(messages=[{"role": "user", "content": message}])
|
29 |
chat_history.append(("Assistant", response))
|
30 |
return "", chat_history
|
31 |
|
|
|
32 |
def clear_chat():
|
33 |
return []
|
34 |
|
|
|
|
|
35 |
submit_btn.click(respond, inputs=[message_input, chat_history_output], outputs=[message_input, chat_history_output])
|
36 |
clear_btn.click(clear_chat, outputs=chat_history_output)
|
|
|
37 |
|
38 |
iface.launch()
|
|