@byfriends/kosong 0.1.0 → 0.2.1
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/dist/{anthropic-Dm_GqFgS.d.mts → anthropic-0CVG5rBE.d.mts} +1 -2
- package/dist/{provider-DiJKWMsQ.d.mts → errors-wlT14tC4.d.mts} +227 -2
- package/dist/{google-genai-hX0X6CF3.d.mts → google-genai-xKK8lI_R.d.mts} +1 -2
- package/dist/index.d.mts +66 -12
- package/dist/index.mjs +945 -21
- package/dist/{openai-common-08qin3UI.mjs → openai-common-Dl42y_vn.mjs} +27 -2
- package/dist/{openai-common-B6cK2ig3.d.mts → openai-common-DwkxUSyI.d.mts} +7 -3
- package/dist/{openai-responses-BxOwxtd3.d.mts → openai-responses-DZ9mQ5RA.d.mts} +2 -2
- package/dist/providers/anthropic.d.mts +1 -1
- package/dist/providers/anthropic.mjs +56 -68
- package/dist/providers/google-genai.d.mts +1 -1
- package/dist/providers/google-genai.mjs +1 -2
- package/dist/providers/openai-common.d.mts +1 -1
- package/dist/providers/openai-common.mjs +1 -1
- package/dist/providers/openai-responses.d.mts +1 -1
- package/dist/providers/openai-responses.mjs +21 -4
- package/dist/request-auth-BMXt8jRu.mjs +341 -0
- package/package.json +1 -11
- package/dist/capability-registry-CMBuEYcf.mjs +0 -161
- package/dist/chat-completions-stream-BuMu_xr9.mjs +0 -62
- package/dist/errors-DweKbIOf.d.mts +0 -42
- package/dist/openai-compat-CMrIk-ib.d.mts +0 -132
- package/dist/openai-compat-CWbwO4b7.mjs +0 -801
- package/dist/openai-legacy-B6CVfLlr.d.mts +0 -71
- package/dist/providers/openai-compat.d.mts +0 -2
- package/dist/providers/openai-compat.mjs +0 -2
- package/dist/providers/openai-legacy.d.mts +0 -2
- package/dist/providers/openai-legacy.mjs +0 -248
- package/dist/request-auth-DCWSyCKI.mjs +0 -63
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { D as VideoURLPart, a as StreamedMessage, b as Message, i as ProviderRequestAuth, m as ModelCapability, o as ThinkingEffort, p as Tool, r as GenerateOptions, s as VideoUploadInput, t as ChatProvider } from "./provider-DiJKWMsQ.mjs";
|
|
2
|
-
import OpenAI from "openai";
|
|
3
|
-
|
|
4
|
-
//#region src/providers/openai-compat-files.d.ts
|
|
5
|
-
interface OpenAICompatUploadOptions {
|
|
6
|
-
auth?: ProviderRequestAuth;
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
}
|
|
9
|
-
interface OpenAICompatFilesOptions {
|
|
10
|
-
apiKey?: string;
|
|
11
|
-
baseUrl: string;
|
|
12
|
-
defaultHeaders?: Record<string, string>;
|
|
13
|
-
clientFactory?: (auth: ProviderRequestAuth) => OpenAI;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* OpenAI-compatible file upload client.
|
|
17
|
-
*
|
|
18
|
-
* Wraps the underlying OpenAI-compatible `files.create` API to upload videos
|
|
19
|
-
* to the file service and return them as {@link VideoURLPart} values
|
|
20
|
-
* suitable for use in chat messages.
|
|
21
|
-
*
|
|
22
|
-
* An `OpenAICompatFiles` instance is typically obtained from
|
|
23
|
-
* {@link OpenAICompatChatProvider.files}.
|
|
24
|
-
*/
|
|
25
|
-
declare class OpenAICompatFiles {
|
|
26
|
-
private readonly _apiKey;
|
|
27
|
-
private readonly _baseUrl;
|
|
28
|
-
private readonly _defaultHeaders;
|
|
29
|
-
private readonly _client;
|
|
30
|
-
private readonly _clientFactory;
|
|
31
|
-
constructor(options: OpenAICompatFilesOptions);
|
|
32
|
-
/**
|
|
33
|
-
* Upload a video file for use in chat messages.
|
|
34
|
-
*
|
|
35
|
-
* Accepts either a local filesystem path or an in-memory
|
|
36
|
-
* {@link VideoUploadInput}. Returns a {@link VideoURLPart} referencing the
|
|
37
|
-
* uploaded file by its file id.
|
|
38
|
-
*
|
|
39
|
-
* @param input - Local path string or `{ data, mimeType }` object.
|
|
40
|
-
* @returns A `VideoURLPart` whose `url` references the uploaded file
|
|
41
|
-
* by its file id (e.g. `ms://<file-id>`).
|
|
42
|
-
* @throws {ChatProviderError} if the input is not a video or the upload
|
|
43
|
-
* fails.
|
|
44
|
-
*/
|
|
45
|
-
uploadVideo(input: string | VideoUploadInput, options?: OpenAICompatUploadOptions): Promise<VideoURLPart>;
|
|
46
|
-
private _createClient;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/providers/openai-compat.d.ts
|
|
50
|
-
interface OpenAICompatOptions {
|
|
51
|
-
apiKey?: string;
|
|
52
|
-
baseUrl?: string;
|
|
53
|
-
model: string;
|
|
54
|
-
stream?: boolean;
|
|
55
|
-
defaultHeaders?: Record<string, string>;
|
|
56
|
-
thinkingEffortKey?: string;
|
|
57
|
-
generationKwargs?: GenerationKwargs;
|
|
58
|
-
clientFactory?: (auth: ProviderRequestAuth) => OpenAI;
|
|
59
|
-
}
|
|
60
|
-
interface GenerationKwargs {
|
|
61
|
-
/**
|
|
62
|
-
* Legacy completion-budget alias. Some OpenAI-compatible APIs still accept
|
|
63
|
-
* `max_tokens`, but for reasoning models it shares the budget with
|
|
64
|
-
* `reasoning_content` and a small value can cause a 200 response with no
|
|
65
|
-
* `content`. Prefer `max_completion_tokens`. When both are set
|
|
66
|
-
* `max_completion_tokens` wins; this provider normalizes by sending only
|
|
67
|
-
* `max_completion_tokens` on the wire.
|
|
68
|
-
*/
|
|
69
|
-
max_tokens?: number | undefined;
|
|
70
|
-
max_completion_tokens?: number | undefined;
|
|
71
|
-
temperature?: number | undefined;
|
|
72
|
-
top_p?: number | undefined;
|
|
73
|
-
n?: number | undefined;
|
|
74
|
-
presence_penalty?: number | undefined;
|
|
75
|
-
frequency_penalty?: number | undefined;
|
|
76
|
-
stop?: string | string[] | undefined;
|
|
77
|
-
reasoning_effort?: string | undefined;
|
|
78
|
-
prompt_cache_key?: string | undefined;
|
|
79
|
-
extra_body?: ExtraBody;
|
|
80
|
-
[key: string]: unknown;
|
|
81
|
-
}
|
|
82
|
-
interface ThinkingConfig {
|
|
83
|
-
type?: 'enabled' | 'disabled';
|
|
84
|
-
keep?: unknown;
|
|
85
|
-
[key: string]: unknown;
|
|
86
|
-
}
|
|
87
|
-
interface ExtraBody {
|
|
88
|
-
thinking?: ThinkingConfig;
|
|
89
|
-
[key: string]: unknown;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Extract usage from a streaming chunk. Some OpenAI-compatible providers may place usage in
|
|
93
|
-
* `choices[0].usage` in addition to the top-level `usage` field.
|
|
94
|
-
*/
|
|
95
|
-
declare function extractUsageFromChunk(chunk: Record<string, unknown>): Record<string, unknown> | null;
|
|
96
|
-
declare class OpenAICompatChatProvider implements ChatProvider {
|
|
97
|
-
readonly name: string;
|
|
98
|
-
private _model;
|
|
99
|
-
private _stream;
|
|
100
|
-
private _apiKey;
|
|
101
|
-
private _baseUrl;
|
|
102
|
-
private _defaultHeaders;
|
|
103
|
-
private _generationKwargs;
|
|
104
|
-
private _thinkingEffortKey;
|
|
105
|
-
private _client;
|
|
106
|
-
private _clientFactory;
|
|
107
|
-
private _files;
|
|
108
|
-
constructor(options: OpenAICompatOptions);
|
|
109
|
-
get modelName(): string;
|
|
110
|
-
/**
|
|
111
|
-
* File upload client for an OpenAI-compatible service.
|
|
112
|
-
*
|
|
113
|
-
* Use this to upload videos (and other media in the future) to the file
|
|
114
|
-
* service and receive a content part that can be embedded in chat
|
|
115
|
-
* messages.
|
|
116
|
-
*/
|
|
117
|
-
get files(): OpenAICompatFiles;
|
|
118
|
-
uploadVideo(input: string | VideoUploadInput, options?: GenerateOptions): Promise<VideoURLPart>;
|
|
119
|
-
get thinkingEffort(): ThinkingEffort | null;
|
|
120
|
-
get modelParameters(): Record<string, unknown>;
|
|
121
|
-
generate(systemPrompt: string, tools: Tool[], history: Message[], options?: GenerateOptions): Promise<StreamedMessage>;
|
|
122
|
-
getCapability(_model?: string): ModelCapability;
|
|
123
|
-
withThinking(effort: ThinkingEffort): OpenAICompatChatProvider;
|
|
124
|
-
withGenerationKwargs(kwargs: GenerationKwargs): OpenAICompatChatProvider;
|
|
125
|
-
withMaxCompletionTokens(maxCompletionTokens: number): OpenAICompatChatProvider;
|
|
126
|
-
withExtraBody(extraBody: ExtraBody): OpenAICompatChatProvider;
|
|
127
|
-
private _createClient;
|
|
128
|
-
private _withGenerationKwargs;
|
|
129
|
-
private _clone;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
export { ThinkingConfig as a, OpenAICompatOptions as i, GenerationKwargs as n, extractUsageFromChunk as o, OpenAICompatChatProvider as r, ExtraBody as t };
|