Skip to content
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

Provider registry doesn't work with model IDs that have a colon #2056

Closed
Christopher-Hayes opened this issue Jun 21, 2024 · 3 comments
Closed
Labels
ai/core bug Something isn't working

Comments

@Christopher-Hayes
Copy link

Description

I'm testing out the experimental "provider registry" and I've found if the model ID has a : in it, this package will remove everything before the LAST :, which sends the wrong model ID to the LLM API.

Code example

I'm using the OpenAI provider in compatible mode, to allow me to run ollama.

const modelID = 'phi3:medium'
const config = {
  apiKey: '',
  organization: '',
  baseURL: 'http://localhost:11434/v1', // Running ollama locally.
  compatibility: 'compatible', // In 'compatible' mode to use local ollama model.
}
const providerRegistry = createProviderRegistry({
  openai: createOpenAI(config),
})

// Provider registry expects `openai:` if the openai provider is being used.
const { text } = await generateText({
  model: this.providerRegistry.languageModel(`openai:${modelID}`}), // Result: openai:phi3:medium
  // Additional options omitted
})

This will error, because the request to ollama has the model ID, medium, not phi3:medium. Could the registry use the FIRST colon to extract the provider ID, instead of the LAST colon?

Additional context

Alternatively, I can just run

const modelID = 'phi3:medium'
const config = {
  apiKey: '',
  organization: '',
  baseURL: 'http://localhost:11434/v1', // Running ollama locally.
  compatibility: 'compatible', // In 'compatible' mode to use local ollama model.
}
const provider = createOpenAI(config)

const { text } = await generateText({
  model: provider.languageModel(modelID),
  // Additional options omitted
})

and this works fine. So, it's definitely a problem with how the registry decides which provider to use.

@lgrammel lgrammel added bug Something isn't working ai/core labels Jun 21, 2024
@lgrammel
Copy link
Collaborator

#2057

@lgrammel
Copy link
Collaborator

@Christopher-Hayes
Copy link
Author

That was quick! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/core bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants