Refresh the models list, add some tooling for dynamically pulling the static list#22
Closed
cmbrose wants to merge 5 commits intotonybaloney:mainfrom
Closed
Refresh the models list, add some tooling for dynamically pulling the static list#22cmbrose wants to merge 5 commits intotonybaloney:mainfrom
cmbrose wants to merge 5 commits intotonybaloney:mainfrom
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19 (as a side effect 😄)
(Generated by
git diff forked/main parse_models_json.py refresh_models_json.py ../llm_github_models.py | llm -m github/o3-mini "Summarize this git diff into a PR body")This PR makes several enhancements and additions to the GitHub models integration and associated tooling:
Changes in llm_github_models.py:
• The chat models list (CHAT_MODELS) has been updated to include an extra field, api_version. Each model tuple now contains: model name, whether it supports streaming, input modalities, output modalities, and the API version (set to None by default or a preview version for select models like "o3", "o3-mini", and "o4-mini").
• The register_models function now unpacks this extra api_version field and passes it to the GitHubModels constructor.
• In the GitHubModels class, the api_version is stored and used to add an extra key in the client call, replacing the previous hardcoded logic for "o3-mini".
• Minor formatting improvements (e.g., in the attachment_as_content_item and build_messages functions) help with clarity and maintainability.
Updates in tools/parse_models_json.py:
• The script now categorizes models from models.json into “chat-completion”, “embeddings”, and “unknown” buckets.
• For chat models, the tuple now includes the new api_version field determined via a helper function. For embeddings, an extra dimensions list is added (for example, [256, 1024] or [512] for specific models).
• The function supports_streaming has been updated to mark additional models (such as "o3", "o4-mini") as not supporting streaming.
• The script generates a Markdown fragment (“models.fragment.md”) that documents model details. It now produces separate sections for supported chat models and embedding models, including images, usage information, publisher details, and a formatted description.
New script: tools/refresh_models_json.py:
• This new utility fetches the latest models catalog from the GitHub API using a valid GITHUB_TOKEN.
• It builds URLs for model detail pages and scrapes each model’s JSON details (using BeautifulSoup) from the GitHub Marketplace.
• The resulting list of models is sorted and written to a models.json file.
• This script facilitates periodically refreshing local metadata without waiting for a live API.
Overall, these changes improve model metadata management by adding versioning support and richer attributes, automate documentation generation through Markdown fragments, and provide a new tool for updating the models catalog by combining API calls with web scraping.