summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Copilot.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider/Copilot.py')
-rw-r--r--g4f/Provider/Copilot.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/g4f/Provider/Copilot.py b/g4f/Provider/Copilot.py
index e8eea0a5..e10a55e8 100644
--- a/g4f/Provider/Copilot.py
+++ b/g4f/Provider/Copilot.py
@@ -57,6 +57,7 @@ class Copilot(AbstractProvider):
image: ImageType = None,
conversation: Conversation = None,
return_conversation: bool = False,
+ web_search: bool = True,
**kwargs
) -> CreateResult:
if not has_curl_cffi:
@@ -124,12 +125,14 @@ class Copilot(AbstractProvider):
is_started = False
msg = None
image_prompt: str = None
+ last_msg = None
while True:
try:
msg = wss.recv()[0]
msg = json.loads(msg)
except:
break
+ last_msg = msg
if msg.get("event") == "appendText":
is_started = True
yield msg.get("text")
@@ -139,8 +142,12 @@ class Copilot(AbstractProvider):
yield ImageResponse(msg.get("url"), image_prompt, {"preview": msg.get("thumbnailUrl")})
elif msg.get("event") == "done":
break
+ elif msg.get("event") == "error":
+ raise RuntimeError(f"Error: {msg}")
+ elif msg.get("event") not in ["received", "startMessage", "citation", "partCompleted"]:
+ debug.log(f"Copilot Message: {msg}")
if not is_started:
- raise RuntimeError(f"Last message: {msg}")
+ raise RuntimeError(f"Invalid response: {last_msg}")
@classmethod
async def get_access_token_and_cookies(cls, proxy: str = None):