llm-proxy 1.0.27 → 1.0.29

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,22 +1,8 @@
1
- export declare class AdapterError extends Error {
2
- details?: any;
3
- constructor(message: string, details?: any);
4
- }
5
- export declare class UnsupportedProviderError extends AdapterError {
6
- constructor(provider: string);
7
- }
8
- export declare class ContentExtractionError extends AdapterError {
9
- constructor(contentType: string, details?: any);
10
- }
11
- export declare class ResponseValidationError extends AdapterError {
12
- response?: any;
13
- constructor(message: string, response?: any);
14
- }
15
1
  import { LLMResponse, Providers } from "../types";
16
2
  export declare class OutputFormatAdapter {
17
3
  static adaptResponse(response: any, provider: Providers): LLMResponse;
18
- private static validateOpenAIResponse;
19
- private static adaptAnthropicBedrockResponse;
4
+ private static adaptCompleteResponse;
5
+ private static adaptStreamingResponse;
20
6
  private static mapRole;
21
7
  private static extractContent;
22
8
  }
@@ -1,73 +1,62 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OutputFormatAdapter = exports.ResponseValidationError = exports.ContentExtractionError = exports.UnsupportedProviderError = exports.AdapterError = void 0;
4
- // Custom error classes
5
- class AdapterError extends Error {
6
- constructor(message, details) {
7
- super(message);
8
- this.details = details;
9
- this.name = "AdapterError";
10
- }
11
- }
12
- exports.AdapterError = AdapterError;
13
- class UnsupportedProviderError extends AdapterError {
14
- constructor(provider) {
15
- super(`Unsupported provider: ${provider}`);
16
- this.name = "UnsupportedProviderError";
17
- }
18
- }
19
- exports.UnsupportedProviderError = UnsupportedProviderError;
20
- class ContentExtractionError extends AdapterError {
21
- constructor(contentType, details) {
22
- super(`Failed to extract content for type: ${contentType}`, details);
23
- this.name = "ContentExtractionError";
24
- }
25
- }
26
- exports.ContentExtractionError = ContentExtractionError;
27
- class ResponseValidationError extends AdapterError {
28
- constructor(message, response) {
29
- super(message);
30
- this.response = response;
31
- this.name = "ResponseValidationError";
32
- }
33
- }
34
- exports.ResponseValidationError = ResponseValidationError;
3
+ exports.OutputFormatAdapter = void 0;
35
4
  const types_1 = require("../types");
