-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infr: update dependencies and openai models
- Loading branch information
Showing
8 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
"""DALL-E model from OpenAI.""" | ||
|
||
import openai | ||
from openai import AsyncOpenAI | ||
from bot.config import config | ||
|
||
openai.api_key = config.openai.api_key | ||
openai = AsyncOpenAI(api_key=config.openai.api_key) | ||
|
||
|
||
class Model: | ||
"""OpenAI DALL-E wrapper.""" | ||
|
||
async def imagine(self, prompt: str, size: str) -> str: | ||
"""Generates an image of the specified size according to the description.""" | ||
resp = await openai.Image.acreate(prompt=prompt, size=size, n=1) | ||
resp = await openai.images.generate( | ||
model="dall-e-3", prompt=prompt, size=size, n=1 | ||
) | ||
if len(resp.data) == 0: | ||
raise ValueError("received an empty answer") | ||
return resp.data[0].url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
httpx==0.23.3 | ||
openai==0.27.2 | ||
beautifulsoup4==4.12.0 | ||
python-telegram-bot==20.2 | ||
httpcore==1.0.2 | ||
httpx==0.25.1 | ||
openai==1.2.3 | ||
beautifulsoup4==4.12.2 | ||
python-telegram-bot==20.6 | ||
PyYAML==6.0.1 | ||
tiktoken==0.3.3 | ||
tiktoken==0.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters