Spaces:
Sleeping
Sleeping
Commit ·
76f07e5
1
Parent(s): 6b79d5e
fix
Browse files
app.py
CHANGED
|
@@ -103,7 +103,8 @@ def build_llm_prompt(system: str, context: list[str], user_question: str) -> str
|
|
| 103 |
prompt += f"[INST] {content.strip()} [/INST]\n"
|
| 104 |
elif role == "assistant":
|
| 105 |
prompt += f"{content.strip()}\n"
|
| 106 |
-
return prompt
|
|
|
|
| 107 |
|
| 108 |
# ---------- 4. Gradio playground (same UI as before) --------------------------
|
| 109 |
def store_doc(doc_text: str, user_id="demo"):
|
|
@@ -218,6 +219,18 @@ with gr.Blocks() as demo:
|
|
| 218 |
outputs=answer_box
|
| 219 |
)
|
| 220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
# ---------- 5. run both (FastAPI + Gradio) -----------------------------------
|
| 222 |
if __name__ == "__main__":
|
| 223 |
# launch Gradio on a background thread
|
|
|
|
| 103 |
prompt += f"[INST] {content.strip()} [/INST]\n"
|
| 104 |
elif role == "assistant":
|
| 105 |
prompt += f"{content.strip()}\n"
|
| 106 |
+
return prompt
|
| 107 |
+
|
| 108 |
|
| 109 |
# ---------- 4. Gradio playground (same UI as before) --------------------------
|
| 110 |
def store_doc(doc_text: str, user_id="demo"):
|
|
|
|
| 219 |
outputs=answer_box
|
| 220 |
)
|
| 221 |
|
| 222 |
+
# ---------- 3. FastAPI layer --------------------------------------------------
|
| 223 |
+
class IngestReq(BaseModel):
|
| 224 |
+
user_id:str
|
| 225 |
+
docs:list[str]
|
| 226 |
+
|
| 227 |
+
class QueryReq(BaseModel):
|
| 228 |
+
user_id:str
|
| 229 |
+
question:str
|
| 230 |
+
|
| 231 |
+
api = FastAPI()
|
| 232 |
+
api = gr.mount_gradio_app(api, demo, path="/")
|
| 233 |
+
|
| 234 |
# ---------- 5. run both (FastAPI + Gradio) -----------------------------------
|
| 235 |
if __name__ == "__main__":
|
| 236 |
# launch Gradio on a background thread
|