Spaces:
Runtime error
Runtime error
non quantized update
Browse files
app.py
CHANGED
@@ -1,34 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
|
|
8 |
|
9 |
-
# Download the model file to the local environment
|
10 |
-
model_path = hf_hub_download(repo_id=model_repo, filename=model_file)
|
11 |
-
|
12 |
-
# Load the GGUF model
|
13 |
-
llm = Llama(model_path=model_path)
|
14 |
-
|
15 |
-
# Define the chatbot function
|
16 |
def chatbot(input_text):
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
#
|
21 |
with gr.Blocks() as demo:
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
def user_interaction(input_text, chat_history):
|
28 |
-
response = chatbot(input_text)
|
29 |
-
chat_history.append((input_text, response))
|
30 |
-
return chat_history, ""
|
31 |
-
|
32 |
-
submit.click(user_interaction, [textbox, chatbot_ui], [chatbot_ui, textbox])
|
33 |
-
|
34 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
3 |
|
4 |
+
# Load your fine-tuned model
|
5 |
+
model_name = "SupermanRX/therapistAi" # Replace with your model's Hugging Face path
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
def chatbot(input_text):
|
10 |
+
# Generate a response
|
11 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
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 |
+
# Use the default chatbot interface
|
17 |
with gr.Blocks() as demo:
|
18 |
+
gr.Chatbot().style(height=600).chat(
|
19 |
+
chatbot,
|
20 |
+
placeholder="Type your message here...",
|
21 |
+
show_label=False
|
22 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
demo.launch()
|