@juspay/neurolink 9.67.2 → 9.67.3

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.
@@ -1,15 +1,19 @@
1
1
  import type { AIProviderName } from "../constants/enums.js";
2
- import { BaseProvider } from "../core/baseProvider.js";
3
- import type { LanguageModel, Schema, StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
2
+ import type { OpenAICompatBuildBodyArgs, OpenAICompatStreamLifecycleListeners } from "../types/index.js";
3
+ import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
4
4
  /**
5
5
  * LiteLLM Provider — direct HTTP, no AI SDK. Talks to a LiteLLM proxy
6
6
  * server (or any deployment that speaks OpenAI chat-completions + the
7
7
  * `/v1/models` and `/v1/embeddings` endpoints).
8
+ *
9
+ * All request/stream/tool-loop orchestration lives in
10
+ * `OpenAIChatCompletionsProvider`. This class adds LiteLLM-specific
11
+ * behaviour: OTel span wrap with cost (`onStreamStart`), Gemini 2.5
12
+ * maxTokens skip (`adjustBuildBodyOptions`), ModelAccessDeniedError on
13
+ * 403, 10-minute model cache (`getAvailableModels`), `LITELLM_FALLBACK_MODELS`
14
+ * env-driven fallback list, and native `/v1/embeddings`.
8
15
  */
9
- export declare class LiteLLMProvider extends BaseProvider {
10
- private config;
11
- private credentials?;
12
- private resolvedModel?;
16
+ export declare class LiteLLMProvider extends OpenAIChatCompletionsProvider {
13
17
  private static modelsCache;
14
18
  private static modelsCacheTime;
15
19
  private static readonly MODELS_CACHE_DURATION;
@@ -19,30 +23,28 @@ export declare class LiteLLMProvider extends BaseProvider {
19
23
  });
20
24
  protected getProviderName(): AIProviderName;
21
25
  protected getDefaultModel(): string;
26
+ protected getFallbackModelName(): string;
27
+ protected getFallbackModels(): string[];
22
28
  /**
23
- * Abstract from BaseProvider used by the parent's generate() path which
24
- * still goes through `generateText`. Returns a thin LanguageModelV3-shaped
25
- * object that delegates to the same HTTP helpers used by executeStream.
29
+ * Gemini 2.5 models on LiteLLM have a known compatibility issue with
30
+ * `max_tokens` strip it before the wire body is built. Applies to
31
+ * both streaming and non-streaming paths.
26
32
  */
27
- protected getAISDKModel(): Promise<LanguageModel>;
28
- private resolveModelName;
33
+ protected adjustBuildBodyOptions(modelId: string, opts: OpenAICompatBuildBodyArgs["options"]): OpenAICompatBuildBodyArgs["options"];
29
34
  /**
30
- * Returns a minimal V3-shaped model. Only used by BaseProvider's
31
- * `generate()` non-streaming path which still relies on the parent's
32
- * `generateText`. The streaming path bypasses this entirely.
35
+ * Wrap the stream in an OTel span to capture provider-level latency,
36
+ * token usage, finish reason, and cost. Matches the pre-migration
37
+ * behaviour where streamText was wrapped in `neurolink.provider.streamText`.
33
38
  */
34
- private buildDelegatingModel;
39
+ protected onStreamStart(modelId: string): OpenAICompatStreamLifecycleListeners | undefined;
35
40
  formatProviderError(error: unknown): Error;
36
- supportsTools(): boolean;
37
41
  /**
38
- * Streaming path drives the LiteLLM proxy directly. No streamText, no
39
- * AI SDK orchestrator. Tool calls, multi-step loops, telemetry, abort
40
- * handling all inline. OTel span captures gen_ai.system + cost.
42
+ * Get available models from LiteLLM proxy `/v1/models` endpoint.
43
+ * Caches results for 10 minutes; falls back to env-driven list or a
44
+ * minimal safe default if the API fetch fails.
41
45
  */
42
- protected executeStream(options: StreamOptions, _analysisSchema?: ZodUnknownSchema | Schema<unknown>): Promise<StreamResult>;
43
- private runStreamLoop;
44
- private streamOneStep;
45
- private executeToolBatch;
46
+ getAvailableModels(): Promise<string[]>;
47
+ private fetchModelsFromAPI;
46
48
  /**
47
49
  * Generate an embedding for a single text input via native /v1/embeddings.
48
50
  */
@@ -52,13 +54,4 @@ export declare class LiteLLMProvider extends BaseProvider {
52
54
  */
53
55
  embedMany(texts: string[], modelName?: string): Promise<number[][]>;
54
56
  private callEmbeddings;
55
- /**
56
- * Get available models from LiteLLM proxy `/v1/models` endpoint.
57
- * Caches results for 10 minutes; falls back to env-driven list or a
58
- * minimal safe default if the API fetch fails.
59
- */
60
- getAvailableModels(): Promise<string[]>;
61
- getFirstAvailableModel(): Promise<string>;
62
- private getFallbackModels;
63
- private fetchModelsFromAPI;
64
57
  }