Spaces:
Sleeping
Sleeping
Updated the script
Browse files
app.py
CHANGED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from llama_cpp import Llama
|
3 |
+
|
4 |
+
# Load the Llama model
|
5 |
+
llm = Llama.from_pretrained(
|
6 |
+
repo_id="GSridhar1982/QA_Llama31_Quantized_GGUF",
|
7 |
+
filename="GGUF_FILE",
|
8 |
+
)
|
9 |
+
|
10 |
+
def generate_response(user_input):
|
11 |
+
# Perform inference
|
12 |
+
response = llm.create_chat_completion(
|
13 |
+
messages=[
|
14 |
+
{
|
15 |
+
"role": "user",
|
16 |
+
"content": user_input
|
17 |
+
}
|
18 |
+
]
|
19 |
+
)
|
20 |
+
|
21 |
+
# Extract the model's reply
|
22 |
+
model_reply = response['choices'][0]['message']['content']
|
23 |
+
return model_reply
|
24 |
+
|
25 |
+
# Create a Gradio interface
|
26 |
+
iface = gr.Interface(
|
27 |
+
fn=generate_response,
|
28 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your question here..."),
|
29 |
+
outputs="text",
|
30 |
+
title="AIML Q&A Chatbot",
|
31 |
+
description="Ask questions related to AIML and get answers from the fine-tuned Llama model."
|
32 |
+
)
|
33 |
+
|
34 |
+
# Launch the app
|
35 |
+
iface.launch()
|