Spaces:
Sleeping
Sleeping
NexusBridge Deployer commited on
Commit ·
9d60c14
1
Parent(s): 243342e
Deploy NexusBridge Ultra
Browse filesFiles changed (3)
41 unmodified lines424344454647484941 unmodified lineselse:full_content = ""async for chunk in provider.chat_completion(request.messages, stream=False):if "choices" in chunk and "delta" in chunk["choices"][0]:full_content += chunk["choices"][0]["delta"]["content"]return {"id": "nexus-123",41 unmodified lines424344454647484950515253545541 unmodified lineselse:full_content = ""async for chunk in provider.chat_completion(request.messages, stream=False):if "choices" in chunk and len(chunk["choices"]) > 0:choice = chunk["choices"][0]if "delta" in choice and "content" in choice["delta"]:full_content += choice["delta"]["content"]elif "message" in choice and "content" in choice["message"]:full_content += choice["message"]["content"]elif "error" in chunk:raise HTTPException(status_code=500, detail=chunk["error"])return {"id": "nexus-123",
67 unmodified lines686970717273742 unmodified lines777879808182838467 unmodified linesif not self.initialized: await self.initialize()async with self.lock:prompt = messages[-1].contenttry:# 1. Clear and Fill the input# The selector for Gemini's input is typically a contenteditable div2 unmodified lines# Format messages for Geminiformatted_messages = []for msg in messages:role = "user" if msg.role == "user" else "model"formatted_messages.append({"role": role, "parts": [msg.content]})await self.page.fill(input_selector, prompt)67 unmodified lines686970717273747576772 unmodified lines80818283848586878867 unmodified linesif not self.initialized: await self.initialize()async with self.lock:# Handle both object and dict styleslast_msg = messages[-1]prompt = last_msg.content if hasattr(last_msg, 'content') else last_msg.get('content', '')try:# 1. Clear and Fill the input# The selector for Gemini's input is typically a contenteditable div2 unmodified lines# Format messages for Geminiformatted_messages = []for msg in messages:role = "user" if (msg.role if hasattr(msg, 'role') else msg.get('role', 'user')) == "user" else "model"content = msg.content if hasattr(msg, 'content') else msg.get('content', '')formatted_messages.append({"role": role, "parts": [content]})await self.page.fill(input_selector, prompt)
77 unmodified lines7879808182838477 unmodified linesasync def chat_completion(self, messages: list, stream: bool = False) -> AsyncGenerator[Dict[str, Any], None]:if not self.initialized: await self.initialize()async with self.lock:prompt = messages[-1].contenttry:# 1. Wait for input and typeinput_selector = 'textarea[placeholder*="Grok"], textarea[placeholder*="Ask"]'77 unmodified lines787980818283848577 unmodified linesasync def chat_completion(self, messages: list, stream: bool = False) -> AsyncGenerator[Dict[str, Any], None]:if not self.initialized: await self.initialize()async with self.lock:last_msg = messages[-1]prompt = last_msg.content if hasattr(last_msg, 'content') else last_msg.get('content', '')try:# 1. Wait for input and typeinput_selector = 'textarea[placeholder*="Grok"], textarea[placeholder*="Ask"]'
app/api/v1/chat.py+8-2
app/providers/gemini_web.py+7-3
app/providers/grok_web.py+2-1