testSpace2 / app.py
SupermanRX's picture
again new update
3472271 verified
raw
history blame
802 Bytes
import gradio as gr
from llama_cpp import Llama
# Load the GGUF model
model_path = "model.gguf" # Ensure this matches your uploaded file name
llm = Llama(model_path=model_path)
# Define the chatbot function
def chatbot(input_text):
output = llm(prompt=input_text, max_tokens=200)
return output['choices'][0]['text']
# Create Gradio interface
with gr.Blocks() as demo:
chatbot_ui = gr.Chatbot()
textbox = gr.Textbox(label="Type your message here:")
submit = gr.Button("Send")
# Handle user interaction
def user_interaction(input_text, chat_history):
response = chatbot(input_text)
chat_history.append((input_text, response))
return chat_history, ""
submit.click(user_interaction, [textbox, chatbot_ui], [chatbot_ui, textbox])
demo.launch()