-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Umans AI Coding Plan provider #2636
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7d721dc
Add Umans AI Coding Plan provider
oldschoola ac8a8fe
Merge remote-tracking branch 'origin/main' into oldschoola/umans
oldschoola 23e180d
Resolve changelog merge conflicts
oldschoola d7df0b6
Address Umans provider review feedback
oldschoola a18242c
Simplify Umans discovery error handling
oldschoola 7bbe2d8
Surface Umans discovery fetch errors
oldschoola 1c4bda2
Drop Xiaomi ASR models from catalog
oldschoola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { createApiKeyLogin } from "./api-key-login"; | ||
| import type { OAuthLoginCallbacks } from "./oauth/types"; | ||
| import type { ProviderDefinition } from "./types"; | ||
|
|
||
| export const loginUmans = createApiKeyLogin({ | ||
| providerLabel: "Umans AI Coding Plan", | ||
| authUrl: "https://app.umans.ai/billing", | ||
| instructions: "Create or copy your Umans API key from Dashboard → API Keys.", | ||
| promptMessage: "Paste your Umans API key", | ||
| placeholder: "sk-...", | ||
| validation: { | ||
| kind: "anthropic-messages", | ||
| provider: "Umans AI Coding Plan", | ||
| baseUrl: "https://api.code.umans.ai", | ||
| model: "umans-coder", | ||
| }, | ||
| }); | ||
|
|
||
| export const umansProvider = { | ||
| id: "umans", | ||
| name: "Umans AI Coding Plan", | ||
| login: (cb: OAuthLoginCallbacks) => loginUmans(cb), | ||
| } as const satisfies ProviderDefinition; | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { describe, expect, it, vi } from "bun:test"; | ||
| import { loginUmans } from "@oh-my-pi/pi-ai/registry/umans"; | ||
| import type { FetchImpl } from "@oh-my-pi/pi-ai/types"; | ||
|
|
||
| describe("umans login", () => { | ||
| it("validates pasted keys against the Anthropic messages endpoint", async () => { | ||
| let authUrl: string | undefined; | ||
| let authInstructions: string | undefined; | ||
| let promptMessage: string | undefined; | ||
| let promptPlaceholder: string | undefined; | ||
| const fetchMock: FetchImpl = vi.fn(async (input: string | URL | Request, init?: RequestInit) => { | ||
| const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url; | ||
| const headers = new Headers(init?.headers); | ||
| const body = JSON.parse(String(init?.body)) as { model?: string; max_tokens?: number }; | ||
|
|
||
| expect(url).toBe("https://api.code.umans.ai/v1/messages"); | ||
| expect(init?.method).toBe("POST"); | ||
| expect(headers.get("content-type")).toBe("application/json"); | ||
| expect(headers.get("anthropic-version")).toBe("2023-06-01"); | ||
| expect(headers.get("x-api-key")).toBe("sk-umans-valid"); | ||
| expect(headers.get("authorization")).toBeNull(); | ||
| expect(body.model).toBe("umans-coder"); | ||
| expect(body.max_tokens).toBe(1); | ||
|
|
||
| return new Response(JSON.stringify({ id: "msg_test", type: "message" }), { | ||
| status: 200, | ||
| headers: { "Content-Type": "application/json" }, | ||
| }); | ||
| }); | ||
|
|
||
| const apiKey = await loginUmans({ | ||
| onAuth: info => { | ||
| authUrl = info.url; | ||
| authInstructions = info.instructions; | ||
| }, | ||
| onPrompt: async prompt => { | ||
| promptMessage = prompt.message; | ||
| promptPlaceholder = prompt.placeholder; | ||
| return " sk-umans-valid "; | ||
| }, | ||
| fetch: fetchMock, | ||
| }); | ||
|
|
||
| expect(apiKey).toBe("sk-umans-valid"); | ||
| expect(authUrl).toBe("https://app.umans.ai/billing"); | ||
| expect(authInstructions).toContain("Dashboard → API Keys"); | ||
| expect(promptMessage).toBe("Paste your Umans API key"); | ||
| expect(promptPlaceholder).toBe("sk-..."); | ||
| expect(fetchMock).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it("surfaces validation errors from the Anthropic messages endpoint", async () => { | ||
| const fetchMock: FetchImpl = vi.fn( | ||
| async () => | ||
| new Response("invalid key", { | ||
| status: 401, | ||
| headers: { "Content-Type": "text/plain" }, | ||
| }), | ||
| ); | ||
|
|
||
| await expect( | ||
| loginUmans({ | ||
| onPrompt: async () => "sk-umans-bad", | ||
| fetch: fetchMock, | ||
| }), | ||
| ).rejects.toThrow("Umans AI Coding Plan API key validation failed (401): invalid key"); | ||
| expect(fetchMock).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should-fix:
/login umansis a new user-facing path, but the PR only checks thatumansappears in the provider list. Existing API-key providers such aszenmuxandnanogpthave tests that assert the exact validation URL, method, auth header, prompt text, trimmed key, and validation-error surfacing. Without the same coverage here, a typo inbaseUrl,model, or the Anthropicx-api-keyvalidation path would ship whileprovider-registry.test.tsstill passes.