bincoder commited on
Commit
70fc16f
·
verified ·
1 Parent(s): 972b905

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,2 +1,24 @@
1
  import gradio as gr
2
- gr.load_chat("http://96.228.37.139:4002/v1/", model="mistral-small", token="ollama").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import ollama # Ensure ollama is available in your Space
3
+
4
+ # Define chat function
5
+ def chat_with_model(message, history):
6
+ try:
7
+ response = ollama.chat(
8
+ model="mistral-small",
9
+ messages=[{"role": "user", "content": message}]
10
+ )
11
+ return response['message']['content']
12
+ except Exception as e:
13
+ return f"Error: {str(e)}"
14
+
15
+ # Define Gradio Chat Interface
16
+ chatbot = gr.ChatInterface(
17
+ chat_with_model,
18
+ title="Mistral AI Chatbot",
19
+ description="Chat with Mistral-Small using Ollama on Hugging Face Spaces.",
20
+ )
21
+
22
+ # Launch the Gradio app
23
+ if __name__ == "__main__":
24
+ chatbot.launch()