Skip to content

Add support for GitHub Models #200

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

Merged
merged 1 commit into from
May 1, 2025
Merged

Add support for GitHub Models #200

merged 1 commit into from
May 1, 2025

Conversation

pamelafox
Copy link
Contributor

Purpose

This pull request introduces support for GitHub-hosted AI models in various parts of the codebase and includes a minor refactor to standardize the naming of embedding dimension environment variables.

Does this introduce a breaking change?

When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.

[ ] Yes
[X] No

Type of change

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

Code quality checklist

See CONTRIBUTING.md for more details.

  • The current tests all pass (python -m pytest).
  • I added tests that prove my fix is effective or that my feature works
  • I ran python -m pytest --cov to verify 100% coverage of added lines
  • I ran python -m mypy to check for type errors
  • I either used the pre-commit hooks or ran ruff manually on my code.

@pamelafox pamelafox requested a review from Copilot May 1, 2025 18:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for GitHub-hosted AI models across various components and standardizes the naming of embedding dimension environment variables.

  • Introduces branches for GitHub Models in clients, routes, dependencies, and evaluation modules.
  • Refactors environment variable names and dynamic attribute access to support multiple model hosts within the application.

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/conftest.py Renamed an embedding dimension env var to standardize naming.
src/backend/fastapi_app/update_embeddings.py Added a new branch for GitHub to select the appropriate column.
src/backend/fastapi_app/routes/api_routes.py Changed to dynamic attribute retrieval for embedding column.
src/backend/fastapi_app/openai_clients.py Added support for GitHub Models for both chat and embeddings.
src/backend/fastapi_app/dependencies.py Extended GitHub support for embedding and chat configuration.
evals/generate_ground_truth.py Updated error messages to reflect GitHub Models are not supported.
evals/evaluate.py Included GitHub branch for evaluation to prevent unsupported usage.
Files not reviewed (2)
  • .env.sample: Language not supported
  • infra/main.bicep: Language not supported
Comments suppressed due to low confidence (3)

tests/conftest.py:98

  • Ensure that the updated environment variable naming in tests ('OPENAICOM_EMBED_DIMENSIONS') matches the standardized naming in application code for consistency.
monkeypatch_session.setenv("OPENAICOM_EMBED_DIMENSIONS", "1024")

evals/generate_ground_truth.py:106

  • [nitpick] The error message for GitHub Models now mirrors other providers; consider including additional context or documentation to help users understand current support limitations.
raise NotImplementedError("GitHub Models is not supported. Switch to Azure or OpenAI.com")

src/backend/fastapi_app/routes/api_routes.py:71

  • Dynamic attribute retrieval is a good refactor; however, verify that all Item instances are guaranteed to have the attribute specified by context.embedding_column to avoid potential AttributeError at runtime.
getattr(item, context.embedding_column)

@@ -50,6 +50,15 @@ async def create_openai_chat_client(
base_url=os.getenv("OLLAMA_ENDPOINT"),
api_key="nokeyneeded",
)
elif OPENAI_CHAT_HOST == "github":
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider documenting the GitHub Models branch in the client setup to clarify why no explicit model parameter is passed during initialization, ensuring future maintainability.

Suggested change
elif OPENAI_CHAT_HOST == "github":
elif OPENAI_CHAT_HOST == "github":
# The GitHub Models branch does not require an explicit model parameter during initialization.
# Instead, it relies on the GITHUB_BASE_URL and GITHUB_MODEL environment variables to configure
# the base URL and model name, respectively. This design choice ensures flexibility and avoids
# hardcoding model details in the code.

Copilot uses AI. Check for mistakes.

@pamelafox pamelafox merged commit 541adda into main May 1, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant