krishna-k commited on
Commit
ad716e2
·
verified ·
1 Parent(s): 096fa26

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForCausalLM
2
+ from transformers import pipeline
3
+ import gradio as gr
4
+
5
+ # messages = [
6
+ # {"role": "user", "content": "Who are you?"},
7
+ # ]
8
+ # pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-3B-Instruct")
9
+ # pipe(messages)
10
+ chatbot = pipeline("conversational", model="microsoft/DialoGPT-medium")
11
+
12
+ # tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
13
+ # model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
14
+
15
+ def chat_with_bot(user_input):
16
+ # Generate a response from the chatbot model
17
+ response = chatbot(user_input)
18
+ return response[0]['generated_text']
19
+
20
+ interface = gr.Interface(
21
+ fn=chat_with_bot, # Function to call for processing the input
22
+ inputs=gr.Textbox(label="Enter your message"), # User input (text)
23
+ outputs=gr.Textbox(label="Chatbot Response"), # Model output (text)
24
+ title="Chat with DialoGPT", # Optional: Add a title to your interface
25
+ description="Chat with an AI model powered by DialoGPT!" # Optional: Add a description
26
+ )
27
+
28
+ interface.launch()