Skip to content

Implement patched o1 & o1-mini model functionality #160

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions terminalgpt/main.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. inject different "user" role instead of "system" if the model is "o1-mini" (o1 does not reproduce the issue), with minimal code and logic changes.
  2. ask only one time if the model is "o1-mini" and then make all changes necessary to the system, messages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Removed duplicated prompts and simply change the config.py prompts role when o1-mini is detected.
  2. Moved the logic the the cli method that is run each call. Model type is only checked once in this method and necessary prompt role is updated.

Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def cli(ctx, model, style: str, token_limit: int = 0):
printer=ctx.obj["PRINTER"],
)

if ctx.obj['MODEL'] == ('o1-mini'):
config.INIT_SYSTEM_MESSAGE["role"] = "user"
config.INIT_WELCOME_MESSAGE["role"] = "user"
config.INIT_WELCOME_BACK_MESSAGE["role"] = "user"

@click.command(help="Installing the OpenAI API key and setup some default settings.")
def install():
Expand Down Expand Up @@ -213,7 +217,7 @@ def new(ctx):
)

messages = [config.INIT_SYSTEM_MESSAGE]
chat_manager.welcome_message(messages + [config.INIT_WELCOME_MESSAGE])
chat_manager.welcome_message(messages + [config.INIT_WELCOME_MESSAGE])
chat_manager.messages = messages
chat_manager.chat_loop()

Expand Down Expand Up @@ -308,7 +312,10 @@ def load(ctx):
while not messages:
messages = conversation_manager.load_conversation()

messages.append(config.INIT_WELCOME_BACK_MESSAGE)
messages = [config.INIT_WELCOME_BACK_MESSAGE]
if ctx.obj['MODEL'] == ('o1-mini'):
messages[0]["role"] = "user"

chat_manager.messages = messages
chat_manager.total_usage = chat_manager.num_tokens_from_messages()

Expand Down