@juspay/neurolink 9.68.13 → 9.68.14
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 +2 -0
- package/dist/browser/neurolink.min.js +319 -319
- package/dist/lib/providers/openAI.d.ts +29 -57
- package/dist/lib/providers/openAI.js +184 -579
- package/dist/lib/utils/providerSetupMessages.js +1 -1
- package/dist/providers/openAI.d.ts +29 -57
- package/dist/providers/openAI.js +184 -579
- package/dist/utils/providerSetupMessages.js +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ export function getProviderSetupMessage(provider, missingVars) {
|
|
|
14
14
|
'OPENAI_API_KEY="sk-proj-your-openai-api-key"',
|
|
15
15
|
"# Optional:",
|
|
16
16
|
`OPENAI_MODEL="${OpenAIModels.GPT_4O}"`,
|
|
17
|
-
'OPENAI_BASE_URL="https://api.openai.com"',
|
|
17
|
+
'OPENAI_BASE_URL="https://api.openai.com/v1"',
|
|
18
18
|
],
|
|
19
19
|
},
|
|
20
20
|
anthropic: {
|
|
@@ -1,78 +1,51 @@
|
|
|
1
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type { EnhancedGenerateResult, TextGenerationOptions, ValidationSchema, StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
-
import type { LanguageModel } from "../types/index.js";
|
|
1
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
2
|
+
import type { EnhancedGenerateResult, NeurolinkCredentials, OpenAICompatStreamLifecycleListeners, TextGenerationOptions } from "../types/index.js";
|
|
3
|
+
import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
6
4
|
/**
|
|
7
|
-
* OpenAI Provider
|
|
8
|
-
*
|
|
5
|
+
* OpenAI Provider — direct HTTP, no AI SDK.
|
|
6
|
+
*
|
|
7
|
+
* OpenAI chat completions at api.openai.com/v1. All request / stream /
|
|
8
|
+
* tool-loop orchestration lives in `OpenAIChatCompletionsProvider`; this
|
|
9
|
+
* class adds:
|
|
10
|
+
* - OTel span wrap with cost (`onStreamStart`)
|
|
11
|
+
* - Native `/v1/embeddings` (`embed` / `embedMany`)
|
|
12
|
+
* - Image generation via `/v1/images/generations` (`executeImageGeneration`)
|
|
13
|
+
* - OpenAI-specific error mapping (`formatProviderError`)
|
|
14
|
+
*
|
|
15
|
+
* @see https://platform.openai.com/docs/api-reference
|
|
9
16
|
*/
|
|
10
|
-
export declare class OpenAIProvider extends
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
baseURL?: string;
|
|
16
|
-
});
|
|
17
|
+
export declare class OpenAIProvider extends OpenAIChatCompletionsProvider {
|
|
18
|
+
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["openai"]);
|
|
19
|
+
protected getProviderName(): AIProviderName;
|
|
20
|
+
protected getDefaultModel(): string;
|
|
21
|
+
formatProviderError(error: unknown): Error;
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
23
|
+
* Wrap the stream in an OTel span to capture provider-level latency,
|
|
24
|
+
* token usage, finish reason, and cost. Mirrors the pre-migration
|
|
25
|
+
* `streamText`-span behaviour.
|
|
19
26
|
*/
|
|
20
|
-
|
|
21
|
-
getProviderName(): AIProviderName;
|
|
22
|
-
getDefaultModel(): string;
|
|
27
|
+
protected onStreamStart(modelId: string): OpenAICompatStreamLifecycleListeners | undefined;
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @returns The default OpenAI embedding model name
|
|
29
|
+
* Default embedding model, overridable via OPENAI_EMBEDDING_MODEL env var.
|
|
26
30
|
*/
|
|
27
31
|
protected getDefaultEmbeddingModel(): string;
|
|
28
32
|
/**
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
getAISDKModel(): LanguageModel;
|
|
32
|
-
/**
|
|
33
|
-
* OpenAI-specific tool validation and filtering
|
|
34
|
-
* Filters out tools that might cause streaming issues
|
|
35
|
-
*/
|
|
36
|
-
private validateAndFilterToolsForOpenAI;
|
|
37
|
-
/**
|
|
38
|
-
* Validate Zod schema structure
|
|
39
|
-
*/
|
|
40
|
-
private validateZodSchema;
|
|
41
|
-
/**
|
|
42
|
-
* Validate tool structure for OpenAI compatibility
|
|
43
|
-
* More lenient validation to avoid filtering out valid tools
|
|
44
|
-
*/
|
|
45
|
-
/** Shared helper: mark a stream span as ERROR, record the exception, and end it. */
|
|
46
|
-
private endStreamSpanWithError;
|
|
47
|
-
private isValidToolStructure;
|
|
48
|
-
/**
|
|
49
|
-
* Validate tool parameters for OpenAI compatibility
|
|
50
|
-
* Ensures the tool has either valid Zod schema or valid JSON schema
|
|
51
|
-
*/
|
|
52
|
-
private isValidToolParameters;
|
|
53
|
-
formatProviderError(error: unknown): Error;
|
|
54
|
-
/**
|
|
55
|
-
* executeGenerate method removed - generation is now handled by BaseProvider.
|
|
56
|
-
* For details on the changes and migration steps, refer to the BaseProvider documentation
|
|
57
|
-
* and the migration guide in the project repository.
|
|
58
|
-
*/
|
|
59
|
-
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
60
|
-
private createOpenAITransformedStream;
|
|
61
|
-
private extractOpenAIChunkContent;
|
|
62
|
-
/**
|
|
63
|
-
* Generate embeddings for text using OpenAI text-embedding models
|
|
33
|
+
* Generate an embedding for a single text input via native /v1/embeddings.
|
|
34
|
+
*
|
|
64
35
|
* @param text - The text to embed
|
|
65
36
|
* @param modelName - The embedding model to use (default: text-embedding-3-small)
|
|
66
37
|
* @returns Promise resolving to the embedding vector
|
|
67
38
|
*/
|
|
68
39
|
embed(text: string, modelName?: string): Promise<number[]>;
|
|
69
40
|
/**
|
|
70
|
-
* Generate embeddings for multiple texts in a single batch
|
|
41
|
+
* Generate embeddings for multiple texts in a single batch via native /v1/embeddings.
|
|
42
|
+
*
|
|
71
43
|
* @param texts - The texts to embed
|
|
72
44
|
* @param modelName - The embedding model to use (default: text-embedding-3-small)
|
|
73
45
|
* @returns Promise resolving to an array of embedding vectors
|
|
74
46
|
*/
|
|
75
47
|
embedMany(texts: string[], modelName?: string): Promise<number[][]>;
|
|
48
|
+
private callEmbeddings;
|
|
76
49
|
/**
|
|
77
50
|
* Image generation via the OpenAI Images API (`/v1/images/generations`).
|
|
78
51
|
*
|
|
@@ -95,4 +68,3 @@ export declare class OpenAIProvider extends BaseProvider {
|
|
|
95
68
|
*/
|
|
96
69
|
private aspectRatioToOpenAISize;
|
|
97
70
|
}
|
|
98
|
-
export default OpenAIProvider;
|