Alexander Hux commited on
Commit
7fd5795
·
verified ·
1 Parent(s): 62ca88e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize your chatbot model here with LLaMA-2
5
+ model_name = "Llama-2-7b" # Adjust this to the specific variant of LLaMA-2 you wish to use
6
+ chatbot = pipeline("text-generation", model=model_name, use_auth_token="your_hugging_face_token_here")
7
+
8
+ def chat_with_bot(user_input):
9
+ # Generating a response from the chatbot model
10
+ responses = chatbot(user_input, max_length=50, num_return_sequences=1)
11
+ return responses[0]["generated_text"]
12
+
13
+ # Setting up the Gradio interface
14
+ iface = gr.Interface(fn=chat_with_bot,
15
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Type your question here..."),
16
+ outputs="text",
17
+ title="Advanced Chatbot",
18
+ description="This is an advanced chatbot powered by LLaMA-2. Type your question and get an answer.")
19
+
20
+ if __name__ == "__main__":
21
+ iface.launch()