36
5
  class OutputFormatAdapter {
37
6
  static adaptResponse(response, provider) {
38
7
  if (!response) {
39
- throw new ResponseValidationError("Response object is null or undefined");
8
+ throw new Error("Response object is null or undefined");
40
9
  }
41
10
  try {
42
11
  switch (provider) {
43
12
  case types_1.Providers.OPENAI:
44
- this.validateOpenAIResponse(response);
45
13
  return response;
46
14
  case types_1.Providers.ANTHROPIC_BEDROCK:
47
- return this.adaptAnthropicBedrockResponse(response);
15
+ // Check if it's a streaming chunk or complete response
16
+ if (response.type === "message" && !response.delta) {
17
+ return this.adaptCompleteResponse(response);
18
+ }
19
+ else {
20
+ return this.adaptStreamingResponse(response);
21
+ }
48
22
  default:
49
- throw new UnsupportedProviderError(provider);
23
+ throw new Error(`Unsupported provider: ${provider}`);
50
24
  }
51
25
  }
52
26
  catch (error) {
53
- if (error instanceof AdapterError) {
54
- throw error;
55
- }
56
- throw new AdapterError("Failed to adapt response", {
57
- provider,
58
- originalError: error,
59
- });
27
+ throw new Error(`Failed to adapt response: ${error.message}`);
60
28
  }
61
29
  }
62
- static validateOpenAIResponse(response) {
63
- if (!response.id || !response.choices) {
64
- throw new ResponseValidationError("Invalid OpenAI response structure", response);
65
- }
30
+ static adaptCompleteResponse(response) {
31
+ return {
32
+ id: response.id,
33
+ object: "text_completion",
34
+ created: Date.now(),
35
+ model: response.model,
36
+ choices: response.content.map((contentBlock, index) => ({
37
+ index,
38
+ message: {
39
+ role: this.mapRole(contentBlock),
40
+ content: this.extractContent(contentBlock),
41
+ },
42
+ logprobs: null,
43
+ finish_reason: response.stop_reason || null,
44
+ })),
45
+ usage: {
46
+ prompt_tokens: response.usage.input_tokens,
47
+ completion_tokens: response.usage.output_tokens,
48
+ total_tokens: response.usage.input_tokens + response.usage.output_tokens,
49
+ prompt_tokens_details: { cached_tokens: 0 },
50
+ completion_tokens_details: { reasoning_tokens: 0 },
51
+ },
52
+ system_fingerprint: "anthropic_translation",
53
+ };
66
54
  }
67
- static adaptAnthropicBedrockResponse(response) {
55
+ static adaptStreamingResponse(chunk) {
68
56
  var _a, _b;
69
- // Handle content_block_stop message
70
- if (response.type === "content_block_stop") {
57
+ // Handle stop messages
58
+ if (chunk.type === "content_block_stop" || chunk.type === "message_stop") {
59
+ const metrics = chunk["amazon-bedrock-invocationMetrics"];
71
60
  return {
72
61
  id: `stream-${Date.now()}`,
73
62
  object: "text_completion",
@@ -78,130 +67,53 @@ class OutputFormatAdapter {
78
67
  index: 0,
79
68
  message: {
80
69
  role: "assistant",
81
- content: "", // Empty content for stop message
70
+ content: "",
82
71
  },
83
72
  logprobs: null,
84
73
  finish_reason: "stop",
85
74
  },
86
75
  ],
87
76
  usage: {
88
- prompt_tokens: 0,
89
- completion_tokens: 0,
90
- total_tokens: 0,
91
- prompt_tokens_details: { cached_tokens: 0 },
92
- completion_tokens_details: { reasoning_tokens: 0 },
93
- },
94
- system_fingerprint: "anthropic_translation",
95
- };
96
- }
97
- // Handle streaming content blocks
98
- if (response.type === "content_block_start" || response.content_block) {
99
- return {
100
- id: `stream-${Date.now()}`,
101
- object: "text_completion",
102
- created: Date.now(),
103
- model: "anthropic.claude-3-haiku", // This will be overwritten in complete response
104
- choices: [
105
- {
106
- index: 0,
107
- message: {
108
- role: "assistant",
109
- content: ((_a = response.content_block) === null || _a === void 0 ? void 0 : _a.text) || "",
110
- },
111
- logprobs: null,
112
- finish_reason: "null",
113
- },
114
- ],
115
- usage: {
116
- prompt_tokens: 0,
117
- completion_tokens: 0,
118
- total_tokens: 0,
77
+ prompt_tokens: (metrics === null || metrics === void 0 ? void 0 : metrics.inputTokenCount) || 0,
78
+ completion_tokens: (metrics === null || metrics === void 0 ? void 0 : metrics.outputTokenCount) || 0,
79
+ total_tokens: ((metrics === null || metrics === void 0 ? void 0 : metrics.inputTokenCount) || 0) + ((metrics === null || metrics === void 0 ? void 0 : metrics.outputTokenCount) || 0),
119
80
  prompt_tokens_details: { cached_tokens: 0 },
120
81
  completion_tokens_details: { reasoning_tokens: 0 },
121
82
  },
122
83
  system_fingerprint: "anthropic_translation",
123
84
  };
124
85
  }
125
- // Rest of the existing code remains the same...
126
- // Handle complete message response
127
- if (response.message) {
128
- if (!((_b = response.message) === null || _b === void 0 ? void 0 : _b.id) ||
129
- !response.message.model ||
130
- !response.message.content ||
131
- !response.message.usage) {
132
- throw new ResponseValidationError("Invalid Anthropic Bedrock response structure", response);
133
- }
134
- try {
135
- const openAIResponse = {
136
- id: response.message.id,
137
- object: "text_completion",
138
- created: Date.now(),
139
- model: response.message.model,
140
- choices: response.message.content.map((contentBlock, index) => {
141
- var _a;
142
- return ({
143
- index,
144
- message: {
145
- role: this.mapRole(contentBlock),
146
- content: this.extractContent(contentBlock),
147
- },
148
- logprobs: null,
149
- finish_reason: ((_a = response.message) === null || _a === void 0 ? void 0 : _a.stop_reason) || "",
150
- });
151
- }),
152
- usage: {
153
- prompt_tokens: response.message.usage.input_tokens,
154
- completion_tokens: response.message.usage.output_tokens,
155
- total_tokens: response.message.usage.input_tokens +
156
- response.message.usage.output_tokens,
157
- prompt_tokens_details: { cached_tokens: 0 },
158
- completion_tokens_details: { reasoning_tokens: 0 },
159
- },
160
- system_fingerprint: "anthropic_translation",
161
- };
162
- return openAIResponse;
163
- }
164
- catch (error) {
165
- throw new AdapterError("Failed to adapt Anthropic response", {
166
- responseId: response.message.id,
167
- originalError: error,
168
- });
169
- }
170
- }
171
- // Handle other message types (delta updates, metrics, etc.)
172
- if (response.delta) {
173
- return {
174
- id: `stream-${Date.now()}`,
175
- object: "text_completion",
176
- created: Date.now(),
177
- model: "anthropic.claude-3-haiku",
178
- choices: [
179
- {
180
- index: 0,
181
- message: {
182
- role: "assistant",
183
- content: response.delta.text || "",
184
- },
185
- logprobs: null,
186
- finish_reason: "null",
86
+ // Handle content blocks or deltas
87
+ const content = ((_a = chunk.content_block) === null || _a === void 0 ? void 0 : _a.text) || ((_b = chunk.delta) === null || _b === void 0 ? void 0 : _b.text) || "";
88
+ return {
89
+ id: `stream-${Date.now()}`,
90
+ object: "text_completion",
91
+ created: Date.now(),
92
+ model: "anthropic.claude-3-haiku",
93
+ choices: [
94
+ {
95
+ index: 0,
96
+ message: {
97
+ role: "assistant",
98
+ content,
187
99
  },
188
- ],
189
- usage: {
190
- prompt_tokens: 0,
191
- completion_tokens: 0,
192
- total_tokens: 0,
193
- prompt_tokens_details: { cached_tokens: 0 },
194
- completion_tokens_details: { reasoning_tokens: 0 },
100
+ logprobs: null,
101
+ finish_reason: "null",
195
102
  },
196
- system_fingerprint: "anthropic_translation",
197
- };
198
- }
199
- // If none of the above conditions match, throw an error
200
- throw new ResponseValidationError("Invalid Anthropic Bedrock response structure", response);
103
+ ],
104
+ usage: {
105
+ prompt_tokens: 0,
106
+ completion_tokens: 0,
107
+ total_tokens: 0,
108
+ prompt_tokens_details: { cached_tokens: 0 },
109
+ completion_tokens_details: { reasoning_tokens: 0 },
110
+ },
111
+ system_fingerprint: "anthropic_translation",
112
+ };
201
113
  }
202
114
  static mapRole(content) {
203
115
  if (!content || !content.type) {
204
- throw new ContentExtractionError("Invalid content block structure");
116
+ throw new Error("Invalid content block structure");
205
117
  }
206
118
  switch (content.type) {
207
119
  case types_1.BedrockAnthropicContentType.TOOL_USE:
@@ -210,34 +122,23 @@ class OutputFormatAdapter {
210
122
  case types_1.BedrockAnthropicContentType.TEXT:
211
123
  return "assistant";
212
124
  default:
213
- throw new ContentExtractionError(`Unknown content type: ${content.type}`);
125
+ return "assistant"; // Default to assistant for unknown types
214
126
  }
215
127
  }
216
128
  static extractContent(content) {
217
129
  if (!content || !content.type) {
218
- throw new ContentExtractionError("Invalid content block structure");
130
+ throw new Error("Invalid content block structure");
219
131
  }
220
- try {
221
- switch (content.type) {
222
- case types_1.BedrockAnthropicContentType.TEXT:
223
- const textContent = content;
224
- if (!textContent.text) {
225
- throw new ContentExtractionError("Missing text in TEXT content");
226
- }
227
- return textContent.text;
228
- case types_1.BedrockAnthropicContentType.TOOL_RESULT:
229
- return content.content || "";
230
- case types_1.BedrockAnthropicContentType.TOOL_USE:
231
- return content.id || "";
232
- default:
233
- throw new ContentExtractionError(`Unsupported content type: ${content.type}`);
234
- }
235
- }
236
- catch (error) {
237
- throw new ContentExtractionError(`Failed to extract content`, {
238
- contentType: content.type,
239
- originalError: error,
240
- });
132
+ switch (content.type) {
133
+ case types_1.BedrockAnthropicContentType.TEXT:
134
+ const textContent = content;
135
+ return textContent.text || "";
136
+ case types_1.BedrockAnthropicContentType.TOOL_RESULT:
137
+ return content.content || "";
138
+ case types_1.BedrockAnthropicContentType.TOOL_USE:
139
+ return content.id || "";
140
+ default:
141
+ return "";
241
142
  }
242
143
  }
243
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OutputFormatAdapter.js","sourceRoot":"","sources":["../../src/middleware/OutputFormatAdapter.ts"],"names":[],"mappings":";;;AAAA,uBAAuB;AACvB,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe,EAAS,OAAa;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,YAAO,GAAP,OAAO,CAAM;QAE/C,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,MAAa,wBAAyB,SAAQ,YAAY;IACxD,YAAY,QAAgB;QAC1B,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AALD,4DAKC;AAED,MAAa,sBAAuB,SAAQ,YAAY;IACtD,YAAY,WAAmB,EAAE,OAAa;QAC5C,KAAK,CAAC,uCAAuC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED,MAAa,uBAAwB,SAAQ,YAAY;IACvD,YAAY,OAAe,EAAS,QAAc;QAChD,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IACH,CAAC;CACF;AAvJD,kDAuJC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-proxy",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "An LLM Proxy that allows the user to interact with different language models from different providers using unified request and response formats.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",