Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bing #1444

Merged
merged 2 commits into from
Jan 10, 2024
Merged

Bing #1444

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion g4f/Provider/Bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ async def stream_generate(
cookies: dict = None,
web_search: bool = False,
gpt4_turbo: bool = False,
timeout = int = 900
timeout: int = 900
):
headers = Defaults.headers
if cookies:
Expand Down
13 changes: 8 additions & 5 deletions g4f/Provider/create_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ async def create_async(
) -> str:
messages.insert(0, {"role": "system", "content": self.system_message})
response = await self.provider.create_async(model, messages, **kwargs)
matches = re.findall(r'(<img data-prompt="(.*?)">)', result)
matches = re.findall(r'(<img data-prompt="(.*?)">)', response)
results = []
for _, prompt in matches:
results.append(self.create_images_async(prompt))
placeholders = []
for placeholder, prompt in matches:
if placeholder not in placeholders:
results.append(self.create_images_async(prompt))
placeholders.append(placeholder)
results = await asyncio.gather(*results)
for idx, result in enumerate(results):
placeholder = matches[idx][0]
placeholder = placeholder[idx]
if self.include_placeholder:
result = placeholder + result
response = response.replace(placeholder, result)
return result
return response
Loading