这是indexloc提供的服务,不要输入任何密码
Skip to content

Use the GitHub models catalog endpoint for listing models #72

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 3 commits into from
Jul 17, 2025

Conversation

cschleiden
Copy link
Member

With this change we'll

  • use https://models.github.ai/catalog to fetch models available through GitHub Models
  • still use AI Foundry's model catalog for fetching model details, for example, for the models view command

@cschleiden cschleiden force-pushed the cschleiden/use-catalog-endpoint branch from 09f5dd6 to 91fa594 Compare July 17, 2025 20:59
@cschleiden cschleiden force-pushed the cschleiden/use-catalog-endpoint branch from 91fa594 to 1cc232e Compare July 17, 2025 21:00
@cschleiden cschleiden force-pushed the cschleiden/use-catalog-endpoint branch from 1cc232e to 1d5ff3f Compare July 17, 2025 21:21
@cschleiden cschleiden marked this pull request as ready for review July 17, 2025 21:24
@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 21:24
@cschleiden cschleiden requested a review from a team as a code owner July 17, 2025 21:24
Copy link
Contributor

@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 transitions the model listing functionality from Azure AI Foundry's model catalog to GitHub's native models catalog endpoint. The change uses GitHub's own models API (https://models.github.ai/catalog) for listing models while maintaining Azure AI Foundry for detailed model information.

  • Updates API client to use GitHub Models catalog endpoint instead of Azure AI Foundry for model listing
  • Refactors model data structures to align with GitHub's API response format
  • Removes deprecated model identifier formatting utility and updates all references to use GitHub's model IDs directly

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/azuremodels/types.go Updates type definitions to match GitHub Models API response format
internal/azuremodels/azure_client.go Changes ListModels to use GitHub Models catalog endpoint with GET request
internal/azuremodels/model_summary.go Updates ModelSummary struct and removes deprecated FormatIdentifier function
internal/azuremodels/model_details.go Removes FormatIdentifier function and related imports
cmd/view/view.go Updates to use model.ID directly instead of FormatIdentifier
cmd/run/run.go Updates model selection and validation to use GitHub model IDs
cmd/list/list.go Updates model listing display to use GitHub model IDs
Test files Updates test cases to use new GitHub model ID format and structure

Comment on lines +53 to +54
idI := strings.ToLower(fmt.Sprintf("%s/%s", models[i].Publisher, models[i].Name))
idJ := strings.ToLower(fmt.Sprintf("%s/%s", models[j].Publisher, models[j].Name))
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] The sorting logic duplicates the model ID formatting that was previously handled by FormatIdentifier. Consider using the existing model.ID field or extracting this formatting logic into a helper function to avoid duplication.

Suggested change
idI := strings.ToLower(fmt.Sprintf("%s/%s", models[i].Publisher, models[i].Name))
idJ := strings.ToLower(fmt.Sprintf("%s/%s", models[j].Publisher, models[j].Name))
idI := FormatIdentifier(models[i].Publisher, models[i].Name)
idJ := FormatIdentifier(models[j].Publisher, models[j].Name)

Copilot uses AI. Check for mistakes.

idI := FormatIdentifier(models[i].Publisher, models[i].Name)
idJ := FormatIdentifier(models[j].Publisher, models[j].Name)
idI := strings.ToLower(fmt.Sprintf("%s/%s", models[i].Publisher, models[i].Name))
idJ := strings.ToLower(fmt.Sprintf("%s/%s", models[j].Publisher, models[j].Name))
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] The sorting logic duplicates the model ID formatting that was previously handled by FormatIdentifier. Consider using the existing model.ID field or extracting this formatting logic into a helper function to avoid duplication.

Copilot uses AI. Check for mistakes.

@@ -500,7 +500,8 @@ func (h *runCommandHandler) getModelNameFromArgs(models []*azuremodels.ModelSumm
if !model.IsChatModel() {
continue
}
prompt.Options = append(prompt.Options, azuremodels.FormatIdentifier(model.Publisher, model.Name))

prompt.Options = append(prompt.Options, model.ID)
Copy link
Member

Choose a reason for hiding this comment

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

It's nice being able to use a simple ID property and not have to format an identifier from other bits.

@@ -14,14 +14,13 @@ func TestView(t *testing.T) {
t.Run("NewViewCommand happy path", func(t *testing.T) {
client := azuremodels.NewMockClient()
modelSummary := &azuremodels.ModelSummary{
ID: "test-id-1",
ID: "openai/test-model-1",
Copy link
Member

Choose a reason for hiding this comment

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

I thought I remembered talk recently of moving away from requiring the publisher name in model identifiers, something from @sgoedecke. Did that happen? Should we also have a test that just has the model name for its ID if so?


modelKey, err := modelkey.ParseModelKey(catalogModel.ID)
if err != nil {
return nil, fmt.Errorf("parsing model key %q: %w", catalogModel.ID, err)
Copy link
Member

Choose a reason for hiding this comment

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

Ahh you calling it a "model key" here when printing out the ID makes me think that we will indeed have the publisher + model name combined in the field, so probably don't need such a test as I suggested above. 👍🏻

@cschleiden cschleiden merged commit 3bc7b92 into main Jul 17, 2025
5 checks passed
@cschleiden cschleiden deleted the cschleiden/use-catalog-endpoint branch July 17, 2025 21:54
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.

3 participants