Skip to content

feat: add provider openWebUI#14341

Open
PapeThePope wants to merge 3 commits intoanomalyco:devfrom
PapeThePope:feat/open-webui-provider
Open

feat: add provider openWebUI#14341
PapeThePope wants to merge 3 commits intoanomalyco:devfrom
PapeThePope:feat/open-webui-provider

Conversation

@PapeThePope
Copy link

Issue for this PR

Closes #13537

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • Added OpenWebUI to Providers
    • via /connect
    • opencode.json
    • ENV Vars: OPEN_WEBUI_API_KEY & OPEN_WEBUI_BASE_URL
  • Automatic Model fetching from the OpenWebUI Instance
    • via /v1/models endpoint

How did you verify your code works?

  1. Started Dev TUI
  2. Added provider via /connect
  3. Provided BaseURL + API Key for OpenWebUI instance
  4. Verified that all models were loaded, that are present on the instance
  5. Ran several sessions against models on the instance

Screenshots / recordings

None

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

})
const updated = patchJsonc(before, config)
await Bun.write(filepath, updated)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should try to avoid 'else' statements. See https://github.com/anomalyco/opencode/blob/dev/CONTRIBUTING.md#style-preferences

Is it possible to rewrite?

for (const endpoint of uniqueEndpoints) {
if (Object.keys(models).length > 0) break

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should avoid try/catch as well, possible to rewrite?
https://github.com/anomalyco/opencode/blob/dev/CONTRIBUTING.md#style-preferences

log.error(msg);
// AI SDK often swallows body text on 429. Injecting into statusText helps it surface.
Object.defineProperty(res, 'statusText', { value: msg });
} catch (e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, try/catch

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.

[FEATURE]: Add Open WebUI as a provider

2 participants