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

Fix support for gpt-4o #411

Merged
merged 4 commits into from
May 21, 2024
Merged
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
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."
sudoskys marked this conversation as resolved.
Show resolved Hide resolved
)
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
Loading