Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files123367 unmodified lines37137237337437537626 unmodified lines403404405406407408409import gradio as grimport osimport json367 unmodified lineshistory: Optional[List[Dict[str, str]]] = None@app.post("/api/chat")async def chat_with_ai(req: ChatRequest):if QA_CHAIN is None or LLM is None:raise HTTPException(status_code=500, detail="Local AI Model is not initialized.")26 unmodified lines{req.message}<|im_end|><|im_start|>assistant"""response = LLM.invoke(chat_prompt)text_output = str(getattr(response, "content", response)).strip()# Clean up tags if the model leaks them1234367 unmodified lines37237337437537637737837938038138226 unmodified lines409410411412413414415import spacesimport gradio as grimport osimport json367 unmodified lineshistory: Optional[List[Dict[str, str]]] = None@app.post("/api/chat")@spaces.GPUdef generate_response(prompt):return LLM.invoke(prompt)async def chat_with_ai(req: ChatRequest):if QA_CHAIN is None or LLM is None:raise HTTPException(status_code=500, detail="Local AI Model is not initialized.")26 unmodified lines{req.message}<|im_end|><|im_start|>assistant"""response = generate_response(chat_prompt)text_output = str(getattr(response, "content", response)).strip()# Clean up tags if the model leaks them
app.py+7-1