Spaces:
Sleeping
Sleeping
Ganesh Chintalapati
commited on
Commit
·
76efecf
1
Parent(s):
40966a6
login
Browse files
core.py
CHANGED
|
@@ -39,8 +39,22 @@ async def submit_query(query, providers, history, user_id):
|
|
| 39 |
|
| 40 |
async 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]], List[Dict[str, str]]], None]:
|
| 41 |
try:
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
except Exception as e:
|
| 45 |
logger.error(f"Error in query_model: {e}")
|
| 46 |
yield f"Error: An unexpected error occurred. {e}", [], [], [], history
|
|
|
|
| 39 |
|
| 40 |
async 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]], List[Dict[str, str]]], None]:
|
| 41 |
try:
|
| 42 |
+
openai_msgs = history.copy()
|
| 43 |
+
anthropic_msgs = history.copy()
|
| 44 |
+
gemini_msgs = history.copy()
|
| 45 |
+
|
| 46 |
+
if "OpenAI" in providers:
|
| 47 |
+
# Replace with: openai_response = await ask_openai(query, history)
|
| 48 |
+
openai_msgs.append({"role": "assistant", "content": f"OpenAI echo: {query}"})
|
| 49 |
+
if "Anthropic" in providers:
|
| 50 |
+
# Replace with: anthropic_response = await ask_anthropic(query, history)
|
| 51 |
+
anthropic_msgs.append({"role": "assistant", "content": f"Anthropic echo: {query}"})
|
| 52 |
+
if "Gemini" in providers:
|
| 53 |
+
# Replace with: gemini_response = await ask_gemini(query, history)
|
| 54 |
+
gemini_msgs.append({"role": "assistant", "content": f"Gemini echo: {query}"})
|
| 55 |
+
|
| 56 |
+
updated_history = history + [{"role": "user", "content": query}]
|
| 57 |
+
yield "", openai_msgs, anthropic_msgs, gemini_msgs, updated_history
|
| 58 |
except Exception as e:
|
| 59 |
logger.error(f"Error in query_model: {e}")
|
| 60 |
yield f"Error: An unexpected error occurred. {e}", [], [], [], history
|