@wuyaos/pi-model-config 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/model-config.schema.json +7 -1
- package/package.json +1 -1
- package/src/command.ts +1069 -1053
- package/src/config.ts +4 -0
- package/src/i18n.ts +10 -0
- package/src/image-apis/common.ts +219 -0
- package/src/image-apis/dashscope.ts +42 -0
- package/src/image-apis/gemini.ts +36 -0
- package/src/image-apis/index.ts +15 -0
- package/src/image-apis/openai.ts +32 -0
- package/src/image-apis/xai.ts +27 -0
- package/src/runtime.ts +20 -3
- package/src/selector.ts +433 -433
- package/src/transport.ts +3 -2
- package/src/types.ts +4 -2
package/src/transport.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProxyAgent, fetch as undiciFetch } from "undici";
|
|
2
2
|
import type { FetchFunction, ProviderEnv, ProviderHeaders, Transport } from "@earendil-works/pi-ai";
|
|
3
|
-
import type
|
|
3
|
+
import { IMAGE_API_NAMES, type ProviderDraft } from "./types.ts";
|
|
4
4
|
import { validateHttpUrl } from "./config.ts";
|
|
5
5
|
import { mcError } from "./i18n.ts";
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ export const CLASSIFIER_APIS = new Set([
|
|
|
26
26
|
"cloudflare-workers-ai-system-one",
|
|
27
27
|
"openai-decisions",
|
|
28
28
|
]);
|
|
29
|
-
export const IMAGE_APIS = new Set(
|
|
29
|
+
export const IMAGE_APIS = new Set(IMAGE_API_NAMES);
|
|
30
30
|
|
|
31
31
|
export function assertSupportedProtocol(draft: ProviderDraft, type: "chat" | "classifier" | "image"): void {
|
|
32
32
|
const api = type === "chat" ? draft.chatApi : type === "classifier" ? draft.classifierApi : draft.imageApi;
|
|
@@ -87,6 +87,7 @@ export function applyProviderTransport<T extends TransportOptions>(
|
|
|
87
87
|
...next.headers,
|
|
88
88
|
authorization: null,
|
|
89
89
|
"x-api-key": null,
|
|
90
|
+
"x-goog-api-key": null,
|
|
90
91
|
"cf-aig-authorization": null,
|
|
91
92
|
};
|
|
92
93
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { AnyModel } from "@earendil-works/pi-ai";
|
|
2
2
|
|
|
3
3
|
export const MODEL_TYPES = ["chat", "classifier", "image"] as const;
|
|
4
|
+
export const IMAGE_API_NAMES = ["openrouter-images", "openai-images", "gemini-images", "xai-images", "dashscope-images"] as const;
|
|
4
5
|
export type ManagedModelType = (typeof MODEL_TYPES)[number];
|
|
6
|
+
export type ImageApiName = (typeof IMAGE_API_NAMES)[number];
|
|
5
7
|
export type ModelIdentity = `${string}\u0000${ManagedModelType}\u0000${string}`;
|
|
6
8
|
|
|
7
9
|
export type AuthMode = "models-json" | "reuse-pi" | "anonymous";
|
|
@@ -64,7 +66,7 @@ export interface ProviderConnectionConfig {
|
|
|
64
66
|
proxyUrl?: string;
|
|
65
67
|
chatApi?: string;
|
|
66
68
|
classifierApi?: string;
|
|
67
|
-
imageApi?:
|
|
69
|
+
imageApi?: ImageApiName;
|
|
68
70
|
defaultType?: ManagedModelType;
|
|
69
71
|
defaultContextWindow?: number;
|
|
70
72
|
defaultMaxTokens?: number;
|
|
@@ -111,7 +113,7 @@ export interface ProviderDraft {
|
|
|
111
113
|
proxyUrl?: string;
|
|
112
114
|
chatApi: string;
|
|
113
115
|
classifierApi: string;
|
|
114
|
-
imageApi:
|
|
116
|
+
imageApi: ImageApiName;
|
|
115
117
|
defaultType: ManagedModelType;
|
|
116
118
|
}
|
|
117
119
|
|