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

Add new GPT-4o models and update tiktoken to 0.7.0 #901

Merged
merged 2 commits into from
May 14, 2024

Conversation

KennyDizi
Copy link
Contributor

@KennyDizi KennyDizi commented May 14, 2024

Type

enhancement


Description

  • Added 'gpt-4o' and 'gpt-4o-2024-05-13' models to the list of available models
  • Updated tiktoken to version 0.7.0

Changes walkthrough

Relevant files
Enhancement
__init__.py
Add new GPT-4o models                                                                       

pr_agent/algo/init.py

  • Added 'gpt-4o' and 'gpt-4o-2024-05-13' models to the list of available
    models
  • +2/-0     
    requirements.txt
    Update tiktoken to 0.7.0                                                                 

    requirements.txt

    • Updated tiktoken to version 0.7.0
    +1/-1     

    Copy link
    Contributor

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Description updated to latest commit (36ad893)

    Copy link
    Contributor

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are straightforward and limited to a few lines in two files. The complexity is low, involving only the addition of model configurations and a package version update.

    🏅 Score

    85

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Configuration Error: Ensure that the token limits set for the new models ('gpt-4o' and 'gpt-4o-2024-05-13') are correct and consistent with the intended use cases and system capabilities.

    🔒 Security concerns

    No

    Copy link
    Contributor

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Add a comment to explain the significance of the model version date

    Consider adding a comment to explain the significance of the specific date '2024-05-13' in
    the model name 'gpt-4o-2024-05-13'. This will help maintainers understand the context or
    reason for this specific versioning.

    pr_agent/algo/init.py [15]

    -'gpt-4o-2024-05-13': 128000,  # 128K, but may be limited by config.max_model_tokens
    +'gpt-4o-2024-05-13': 128000,  # 128K, specific release date for targeted improvements or features
     
    Suggestion importance[1-10]: 6

    Why: The suggestion to add a comment explaining the significance of the date in the model name is valid and improves code maintainability. However, it's not a critical issue, hence the moderate score.

    6

    @KennyDizi KennyDizi changed the title Add gpt-4o models Add new GPT-4o models and update tiktoken to 0.7.0 May 14, 2024
    Copy link
    Contributor

    @barnett-yuxiang barnett-yuxiang left a comment

    Choose a reason for hiding this comment

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

    It is recommended to update the content of the doc synchronously?

    @KennyDizi
    Copy link
    Contributor Author

    It is recommended to update the content of the doc synchronously?

    Would you pls assist me with where I can update the doc for those new models? I can't find it out

    @barnett-yuxiang
    Copy link
    Contributor

    It is recommended to update the content of the doc synchronously?

    Would you pls assist me with where I can update the doc for those new models? I can't find it out

    image

    I understand that updating here is enough, but let's still listen to @mrT23 advice. 🤝

    @KennyDizi
    Copy link
    Contributor Author

    It is recommended to update the content of the doc synchronously?

    Would you pls assist me with where I can update the doc for those new models? I can't find it out

    image

    I understand that updating here is enough, but let's still listen to @mrT23 advice. 🤝

    cool!

    @mrT23
    Copy link
    Collaborator

    mrT23 commented May 14, 2024

    Thanks @KennyDizi

    Currently, it's just an option, but it's definitely a strong candidate to become the default model in the near future.
    (I am benchmarking it on alphaCodium, to get a sense of how good it really is on code. will be finished soon)

    @mrT23 mrT23 merged commit b4458ff into Codium-ai:main May 14, 2024
    1 check passed
    @KennyDizi
    Copy link
    Contributor Author

    Thanks @KennyDizi

    Currently, it's just an option, but it's definitely a strong candidate to become the default model in the near future. (I am benchmarking it on alphaCodium, to get a sense of how good it really is on code. will be finished soon)

    Thanks, @mrT23 gpt-4o model made a new standard; we're looking for your benchmark.

    @vKongv
    Copy link

    vKongv commented May 14, 2024

    I tried to use gpt-4o as my model and I encountered this error. I am running it in Github Action

    My github action yml file:

    jobs:
      pr_agent_job:
        runs-on: ubuntu-latest
        if: |
          (github.event_name == 'pull_request') ||
          (github.event_name == 'issue_comment' && 
          github.event.issue.pull_request && 
          contains(github.event.comment.body, '/review'))
        permissions:
          issues: write
          pull-requests: write
          contents: write
        name: Run pr agent on pull requests and respond to '/review' comments
        steps:
          - name: PR Agent action step
            id: pragent
            uses: Codium-ai/pr-agent@main
            env:
              CONFIG.MODEL: gpt-4o-2024-05-13
              PR_REVIEWER.INLINE_CODE_COMMENTS: true
              PR_REVIEWER.PERSISTENT_COMMENT: false
              PR_REVIEWER.NUM_CODE_SUGGESTIONS: 8
              OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    {"text": "Applying repo settings\n", "record": {"elapsed": {"repr": "0:00:01.098014", "seconds": 1.098014}, "exception": null, "extra": {}, "file": {"name": "github_action_runner.py", "path": "/app/pr_agent/servers/github_action_runner.py"}, "function": "run_action", "level": {"icon": "ℹ️", "name": "INFO", "no": 20}, "line": 75, "message": "Applying repo settings", "module": "github_action_runner", "name": "__main__", "process": {"id": 6, "name": "MainProcess"}, "thread": {"id": 139708756859776, "name": "MainThread"}, "time": {"repr": "2024-05-14 10:44:11.476957+00:00", "timestamp": 1715683451.476957}}}
    {"text": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'\n", "record": {"elapsed": {"repr": "0:00:03.222232", "seconds": 3.222232}, "exception": null, "extra": {"command": "review"}, "file": {"name": "utils.py", "path": "/app/pr_agent/algo/utils.py"}, "function": "clip_tokens", "level": {"icon": "⚠️", "name": "WARNING", "no": 30}, "line": 582, "message": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'", "module": "utils", "name": "pr_agent.algo.utils", "process": {"id": 6, "name": "MainProcess"}, "thread": {"id": 139708756859776, "name": "MainThread"}, "time": {"repr": "2024-05-14 10:44:13.60[11](https://github.com/dresstal-berhad/auito-be/actions/runs/9078012351/job/24944105248#step:3:12)75+00:00", "timestamp": 1715683453.601175}}}
    {"text": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'\n", "record": {"elapsed": {"repr": "0:00:03.511451", "seconds": 3.511451}, "exception": null, "extra": {"command": "review"}, "file": {"name": "utils.py", "path": "/app/pr_agent/algo/utils.py"}, "function": "clip_tokens", "level": {"icon": "⚠️", "name": "WARNING", "no": 30}, "line": 582, "message": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'", "module": "utils", "name": "pr_agent.algo.utils", "process": {"id": 6, "name": "MainProcess"}, "thread": {"id": 139708756859776, "name": "MainThread"}, "time": {"repr": "2024-05-14 10:44:13.890394+00:00", "timestamp": 1715683453.890394}}}
    Traceback (most recent call last):
      File "/app/pr_agent/servers/github_action_runner.py", line 148, in <module>
        asyncio.run(run_action())
      File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
        return future.result()
      File "/app/pr_agent/servers/github_action_runner.py", line 141, in run_action
        await PRAgent().handle_request(url, body,
      File "/app/pr_agent/agent/pr_agent.py", line 93, in handle_request
        await command2class[action](pr_url, ai_handler=self.ai_handler, args=args).run()
      File "/app/pr_agent/tools/pr_reviewer.py", line 75, in __init__
        self.token_handler = TokenHandler(
      File "/app/pr_agent/algo/token_handler.py", line 47, in __init__
        self.encoder = TokenEncoder.get_token_encoder()
      File "/app/pr_agent/algo/token_handler.py", line 19, in get_token_encoder
        cls._encoder_instance = encoding_for_model(cls._model) if "gpt" in cls._model else get_encoding(
      File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 97, in encoding_for_model
        return get_encoding(encoding_name_for_model(model_name))
      File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 84, in encoding_name_for_model
        raise KeyError(
    KeyError: 'Could not automatically map gpt-4o-2024-05-[13](https://github.com/dresstal-berhad/auito-be/actions/runs/9078012351/job/24944105248#step:3:14) to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'
    

    Am I missing anything?

    Edit: I also try using gpt-4o for CONFIG.MODEL but it still getting the same error

    @KennyDizi
    Copy link
    Contributor Author

    I tried to use gpt-4o as my model and I encountered this error. I am running it in Github Action

    My github action yml file:

    jobs:
    
      pr_agent_job:
    
        runs-on: ubuntu-latest
    
        if: |
    
          (github.event_name == 'pull_request') ||
    
          (github.event_name == 'issue_comment' && 
    
          github.event.issue.pull_request && 
    
          contains(github.event.comment.body, '/review'))
    
        permissions:
    
          issues: write
    
          pull-requests: write
    
          contents: write
    
        name: Run pr agent on pull requests and respond to '/review' comments
    
        steps:
    
          - name: PR Agent action step
    
            id: pragent
    
            uses: Codium-ai/pr-agent@main
    
            env:
    
              CONFIG.MODEL: gpt-4o-2024-05-13
    
              PR_REVIEWER.INLINE_CODE_COMMENTS: true
    
              PR_REVIEWER.PERSISTENT_COMMENT: false
    
              PR_REVIEWER.NUM_CODE_SUGGESTIONS: 8
    
              OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
    
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    
    
    {"text": "Applying repo settings\n", "record": {"elapsed": {"repr": "0:00:01.098014", "seconds": 1.098014}, "exception": null, "extra": {}, "file": {"name": "github_action_runner.py", "path": "/app/pr_agent/servers/github_action_runner.py"}, "function": "run_action", "level": {"icon": "ℹ️", "name": "INFO", "no": 20}, "line": 75, "message": "Applying repo settings", "module": "github_action_runner", "name": "__main__", "process": {"id": 6, "name": "MainProcess"}, "thread": {"id": 139708756859776, "name": "MainThread"}, "time": {"repr": "2024-05-14 10:44:11.476957+00:00", "timestamp": 1715683451.476957}}}
    
    {"text": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'\n", "record": {"elapsed": {"repr": "0:00:03.222232", "seconds": 3.222232}, "exception": null, "extra": {"command": "review"}, "file": {"name": "utils.py", "path": "/app/pr_agent/algo/utils.py"}, "function": "clip_tokens", "level": {"icon": "⚠️", "name": "WARNING", "no": 30}, "line": 582, "message": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'", "module": "utils", "name": "pr_agent.algo.utils", "process": {"id": 6, "name": "MainProcess"}, "thread": {"id": 139708756859776, "name": "MainThread"}, "time": {"repr": "2024-05-14 10:44:13.60[11](https://github.com/dresstal-berhad/auito-be/actions/runs/9078012351/job/24944105248#step:3:12)75+00:00", "timestamp": 1715683453.601175}}}
    
    {"text": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'\n", "record": {"elapsed": {"repr": "0:00:03.511451", "seconds": 3.511451}, "exception": null, "extra": {"command": "review"}, "file": {"name": "utils.py", "path": "/app/pr_agent/algo/utils.py"}, "function": "clip_tokens", "level": {"icon": "⚠️", "name": "WARNING", "no": 30}, "line": 582, "message": "Failed to clip tokens: 'Could not automatically map gpt-4o-2024-05-13 to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'", "module": "utils", "name": "pr_agent.algo.utils", "process": {"id": 6, "name": "MainProcess"}, "thread": {"id": 139708756859776, "name": "MainThread"}, "time": {"repr": "2024-05-14 10:44:13.890394+00:00", "timestamp": 1715683453.890394}}}
    
    Traceback (most recent call last):
    
      File "/app/pr_agent/servers/github_action_runner.py", line 148, in <module>
    
        asyncio.run(run_action())
    
      File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    
        return loop.run_until_complete(main)
    
      File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    
        return future.result()
    
      File "/app/pr_agent/servers/github_action_runner.py", line 141, in run_action
    
        await PRAgent().handle_request(url, body,
    
      File "/app/pr_agent/agent/pr_agent.py", line 93, in handle_request
    
        await command2class[action](pr_url, ai_handler=self.ai_handler, args=args).run()
    
      File "/app/pr_agent/tools/pr_reviewer.py", line 75, in __init__
    
        self.token_handler = TokenHandler(
    
      File "/app/pr_agent/algo/token_handler.py", line 47, in __init__
    
        self.encoder = TokenEncoder.get_token_encoder()
    
      File "/app/pr_agent/algo/token_handler.py", line 19, in get_token_encoder
    
        cls._encoder_instance = encoding_for_model(cls._model) if "gpt" in cls._model else get_encoding(
    
      File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 97, in encoding_for_model
    
        return get_encoding(encoding_name_for_model(model_name))
    
      File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 84, in encoding_name_for_model
    
        raise KeyError(
    
    KeyError: 'Could not automatically map gpt-4o-2024-05-[13](https://github.com/dresstal-berhad/auito-be/actions/runs/9078012351/job/24944105248#step:3:14) to a tokeniser. Please use `tiktoken.get_encoding` to explicitly get the tokeniser you expect.'
    
    

    Am I missing anything?

    Edit: I also try using gpt-4o for CONFIG.MODEL but it still getting the same error

    You have to install the tiktoken v0.7.0 to use new model.

    @mrT23
    Copy link
    Collaborator

    mrT23 commented May 14, 2024

    @vKongv
    i only now updated the dockers. try again

    @vKongv
    Copy link

    vKongv commented May 14, 2024 via email

    @mrT23
    Copy link
    Collaborator

    mrT23 commented May 14, 2024

    @KennyDizi
    p.s.
    https://twitter.com/talrid23/status/1790342268555079906

    the model does look strong (and fast).
    couple more days, and I think I will make it the default one

    @barnett-yuxiang
    Copy link
    Contributor

    @mrT23

    The speed is 2x faster, and the price is only 50% of the original.

    image

    @mrT23
    Copy link
    Collaborator

    mrT23 commented May 15, 2024

    @barnett-yuxiang i understand, and will probably use it as the default model in the near future.

    But:
    As a general strategy, I don't like to switch models the first day they come out:

    1. usually there are availability issues, that are resolved along the way
    2. I want to validate the quality, both from my inspection and from general internet feedback

    Ping me in a week or so if the base model was not switched :-)

    @barnett-yuxiang
    Copy link
    Contributor

    Oh, @mrT23 , I understand your expression very well, and if it were me, I would also make decisions like you. Our thoughts are the same.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    4 participants