SupermanRX commited on
Commit
279939d
·
verified ·
1 Parent(s): aa9109c

non quantized update

Browse files
Files changed (1) hide show
  1. app.py +16 -27
app.py CHANGED
@@ -1,34 +1,23 @@
1
  import gradio as gr
2
- from llama_cpp import Llama
3
- from huggingface_hub import hf_hub_download
4
 
5
- # Fetch the model file from Hugging Face Hub
6
- model_repo = "SupermanRX/moderateTherapistModel" # Replace with your repo name
7
- model_file = "unsloth.Q8_0.gguf" # Replace with your GGUF model file name in the repo
 
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
- output = llm(prompt=input_text, max_tokens=200)
18
- return output['choices'][0]['text']
 
 
 
19
 
20
- # Create Gradio interface
21
  with gr.Blocks() as demo:
22
- chatbot_ui = gr.Chatbot()
23
- textbox = gr.Textbox(label="Type your message here:")
24
- submit = gr.Button("Send")
25
-
26
- # Handle user interaction
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()