Spaces:
Build error
Build error
Ganesh Chintalapati commited on
Commit ·
a3ce268
1
Parent(s): 5925c4b
modular code apsssjjj
Browse files3 unmodified lines4567891081 unmodified lines929394959697984 unmodified lines1031041051061071081091101111121131141151161171181191201213 unmodified linesfrom config import loggerfrom api import ask_openai, ask_anthropic, ask_geminiasync def query_model(query: str, providers: List[str], history: List[Dict[str, str]]) -> AsyncGenerator[Tuple[str, List[Dict[str, str]], List[Dict[str, str]], List[Dict[str, str]]], None]:logger.info(f"Processing query with providers: {providers}")openai_response = ""anthropic_response = ""81 unmodified linesgemini_response = responsegemini_messages = messageslogger.info(f"Yielding update for {provider}: {response[:50]}...")yield "", openai_messages, anthropic_messages, gemini_messagesnew_generator_states[new_generator_states.index((provider, gen, task))] = (provider, gen, None)except StopAsyncIteration:logger.info(f"Generator for {provider} completed")4 unmodified linesactive_generators = new_generator_statesresponses = []if openai_response.strip() and not openai_response.startswith("Error:"):responses.append(f"[OpenAI]: {openai_response}")if anthropic_response.strip() and not anthropic_response.startswith("Error:"):responses.append(f"[Anthropic]: {anthropic_response}")if gemini_response.strip() and not gemini_response.startswith("Error:"):responses.append(f"[Gemini]: {gemini_response}")combined_response = "\n\n".join(responses) if responses else "No valid responses received."updated_history = history + [{"user": query, "bot": combined_response}]logger.info(f"Updated history: {updated_history}")yield combined_response, openai_messages, anthropic_messages, gemini_messagesasync def submit_query(query: str, providers: List[str], history: List[Dict[str, str]]) -> AsyncGenerator[Tuple[str, List[Dict[str, str]], List[Dict[str, str]], List[Dict[str, str]], List[Dict[str, str]]], None]:3 unmodified lines4567891081 unmodified lines929394959697984 unmodified lines1031041051061071081091101111121131141151161171181191203 unmodified linesfrom config import loggerfrom api import ask_openai, ask_anthropic, ask_geminiasync def query_model(query: str, providers: List[str], history: List[Dict[str, str]]) -> AsyncGenerator[Tuple[str, str, List[Dict[str, str]], List[Dict[str, str]], List[Dict[str, str]]], None]:logger.info(f"Processing query with providers: {providers}")openai_response = ""anthropic_response = ""81 unmodified linesgemini_response = responsegemini_messages = messageslogger.info(f"Yielding update for {provider}: {response[:50]}...")yield response, openai_messages, anthropic_messages, gemini_messagesnew_generator_states[new_generator_states.index((provider, gen, task))] = (provider, gen, None)except StopAsyncIteration:logger.info(f"Generator for {provider} completed")4 unmodified linesactive_generators = new_generator_statescombined_response = ""if openai_response.strip() and not openai_response.startswith("Error:"):combined_response += f"[OpenAI]: {openai_response}\n\n"if anthropic_response.strip() and not anthropic_response.startswith("Error:"):combined_response += f"[Anthropic]: {anthropic_response}\n\n"if gemini_response.strip() and not gemini_response.startswith("Error:"):combined_response += f"[Gemini]: {gemini_response}"updated_history = history + [{"user": query, "bot": combined_response.strip()}]logger.info(f"Updated history: {updated_history}")yield combined_response.strip(), openai_messages, anthropic_messages, gemini_messagesasync def submit_query(query: str, providers: List[str], history: List[Dict[str, str]]) -> AsyncGenerator[Tuple[str, List[Dict[str, str]], List[Dict[str, str]], List[Dict[str, str]], List[Dict[str, str]]], None]:
core.py+8-9