SupermanRX commited on
Commit
3441cda
·
verified ·
1 Parent(s): 106bf91

chatbot file

Browse files
Files changed (1) hide show
  1. chatbot.py +25 -0
chatbot.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load your fine-tuned model
5
+ model_name = "SupermanRX/moderateTherapistModel" # Replace with your Hugging Face model path
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ def chatbot(input_text):
10
+ # Process user input and generate 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
+ # Create a Gradio interface
17
+ interface = gr.Interface(
18
+ fn=chatbot,
19
+ inputs="text",
20
+ outputs="text",
21
+ title="Chat with Your Model"
22
+ )
23
+
24
+ # Launch the Gradio app
25
+ interface.launch()