Skip to content

Bump anthropic from 0.3.11 to 0.7.7

Tan Le requested to merge bump-anthropic-0.7.7 into main

What does this merge request do and why?

Bump anthropic from 0.3.11 to 0.7.7. Some notable changes from the CHANGELOG:

  • client: retry on 408 Request Timeout (#155) (46386f8)
  • client: adjust retry behavior to be exponential backoff (#205) (c8a4119)
  • client: correctly flush the stream response body (#230) (a60d543)

Full change set.

How to set up and validate locally

  1. Check out to this merge request's branch.

  2. Ensure a local Docker image built successfully.

    docker buildx build --platform linux/amd64 \
      -t ai-gateway:dev .
  3. Run a local service on Docker.

    docker run --platform linux/amd64 --rm \
      -p 5052:5052 \
      -e AUTH_BYPASS_EXTERNAL=true \
      -v $PWD:/app -it ai-gateway:dev
  4. Run a cURL request to verify that inference via Anthropic API still works

    Generations
    curl --request POST \
      --url http://codesuggestions.gdk.test:5999/v2/code/generations \
      --header 'Content-Type: application/json' \
      --header 'X-Gitlab-Authentication-Type: oidc' \
      --data '{
      "current_file": {
        "file_name": "math.py",
        "content_above_cursor": "# Hello world",
        "content_below_cursor": "\n"
      },
      "prompt_version": 2,
      "prompt": "Human: You are a coding autocomplete agent. We want to generate new Python code inside the\nfile '\''hello.py'\'' based on instructions from the user.\nThe existing code is provided in <existing_code></existing_code> tags.\nThe new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.\nIn your process, first, review the existing code to understand its logic and format. Then, try to determine the most\nlikely new code to generate at the cursor position to fulfill the instructions.\n\nWhen generating the new code, please ensure the following:\n1. It is valid Python code.\n2. It matches the existing code'\''s variable, parameter and function names.\n3. It does not repeat any existing code. Do not repeat code that comes before or after the cursor tags. This includes cases where the cursor is in the middle of a word.\n4. If the cursor is in the middle of a word, it finishes the word instead of repeating code before the cursor tag.\n\nReturn new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.\nIf you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.\n\nHere are a few examples of successfully generated code by other autocomplete agents:\n\n<examples>\n\n  <example>\n    H: <existing_code>\n         class Project:\n  def __init__(self, name, public):\n    self.name = name\n    self.visibility = '\''PUBLIC'\'' if public\n\n    # is this project public?\n<cursor>\n\n    # print name of this project\n       </existing_code>\n\n    A: <new_code>def is_public(self):\n  self.visibility == '\''PUBLIC'\''</new_code>\n  </example>\n\n  <example>\n    H: <existing_code>\n         # get the current user'\''s name from the session data\ndef get_user(session):\n<cursor>\n\n# is the current user an admin\n       </existing_code>\n\n    A: <new_code>username = None\nif '\''username'\'' in session:\n  username = session['\''username'\'']\nreturn username</new_code>\n  </example>\n\n</examples>\n\n\n<existing_code>\ndef foo():\n   # generate a function for the square root<cursor>\n</existing_code>\n\n\nHere are instructions provided in <instruction></instruction> tags.\n\n<instruction>\ngenerate a function for the square root\n</instruction>\n\n\nAssistant: <new_code>",
      "model_provider": "anthropic"
    }
    '
    Generations - Stream
       curl --request POST -N \
      --url http://codesuggestions.gdk.test:5999/v2/code/generations \
      --header 'Content-Type: application/json' \
      --header 'X-Gitlab-Authentication-Type: oidc' \
      --data '{
      "current_file": {
        "file_name": "poetry.py",
        "content_above_cursor": "# Hello world",
        "content_below_cursor": "\n"
      },
      "prompt_version": 2,
      "prompt": "write me a Dr Seus poem about GitLab AIDevSecOps for 100 words\n",
      "model_provider": "anthropic",
      "stream": true
    }
    '

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.
Edited by Tan Le

Merge request reports