File size: 802 Bytes
3441cda
3472271
3441cda
3472271
 
 
3441cda
3472271
3441cda
3472271
 
3441cda
3472271
 
 
 
 
3441cda
3472271
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()