@juspay/neurolink 9.67.2 → 9.68.0
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/CHANGELOG.md +8 -0
- package/dist/browser/neurolink.min.js +345 -345
- package/dist/lib/providers/litellm.d.ts +25 -32
- package/dist/lib/providers/litellm.js +132 -601
- package/dist/lib/providers/openaiChatCompletionsBase.d.ts +123 -0
- package/dist/lib/providers/openaiChatCompletionsBase.js +685 -0
- package/dist/lib/providers/openaiChatCompletionsClient.d.ts +3 -0
- package/dist/lib/providers/openaiChatCompletionsClient.js +39 -0
- package/dist/lib/providers/openaiCompatible.d.ts +7 -63
- package/dist/lib/providers/openaiCompatible.js +27 -658
- package/dist/lib/types/openaiCompatible.d.ts +20 -1
- package/dist/providers/litellm.d.ts +25 -32
- package/dist/providers/litellm.js +132 -601
- package/dist/providers/openaiChatCompletionsBase.d.ts +123 -0
- package/dist/providers/openaiChatCompletionsBase.js +684 -0
- package/dist/providers/openaiChatCompletionsClient.d.ts +3 -0
- package/dist/providers/openaiChatCompletionsClient.js +39 -0
- package/dist/providers/openaiCompatible.d.ts +7 -63
- package/dist/providers/openaiCompatible.js +27 -658
- package/dist/types/openaiCompatible.d.ts +20 -1
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for providers that talk to an OpenAI chat-completions
|
|
3
|
+
* shaped HTTP endpoint. Owns the entire request/stream/tool-loop pipeline
|
|
4
|
+
* so concrete providers only declare configuration + provider-specific
|
|
5
|
+
* quirks (env var names, default model, error mapping).
|
|
6
|
+
*
|
|
7
|
+
* Currently extended by:
|
|
8
|
+
* - OpenAICompatibleProvider (generic /v1/chat/completions backend)
|
|
9
|
+
* - LiteLLMProvider (LiteLLM proxy server)
|
|
10
|
+
* - DeepSeekProvider (api.deepseek.com)
|
|
11
|
+
*
|
|
12
|
+
* Subclasses provide:
|
|
13
|
+
* - getProviderName() / getDefaultModel() / formatProviderError() (abstract)
|
|
14
|
+
* - optional overrides: getFallbackModelName, getFallbackModels,
|
|
15
|
+
* adjustBuildBodyOptions, onStreamStart, getAvailableModels
|
|
16
|
+
*
|
|
17
|
+
* Nothing here imports from "ai" or "@ai-sdk/*". The base class is a
|
|
18
|
+
* direct HTTP client + multi-step tool-execution loop driven by SSE.
|
|
19
|
+
*/
|
|
20
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
21
|
+
import { BaseProvider } from "../core/baseProvider.js";
|
|
22
|
+
import type { LanguageModel, OpenAICompatBuildBodyArgs, OpenAICompatChatRequest, OpenAICompatResponseFormat, OpenAICompatStreamLifecycleListeners, Schema, StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
|
|
23
|
+
/**
|
|
24
|
+
* Abstract HTTP+SSE provider for OpenAI chat-completions-shaped endpoints.
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
27
|
+
protected config: {
|
|
28
|
+
baseURL: string;
|
|
29
|
+
apiKey: string;
|
|
30
|
+
};
|
|
31
|
+
protected resolvedModel?: string;
|
|
32
|
+
constructor(providerName: AIProviderName, modelName: string | undefined, sdk: unknown, config: {
|
|
33
|
+
baseURL: string;
|
|
34
|
+
apiKey: string;
|
|
35
|
+
});
|
|
36
|
+
protected abstract getProviderName(): AIProviderName;
|
|
37
|
+
protected abstract getDefaultModel(): string;
|
|
38
|
+
protected abstract formatProviderError(error: unknown): Error;
|
|
39
|
+
/**
|
|
40
|
+
* Model name to return when `getDefaultModel()` is empty AND
|
|
41
|
+
* auto-discovery via `/models` finds nothing. Default "gpt-3.5-turbo".
|
|
42
|
+
*/
|
|
43
|
+
protected getFallbackModelName(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Hardcoded model names returned from `getAvailableModels()` when the
|
|
46
|
+
* remote `/models` endpoint can't be reached. Default empty.
|
|
47
|
+
*/
|
|
48
|
+
protected getFallbackModels(): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Hook to mutate the `buildBody` options before the wire body is
|
|
51
|
+
* constructed. Default identity. Override for model-specific quirks
|
|
52
|
+
* (e.g. LiteLLM's Gemini 2.5 maxTokens skip).
|
|
53
|
+
*/
|
|
54
|
+
protected adjustBuildBodyOptions(_modelId: string, opts: OpenAICompatBuildBodyArgs["options"]): OpenAICompatBuildBodyArgs["options"];
|
|
55
|
+
/**
|
|
56
|
+
* Hook to adjust the OpenAI `response_format` after it's converted from the
|
|
57
|
+
* V3 responseFormat (non-streaming `doGenerate` path). Default identity.
|
|
58
|
+
* Override for providers that don't support a given format type — e.g.
|
|
59
|
+
* DeepSeek rejects `response_format: { type: "json_schema" }` ("This
|
|
60
|
+
* response_format type is unavailable now"); the `@ai-sdk/openai-compatible`
|
|
61
|
+
* path this replaced declared `supportsStructuredOutputs: false`, which
|
|
62
|
+
* downgraded `json_schema` to `json_object`. Subclasses replicate that here.
|
|
63
|
+
*/
|
|
64
|
+
protected adjustResponseFormat(rf: OpenAICompatResponseFormat | undefined, _modelId: string): OpenAICompatResponseFormat | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Hook to adjust the fully-built wire request body before it is sent, on
|
|
67
|
+
* both the streaming and non-streaming paths. Default identity. Override for
|
|
68
|
+
* provider/model quirks that can't be expressed through buildBody options —
|
|
69
|
+
* e.g. Azure's newer reasoning deployments (o-series, gpt-5+) reject
|
|
70
|
+
* `max_tokens` and require `max_completion_tokens`.
|
|
71
|
+
*/
|
|
72
|
+
protected adjustRequestBody(body: OpenAICompatChatRequest, _modelId: string): OpenAICompatChatRequest;
|
|
73
|
+
/**
|
|
74
|
+
* Hook called once at the start of every `executeStream` invocation.
|
|
75
|
+
* Return lifecycle listeners (onUsage / onFinish) to receive deferred
|
|
76
|
+
* analytics events as the stream progresses. Default returns undefined
|
|
77
|
+
* (no extra wiring). LiteLLM uses this for the OTel span wrap with cost.
|
|
78
|
+
*/
|
|
79
|
+
protected onStreamStart(_modelId: string): OpenAICompatStreamLifecycleListeners | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true if `resolveModelName` should fall back to fetching
|
|
82
|
+
* `getAvailableModels()` and picking the first one when no explicit
|
|
83
|
+
* model is configured. Default true. Subclasses with a non-empty
|
|
84
|
+
* `getDefaultModel()` will never hit this branch anyway.
|
|
85
|
+
*/
|
|
86
|
+
protected shouldAutoDiscoverModel(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Builds the chat-completions request URL for a model. Default is
|
|
89
|
+
* `${baseURL}/chat/completions`. Override for providers with a different
|
|
90
|
+
* routing scheme (e.g. Azure's deployment-based path + api-version query).
|
|
91
|
+
*/
|
|
92
|
+
protected getChatCompletionsURL(_modelId: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* Auth headers merged into every request. Default is a Bearer token.
|
|
95
|
+
* Override for providers that authenticate differently (e.g. Azure, which
|
|
96
|
+
* uses an `api-key` header instead of `Authorization: Bearer`).
|
|
97
|
+
*/
|
|
98
|
+
protected getAuthHeaders(): Record<string, string>;
|
|
99
|
+
supportsTools(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Returns a minimal V3-shaped model used by BaseProvider's `generate()`
|
|
102
|
+
* non-streaming path. Driven by the parent's `generateText`. The
|
|
103
|
+
* streaming path bypasses this entirely.
|
|
104
|
+
*/
|
|
105
|
+
protected getAISDKModel(): Promise<LanguageModel>;
|
|
106
|
+
protected resolveModelName(): Promise<string>;
|
|
107
|
+
private buildDelegatingModel;
|
|
108
|
+
/**
|
|
109
|
+
* Streaming path — drives the chat-completions endpoint directly. No
|
|
110
|
+
* streamText, no AI SDK orchestrator. Tool calls, multi-step loops,
|
|
111
|
+
* telemetry, abort handling all inline.
|
|
112
|
+
*/
|
|
113
|
+
protected executeStream(options: StreamOptions, _analysisSchema?: ZodUnknownSchema | Schema<unknown>): Promise<StreamResult>;
|
|
114
|
+
private runStreamLoop;
|
|
115
|
+
private streamOneStep;
|
|
116
|
+
private executeToolBatch;
|
|
117
|
+
/**
|
|
118
|
+
* Default implementation hits `${baseURL}/models`. Subclasses with a
|
|
119
|
+
* different endpoint path, caching, or fallback strategy should override.
|
|
120
|
+
*/
|
|
121
|
+
getAvailableModels(): Promise<string[]>;
|
|
122
|
+
getFirstAvailableModel(): Promise<string>;
|
|
123
|
+
}
|