Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from llama_cpp import Llama
|
3 |
|
4 |
-
# Load the model directly from Hugging Face
|
5 |
MODEL_URL = "https://huggingface.co/TheBloke/Llama-2-7B-GGML/resolve/main/llama-7B.ggmlv3.q4_0.bin"
|
6 |
|
7 |
-
# Define OmniAI's chat function
|
8 |
-
def omni_ai_chat(
|
9 |
llm = Llama(model_path=MODEL_URL) # Load model dynamically
|
10 |
-
response = llm(
|
11 |
return response["choices"][0]["text"].strip()
|
12 |
|
13 |
-
# Set up Gradio chatbot UI
|
14 |
chatbot = gr.ChatInterface(fn=omni_ai_chat, title="OmniAI - Cloud AI",
|
15 |
-
description="Your personal AI assistant, running entirely in the cloud!"
|
|
|
16 |
|
17 |
# Launch the app!
|
18 |
chatbot.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from llama_cpp import Llama
|
3 |
|
4 |
+
# Load the model directly from Hugging Face’s cloud
|
5 |
MODEL_URL = "https://huggingface.co/TheBloke/Llama-2-7B-GGML/resolve/main/llama-7B.ggmlv3.q4_0.bin"
|
6 |
|
7 |
+
# Define OmniAI's chat function (handles two arguments: user message + history)
|
8 |
+
def omni_ai_chat(user_message, history):
|
9 |
llm = Llama(model_path=MODEL_URL) # Load model dynamically
|
10 |
+
response = llm(user_message) # Process only the latest prompt
|
11 |
return response["choices"][0]["text"].strip()
|
12 |
|
13 |
+
# Set up Gradio chatbot UI with correct formatting
|
14 |
chatbot = gr.ChatInterface(fn=omni_ai_chat, title="OmniAI - Cloud AI",
|
15 |
+
description="Your personal AI assistant, running entirely in the cloud!",
|
16 |
+
type="messages") # Fixes deprecated format warning
|
17 |
|
18 |
# Launch the app!
|
19 |
chatbot.launch()
|