Spaces:
Runtime error
Runtime error
Ganesh Chintalapati commited on
Commit ·
fac7191
1
Parent(s): 128373b
Fix syntaxerror
Browse files45 unmodified lines46474849505152119 unmodified lines17217317417517617717817918018118218318418518618718845 unmodified linesasync with httpx.AsyncClient() as client:async with client.stream("POST", "https://api.openai.com/v1/chat/completions", headers=headers, json=payload) as response:response.raise_for_status()async for chunk in response.aiter_text():if chunk:# Parse the streaming chunk (JSON lines)lines = chunk.splitlines()119 unmodified lines# Update history with the new query and responseupdated_history = history + [{"user": query, "bot": response}]yield response, updated_history # Final yield with updated historyasync def submit_query(query: str, provider: str, history: List[Dict[str, str]]) -> Tuple[str, List[Dict[str, str]], List[Dict[str, str]]]:if not query.strip():return "", history, historyresponse = ""async for response_chunk, updated_history in query_model(query, provider, history):response += response_chunkyield "", updated_history, updated_history # Yield intermediate updates for streamingreturn "", updated_history, updated_history # Final return with cleared query# Gradio interfacedef clear_history():45 unmodified lines46474849505152119 unmodified lines17217317417517617717817918018118218318418518618718818919045 unmodified linesasync with httpx.AsyncClient() as client:async with client.stream("POST", "https://api.openai.com/v1/chat/completions", headers=headers, json=payload) as response:response.raise_for_status()async for chunk in response.intro_text():if chunk:# Parse the streaming chunk (JSON lines)lines = chunk.splitlines()119 unmodified lines# Update history with the new query and responseupdated_history = history + [{"user": query, "bot": response}]logger.info(f"Updated history: {updated_history}")yield response, updated_history # Final yield with updated historyasync def submit_query(query: str, provider: str, history: List[Dict[str, str]]) -> AsyncGenerator[Tuple[str, List[Dict[str, str]], List[Dict[str, str]]], None]:if not query.strip():yield "", history, historyreturnresponse = ""async for response_chunk, updated_history in query_model(query, provider, history):response += response_chunkyield "", updated_history, updated_history # Yield intermediate updates for streamingyield "", updated_history, updated_history # Final yield with cleared query# Gradio interfacedef clear_history():
app.py+6-4