Skip to content

Commit

Permalink
enhancement: 作图默认调用dall-e-3模型,支持新参数:model, quality, style (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
latorc authored Nov 14, 2023
1 parent b379085 commit cf814e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions bot/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ def reply(self, context: Context) -> Reply:
return Reply(ReplyType.TEXT, response["content"])

def reply_img(self, query) -> Reply:
create_image_size = conf().get("create_image_size", "256x256")
create_image_size = conf().get("create_image_size", "512x512")
create_image_model = conf().get("create_image_model", "dall-e-3")
create_image_style = conf().get("create_image_style", "vivid")
create_image_quality = conf().get("create_image_quality", "standard")

try:
response = openai.Image.create(prompt=query, n=1, size=create_image_size)
response = openai.Image.create(prompt=query, model=create_image_model, size=create_image_size,
style=create_image_style, quality=create_image_quality)
image_url = response["data"][0]["url"]
logger.info(f"[{self.name}] Image={image_url}")
return Reply(ReplyType.IMAGE, image_url)
Expand Down
5 changes: 4 additions & 1 deletion config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
"temperature": 0.9,
"proxy": "",
"openai_api_base": "",
"create_image_size": "256x256",
"create_image_prefix": ["draw", "paint", "imagine"],
"create_image_model": "dall-e-3",
"create_image_size": "1024x1024",
"create_image_style": "vivid",
"create_image_quality": "hd",
"clear_current_session_command": "#clear session",
"clear_all_sessions_command": "#clear all sessions",
"chat_group_session_independent": false,
Expand Down

0 comments on commit cf814e2

Please sign in to comment.