Spaces:
Runtime error
Runtime error
again new update
Browse files
app.py
CHANGED
@@ -1,25 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
# Load
|
5 |
-
|
6 |
-
|
7 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
|
|
|
9 |
def chatbot(input_text):
|
10 |
-
|
11 |
-
|
12 |
-
outputs = model.generate(inputs["input_ids"], max_length=200, pad_token_id=tokenizer.eos_token_id)
|
13 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
-
return response
|
15 |
|
16 |
-
# Create
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
title="Chat with Your Model"
|
22 |
-
)
|
23 |
|
24 |
-
#
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from llama_cpp import Llama
|
3 |
|
4 |
+
# Load the GGUF model
|
5 |
+
model_path = "model.gguf" # Ensure this matches your uploaded file name
|
6 |
+
llm = Llama(model_path=model_path)
|
|
|
7 |
|
8 |
+
# Define the chatbot function
|
9 |
def chatbot(input_text):
|
10 |
+
output = llm(prompt=input_text, max_tokens=200)
|
11 |
+
return output['choices'][0]['text']
|
|
|
|
|
|
|
12 |
|
13 |
+
# Create Gradio interface
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
chatbot_ui = gr.Chatbot()
|
16 |
+
textbox = gr.Textbox(label="Type your message here:")
|
17 |
+
submit = gr.Button("Send")
|
|
|
|
|
18 |
|
19 |
+
# Handle user interaction
|
20 |
+
def user_interaction(input_text, chat_history):
|
21 |
+
response = chatbot(input_text)
|
22 |
+
chat_history.append((input_text, response))
|
23 |
+
return chat_history, ""
|
24 |
+
|
25 |
+
submit.click(user_interaction, [textbox, chatbot_ui], [chatbot_ui, textbox])
|
26 |
+
|
27 |
+
demo.launch()
|