Spaces:
Paused
Paused
Download app.py from rr19tech/PLNB-Client: direct link, hf CLI and curl.
- Browser
- Download file 978 Bytes
-
https://huggingface.co/spaces/rr19tech/PLNB-Client/resolve/main/app.py
- Command line
-
hf download hf://spaces/rr19tech/PLNB-Client/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rr19tech/PLNB-Client/resolve/main/app.py
978 Bytes
| 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() |