rr19tech commited on
Commit
d7553bf
·
verified ·
1 Parent(s): 1096aef

Created app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_client import Client
3
+
4
+
5
+ API_URL = "https://huggingface.co/spaces/rr19tech/PLNB-Model"
6
+ client = Client(API_URL)
7
+
8
+ # 2. Our "Static" Context
9
+ STATIC_CONTEXT = """
10
+ PLNB breakfast menu consists of idly, dosa
11
+ PLNB lunch menu consistes of dal, rice, roti and curry
12
+ PLNB dinner menu consists of roti and kheer
13
+ """
14
+
15
+ def test_rag_client(question, history):
16
+ # Construct the prompt with the static context
17
+ prompt = f"""Use the provided context to answer the question.
18
+ Context: {STATIC_CONTEXT}
19
+ Question: {question}
20
+ Answer:"""
21
+
22
+ try:
23
+ # Call the backend API
24
+ # Ensure your backend uses gr.Interface(fn=chat_api, ...) for /predict
25
+ result = client.predict(message=prompt, api_name="/chat")
26
+ return result
27
+ except Exception as e:
28
+ return f"Backend Error: {str(e)}"
29
+
30
+ # Simple UI to test the context
31
+ demo = gr.ChatInterface(
32
+ fn=test_rag_client,
33
+ title="Static Context Test",
34
+ description="Ask PLNB menu questions"
35
+ )
36
+
37
+ demo.launch()