Skip to content

Commit

Permalink
Merge pull request #411 from LlmKira/dev
Browse files Browse the repository at this point in the history
Fix support for gpt-4o
  • Loading branch information
sudoskys authored May 21, 2024
2 parents 4b8c103 + 0e192d0 commit a1865b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/sender/telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ async def listen_login_command(message: types.Message):
reply = await login(
uid=uid_make(__sender__, message.from_user.id), arg_string=_arg
)
await bot.reply_to(message, text=reply)
await bot.reply_to(
message,
text=reply,
parse_mode="MarkdownV2",
)

@bot.message_handler(commands="env", chat_types=["private"])
async def listen_env_command(message: types.Message):
Expand Down
5 changes: 3 additions & 2 deletions app/sender/util_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ async def login(uid: str, arg_string) -> str:
"""
error = telegramify_markdown.convert(
"🔑 **Incorrect format.**\n"
"You can set it via `https://<something api.openai.com>/v1$<api key>"
"You can set it via `/login https://<something api.openai.com>/v1$<api key>"
"$<model such as gpt-4-turbo>$<tool_model such as gpt-3.5-turbo>` format, "
"or you can log in via URL using `token$https://provider.com`."
"or you can log in via URL using `/login token$https://provider.com`.\n"
"Use $ to separate the parameters."
)
settings = split_setting_string(arg_string)
if not settings:
Expand Down
4 changes: 3 additions & 1 deletion llmkira/openai/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
SystemMessage,
)

VISION = ("gpt-4-vision", "gpt-4-turbo", "claude-3", "gpt-4o")


class OpenAICredential(BaseModel):
api_key: SecretStr
Expand Down Expand Up @@ -164,7 +166,7 @@ def make_url(base_url: str):

@model_validator(mode="after")
def check_vision(self):
if not self.model.startswith(("gpt-4-vision", "gpt-4-turbo", "claude-3")):
if not self.model.startswith(VISION):
logger.info(
"Try to remove the image content part from the messages, because the model is not supported."
)
Expand Down

0 comments on commit a1865b4

Please sign in to comment.