summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing/conversation.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-14 15:32:51 +0100
committerGitHub <noreply@github.com>2024-01-14 15:32:51 +0100
commit1ca80ed48b55d6462b4bd445e66d4f7de7442c2b (patch)
tree05a94b53b83461b8249de965e093b4fd3722e2d1 /g4f/Provider/bing/conversation.py
parentMerge pull request #1466 from hlohaus/upp (diff)
parentChange doctypes style to Google (diff)
downloadgpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.tar
gpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.tar.gz
gpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.tar.bz2
gpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.tar.lz
gpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.tar.xz
gpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.tar.zst
gpt4free-1ca80ed48b55d6462b4bd445e66d4f7de7442c2b.zip
Diffstat (limited to 'g4f/Provider/bing/conversation.py')
-rw-r--r--g4f/Provider/bing/conversation.py44
1 files changed, 42 insertions, 2 deletions
diff --git a/g4f/Provider/bing/conversation.py b/g4f/Provider/bing/conversation.py
index 9e011c26..36ada3b0 100644
--- a/g4f/Provider/bing/conversation.py
+++ b/g4f/Provider/bing/conversation.py
@@ -1,13 +1,33 @@
from aiohttp import ClientSession
-
-class Conversation():
+class Conversation:
+ """
+ Represents a conversation with specific attributes.
+ """
def __init__(self, conversationId: str, clientId: str, conversationSignature: str) -> None:
+ """
+ Initialize a new conversation instance.
+
+ Args:
+ conversationId (str): Unique identifier for the conversation.
+ clientId (str): Client identifier.
+ conversationSignature (str): Signature for the conversation.
+ """
self.conversationId = conversationId
self.clientId = clientId
self.conversationSignature = conversationSignature
async def create_conversation(session: ClientSession, proxy: str = None) -> Conversation:
+ """
+ Create a new conversation asynchronously.
+
+ Args:
+ session (ClientSession): An instance of aiohttp's ClientSession.
+ proxy (str, optional): Proxy URL. Defaults to None.
+
+ Returns:
+ Conversation: An instance representing the created conversation.
+ """
url = 'https://www.bing.com/turing/conversation/create?bundleVersion=1.1199.4'
async with session.get(url, proxy=proxy) as response:
try:
@@ -24,12 +44,32 @@ async def create_conversation(session: ClientSession, proxy: str = None) -> Conv
return Conversation(conversationId, clientId, conversationSignature)
async def list_conversations(session: ClientSession) -> list:
+ """
+ List all conversations asynchronously.
+
+ Args:
+ session (ClientSession): An instance of aiohttp's ClientSession.
+
+ Returns:
+ list: A list of conversations.
+ """
url = "https://www.bing.com/turing/conversation/chats"
async with session.get(url) as response:
response = await response.json()
return response["chats"]
async def delete_conversation(session: ClientSession, conversation: Conversation, proxy: str = None) -> bool:
+ """
+ Delete a conversation asynchronously.
+
+ Args:
+ session (ClientSession): An instance of aiohttp's ClientSession.
+ conversation (Conversation): The conversation to delete.
+ proxy (str, optional): Proxy URL. Defaults to None.
+
+ Returns:
+ bool: True if deletion was successful, False otherwise.
+ """
url = "https://sydney.bing.com/sydney/DeleteSingleConversation"
json = {
"conversationId": conversation.conversationId,