From 1745cb7394ab28508949223da9a7000ff09dbfc8 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 9 Dec 2024 11:50:42 -0600 Subject: [PATCH] Add workflow for checking if types are up-to-date (#16) * Add workflow for checking if types are up-to-date * Fix install * Fix err message * Update provider types --- .github/workflows/check-update-types.yml | 42 ++++++++++++++++++++++++ Makefile | 5 +++ chatlas/types/anthropic/_submit.py | 1 - chatlas/types/openai/_submit.py | 4 +-- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/check-update-types.yml diff --git a/.github/workflows/check-update-types.yml b/.github/workflows/check-update-types.yml new file mode 100644 index 0000000..aca0175 --- /dev/null +++ b/.github/workflows/check-update-types.yml @@ -0,0 +1,42 @@ +name: Test - Python + +on: + workflow_dispatch: + push: + branches: ["main", "rc-*"] + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + release: + types: [published] + +env: + UV_VERSION: "0.4.x" + PYTHON_VERSION: 3.13 + +jobs: + check-types-updated: + name: Check provider types + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: 🚀 Install uv + uses: astral-sh/setup-uv@v3 + + - name: 🐍 Set up Python ${{ env.PYTHON_VERSION }} + run: uv python install ${{ env.PYTHON_VERSION }} + + - name: 📦 Install the project + run: uv sync --python ${{ env.PYTHON_VERSION }} --all-extras + + - name: Run type update + run: make update-types + + # Fail if there are changes under chatlas/types and throw a useful error message + - name: Check for changes + run: | + if [[ -n $(git diff chatlas/types) ]]; then + echo "::error::Types are out of date. Please run 'make update-types' and commit the changes." + exit 1 + fi diff --git a/Makefile b/Makefile index 391edca..7b0b4bb 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,11 @@ update-snaps: @echo "📸 Updating pytest snapshots" uv run pytest --snapshot-update +.PHONY: update-types +update-types: + @echo "📝 Updating chat provider types" + uv run python scripts/main.py + .PHONY: help help: ## Show help messages for make targets @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; { \ diff --git a/chatlas/types/anthropic/_submit.py b/chatlas/types/anthropic/_submit.py index 57e77e5..9e6f9f5 100644 --- a/chatlas/types/anthropic/_submit.py +++ b/chatlas/types/anthropic/_submit.py @@ -32,7 +32,6 @@ class SubmitInputArgs(TypedDict, total=False): "claude-3-haiku-20240307", "claude-2.1", "claude-2.0", - "claude-instant-1.2", ], ] stop_sequences: Union[list[str], anthropic.NotGiven] diff --git a/chatlas/types/openai/_submit.py b/chatlas/types/openai/_submit.py index 7fc1de0..ce5c13f 100644 --- a/chatlas/types/openai/_submit.py +++ b/chatlas/types/openai/_submit.py @@ -6,7 +6,6 @@ from typing import Iterable, Literal, Mapping, Optional, TypedDict, Union import openai -import openai._types import openai.types.chat.chat_completion_assistant_message_param import openai.types.chat.chat_completion_audio_param import openai.types.chat.chat_completion_function_call_option_param @@ -42,6 +41,7 @@ class SubmitInputArgs(TypedDict, total=False): "o1-mini", "o1-mini-2024-09-12", "gpt-4o", + "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", "gpt-4o-realtime-preview", @@ -129,7 +129,7 @@ class SubmitInputArgs(TypedDict, total=False): top_logprobs: Union[int, None, openai.NotGiven] top_p: Union[float, None, openai.NotGiven] user: str | openai.NotGiven - extra_headers: Optional[Mapping[str, Union[str, openai._types.Omit]]] + extra_headers: Optional[Mapping[str, Union[str, openai.Omit]]] extra_query: Optional[Mapping[str, object]] extra_body: object | None timeout: float | openai.Timeout | None | openai.NotGiven