Skip to content

Commit

Permalink
Add workflow for checking if types are up-to-date (#16)
Browse files Browse the repository at this point in the history
* Add workflow for checking if types are up-to-date

* Fix install

* Fix err message

* Update provider types
  • Loading branch information
cpsievert authored Dec 9, 2024
1 parent 42186fe commit 1745cb7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/check-update-types.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ":.*?## "}; { \
Expand Down
1 change: 0 additions & 1 deletion chatlas/types/anthropic/_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions chatlas/types/openai/_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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

0 comments on commit 1745cb7

Please sign in to comment.