Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,41 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from llama_cpp import Llama
|
3 |
|
4 |
# Load the Llama model
|
5 |
-
llm = Llama.from_pretrained(
|
6 |
-
|
7 |
-
|
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 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Create a Gradio interface
|
26 |
iface = gr.Interface(
|
27 |
-
fn=
|
28 |
inputs="textbox",
|
29 |
outputs="text",
|
30 |
title="AIML Q&A Chatbot",
|
|
|
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="QA_llama31_unsloth.Q4_K_M.gguf",
|
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 |
+
from transformers import pipeline
|
26 |
+
|
27 |
+
# Replace with your Hugging Face model space URL
|
28 |
+
model_id = "GSridhar1982/AIML_QA_Llama31_FineTuned_UsingLora"
|
29 |
+
|
30 |
+
pipe = pipeline("text2text-generation", model=model_id)
|
31 |
+
|
32 |
+
def generate_text(prompt):
|
33 |
+
"""Generates text using the loaded Hugging Face model."""
|
34 |
+
return pipe(prompt)[0]['generated_text']
|
35 |
+
|
36 |
# Create a Gradio interface
|
37 |
iface = gr.Interface(
|
38 |
+
fn=generate_text,
|
39 |
inputs="textbox",
|
40 |
outputs="text",
|
41 |
title="AIML Q&A Chatbot",
|