File size: 978 Bytes
d7553bf
 
 
 
b55e7ff
d7553bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
import gradio as gr
from gradio_client import Client


API_URL = "rr19tech/PLNB-Model-SMOL"
client = Client(API_URL)

# 2. Our "Static" Context
STATIC_CONTEXT = """
PLNB breakfast menu consists of idly, dosa
PLNB lunch menu consistes of dal, rice, roti and curry
PLNB dinner menu consists of roti and kheer
"""

def test_rag_client(question, history):
    # Construct the prompt with the static context
    prompt = f"""Use the provided context to answer the question.
Context: {STATIC_CONTEXT}
Question: {question}
Answer:"""

    try:
        # Call the backend API
        # Ensure your backend uses gr.Interface(fn=chat_api, ...) for /predict
        result = client.predict(message=prompt, api_name="/chat")
        return result
    except Exception as e:
        return f"Backend Error: {str(e)}"

# Simple UI to test the context
demo = gr.ChatInterface(
    fn=test_rag_client, 
    title="Static Context Test",
    description="Ask PLNB menu questions"
)

demo.launch()