Spaces:
Runtime error
Runtime error
Ganesh Chintalapati commited on
Commit ·
fac7191
1
Parent(s): 128373b
Fix syntaxerror
Browse files45 unmodified lines4647484949505152119 unmodified lines17217317417517617717717817917918018118218318418518618518718818919045 unmodified lines async 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(): 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 response updated_history = history + [{"user": query, "bot": response}] logger.info(f"Updated history: {updated_history}") yield response, updated_history # Final yield with updated history
async def submit_query(query: str, provider: str, history: List[Dict[str, str]]) -> Tuple[str, List[Dict[str, str]], List[Dict[str, str]]]:async 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(): return "", history, history yield "", history, history return response = "" async for response_chunk, updated_history in query_model(query, provider, history): response += response_chunk yield "", updated_history, updated_history # Yield intermediate updates for streaming return "", updated_history, updated_history # Final return with cleared query yield "", updated_history, updated_history # Final yield with cleared query
# Gradio interfacedef clear_history():app.py+6-4