Delete app.py
Browse files
app.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
-
import torch
|
| 4 |
-
|
| 5 |
-
# Load an open-source chatbot model from Hugging Face
|
| 6 |
-
MODEL_NAME = "openchat/openchat-3.5"
|
| 7 |
-
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 8 |
-
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, torch_dtype=torch.float16, device_map="auto")
|
| 9 |
-
|
| 10 |
-
def chat_response(user_input):
|
| 11 |
-
inputs = tokenizer(user_input, return_tensors="pt").to("cuda")
|
| 12 |
-
outputs = model.generate(**inputs, max_new_tokens=100)
|
| 13 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 14 |
-
return response
|
| 15 |
-
|
| 16 |
-
# Create the Gradio interface
|
| 17 |
-
iface = gr.Interface(
|
| 18 |
-
fn=chat_response,
|
| 19 |
-
inputs=gr.Textbox(placeholder="Ask me anything..."),
|
| 20 |
-
outputs="text",
|
| 21 |
-
title="Chatbot",
|
| 22 |
-
description="A simple chatbot powered by OpenChat-3.5"
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
# Launch the app
|
| 26 |
-
if __name__ == "__main__":
|
| 27 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|