File size: 882 Bytes
f40f6ca
e81731d
 
 
 
7d25ed6
 
e81731d
 
 
 
7d25ed6
e81731d
 
7d25ed6
 
e81731d
7d25ed6
 
e81731d
 
7d25ed6
e81731d
 
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
import gradio as gr
from rag import respond_rag_ollama  # Your custom RAG function using Ollama

history = []

def respond(message, chat_history, temperature=0.5, max_tokens=512  ):
    response = respond_rag_ollama(message, temperature=temperature,num_predict=max_tokens)  # send only message & temperature
    chat_history.append((message, response))
    return "", chat_history

with gr.Blocks() as demo:
    gr.Markdown("# Game of Thrones Q&A bot")

    chatbot = gr.Chatbot()
    msg = gr.Textbox(label="Tell me something about 7 kingdoms")

    temp = gr.Slider(0.0, 1.0, value=0.5, label="Temperature")
    max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")

    clear = gr.Button("Clear")

    msg.submit(respond, [msg, chatbot, temp, max_tokens], [msg, chatbot])
    clear.click(lambda: ([], ""), None, [chatbot, msg])
demo.launch()