llm-proxy 1.0.0 → 1.0.2
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/clients/AwsBedrockAnthropicClient.d.ts +0 -0
- package/{src/clients/AwsBedrockAnthropicClient.ts → dist/clients/AwsBedrockAnthropicClient.js} +2 -5
- package/dist/clients/AwsBedrockAnthropicClient.js.map +1 -0
- package/dist/clients/OpenAIClient.d.ts +0 -0
- package/{src/clients/OpenAIClient.ts → dist/clients/OpenAIClient.js} +2 -9
- package/dist/clients/OpenAIClient.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +120 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/InputFormatAdapter.d.ts +4 -0
- package/dist/middleware/InputFormatAdapter.js +40 -0
- package/dist/middleware/InputFormatAdapter.js.map +1 -0
- package/dist/middleware/OutputFormatAdapter.d.ts +7 -0
- package/dist/middleware/OutputFormatAdapter.js +67 -0
- package/dist/middleware/OutputFormatAdapter.js.map +1 -0
- package/dist/middleware/ProviderFinder.d.ts +4 -0
- package/dist/middleware/ProviderFinder.js +19 -0
- package/dist/middleware/ProviderFinder.js.map +1 -0
- package/dist/services/AwsBedrockAnthropicService.d.ts +8 -0
- package/dist/services/AwsBedrockAnthropicService.js +110 -0
- package/dist/services/AwsBedrockAnthropicService.js.map +1 -0
- package/dist/services/ClientService.d.ts +5 -0
- package/dist/services/ClientService.js +3 -0
- package/dist/services/ClientService.js.map +1 -0
- package/dist/services/OpenAIService.d.ts +11 -0
- package/dist/services/OpenAIService.js +104 -0
- package/dist/services/OpenAIService.js.map +1 -0
- package/dist/types/index.d.ts +194 -0
- package/dist/types/index.js +50 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +9 -3
- package/docs/directoryStructure.png +0 -0
- package/docs/plan.excalidraw +0 -1758
- package/docs/plan.png +0 -0
- package/jest.config.js +0 -10
- package/src/index.ts +0 -145
- package/src/middleware/InputFormatAdapter.ts +0 -51
- package/src/middleware/OutputFormatAdapter.ts +0 -83
- package/src/middleware/ProviderFinder.ts +0 -23
- package/src/services/AwsBedrockAnthropicService.ts +0 -111
- package/src/services/ClientService.ts +0 -29
- package/src/services/OpenAIService.ts +0 -68
- package/src/test/AwsBedrockAnthropicClient.test.ts +0 -98
- package/src/test/AwsBedrockAnthropicStreamClient.test.ts +0 -81
- package/src/test/OpenAIClient.test.ts +0 -58
- package/src/types/index.ts +0 -234
- package/tsconfig.json +0 -110
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
12
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
13
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
14
|
+
var m = o[Symbol.asyncIterator], i;
|
|
15
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
16
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
17
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
18
|
+
};
|
|
19
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
24
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
25
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
26
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
27
|
+
function fulfill(value) { resume("next", value); }
|
|
28
|
+
function reject(value) { resume("throw", value); }
|
|
29
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.OpenAIService = void 0;
|
|
36
|
+
const openai_1 = __importDefault(require("openai"));
|
|
37
|
+
class OpenAIService {
|
|
38
|
+
constructor(apiKey) {
|
|
39
|
+
this.openai = new openai_1.default({ apiKey });
|
|
40
|
+
}
|
|
41
|
+
generateCompletion(messages, model, maxTokens, temperature, systemPrompt, // Optional parameter
|
|
42
|
+
tools // Optional parameter
|
|
43
|
+
) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (model.type !== "OpenAI") {
|
|
46
|
+
throw new Error("Unsupported model type for OpenAIService.");
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const response = yield this.openai.chat.completions.create({
|
|
50
|
+
model: model.model,
|
|
51
|
+
messages,
|
|
52
|
+
max_tokens: maxTokens,
|
|
53
|
+
temperature,
|
|
54
|
+
});
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error("Error generating text:", error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
generateStreamCompletion(messages, model, maxTokens, temperature, systemPrompt, // Optional parameter
|
|
64
|
+
tools, // Optional parameter
|
|
65
|
+
stream // Optional parameter
|
|
66
|
+
) {
|
|
67
|
+
return __asyncGenerator(this, arguments, function* generateStreamCompletion_1() {
|
|
68
|
+
var _a, e_1, _b, _c;
|
|
69
|
+
if (model.type !== "OpenAI") {
|
|
70
|
+
throw new Error("Unsupported model type for OpenAIService.");
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const stream = yield __await(this.openai.chat.completions.create({
|
|
74
|
+
model: model.model,
|
|
75
|
+
messages,
|
|
76
|
+
max_tokens: maxTokens,
|
|
77
|
+
temperature,
|
|
78
|
+
stream: true,
|
|
79
|
+
}));
|
|
80
|
+
try {
|
|
81
|
+
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
|
|
82
|
+
_c = stream_1_1.value;
|
|
83
|
+
_d = false;
|
|
84
|
+
const chunk = _c;
|
|
85
|
+
yield yield __await(chunk);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
89
|
+
finally {
|
|
90
|
+
try {
|
|
91
|
+
if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
|
|
92
|
+
}
|
|
93
|
+
finally { if (e_1) throw e_1.error; }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error("Error in stream completion:", error);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.OpenAIService = OpenAIService;
|
|
104
|
+
//# sourceMappingURL=OpenAIService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAIService.js","sourceRoot":"","sources":["../../src/services/OpenAIService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAI5B,MAAa,aAAa;IAGxB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;IAEK,kBAAkB,CACtB,QAAwB,EACxB,KAAoB,EACpB,SAAiB,EACjB,WAAmB,EACnB,YAAqB,EAAE,qBAAqB;IAC5C,KAAW,CAAC,qBAAqB;;;YAEjC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAC/D,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;oBACzD,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,QAAQ;oBACR,UAAU,EAAE,SAAS;oBACrB,WAAW;iBACZ,CAAC,CAAC;gBACH,OAAO,QAA0B,CAAC;YACpC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;gBAC/C,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;IAEM,wBAAwB,CAC7B,QAAwB,EACxB,KAAoB,EACpB,SAAiB,EACjB,WAAmB,EACnB,YAAqB,EAAE,qBAAqB;IAC5C,KAAW,EAAE,qBAAqB;IAClC,MAAgB,CAAC,qBAAqB;;;;YAEtC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAC/D,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,cAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;oBACvD,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,QAAQ;oBACR,UAAU,EAAE,SAAS;oBACrB,WAAW;oBACX,MAAM,EAAE,IAAI;iBACb,CAAC,CAAA,CAAC;;oBAEH,KAA0B,eAAA,WAAA,cAAA,MAAM,CAAA,YAAA,qFAAE,CAAC;wBAAT,sBAAM;wBAAN,WAAM;wBAArB,MAAM,KAAK,KAAA,CAAA;wBACpB,oBAAM,KAAK,CAAA,CAAC;oBACd,CAAC;;;;;;;;;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;gBACpD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;CACF;AA/DD,sCA+DC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export declare enum Providers {
|
|
2
|
+
OPENAI = "OpenAI",
|
|
3
|
+
ANTHROPIC_BEDROCK = "AnthropicBedrock",
|
|
4
|
+
COHERE_BEDROCK = "CohereBedrock"
|
|
5
|
+
}
|
|
6
|
+
export declare enum OpenAIMessagesRoles {
|
|
7
|
+
SYSTEM = "system",
|
|
8
|
+
USER = "user",
|
|
9
|
+
ASSISTANT = "assistant",
|
|
10
|
+
TOOL = "tool",
|
|
11
|
+
FUNCTION = "function"
|
|
12
|
+
}
|
|
13
|
+
export type OpenAISystemMessage = {
|
|
14
|
+
role: OpenAIMessagesRoles.SYSTEM;
|
|
15
|
+
content: string;
|
|
16
|
+
};
|
|
17
|
+
export type OpenAIUserMessage = {
|
|
18
|
+
role: OpenAIMessagesRoles.USER;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
export type OpenAIAssistantMessage = {
|
|
22
|
+
role: OpenAIMessagesRoles.ASSISTANT;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export type OpenAIToolMessage = {
|
|
26
|
+
role: OpenAIMessagesRoles.TOOL;
|
|
27
|
+
content: string;
|
|
28
|
+
tool_call_id: string;
|
|
29
|
+
};
|
|
30
|
+
export type OpenAIFunctionMessage = {
|
|
31
|
+
role: OpenAIMessagesRoles.FUNCTION;
|
|
32
|
+
content: string;
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
export type OpenAIMessage = OpenAISystemMessage | OpenAIUserMessage | OpenAIAssistantMessage | OpenAIToolMessage | OpenAIFunctionMessage;
|
|
36
|
+
export type OpenAIMessages = OpenAIMessage[];
|
|
37
|
+
export declare enum OpenAISupportedLLMs {
|
|
38
|
+
GPT_4_O_LAEST = "chatgpt-4o-latest",// points to the latest version of gpt-4o
|
|
39
|
+
GPT_4_O = "gpt-4o",
|
|
40
|
+
GPT_4_O_MINI = "gpt-4o-mini",
|
|
41
|
+
GPT_4_TURBO = "gpt-4-turbo",
|
|
42
|
+
GPT_4_TURBO_PREVIEW = "gpt-4-turbo-preview",// its same as gpt-4-turbo-2024-04-09
|
|
43
|
+
GPT_3_5_TURBO = "gpt-3.5-turbo"
|
|
44
|
+
}
|
|
45
|
+
export interface OpenAIChoices {
|
|
46
|
+
index: number;
|
|
47
|
+
message: any;
|
|
48
|
+
logprobs: any;
|
|
49
|
+
finish_reason: string;
|
|
50
|
+
}
|
|
51
|
+
export interface OpenAIUsage {
|
|
52
|
+
prompt_tokens: number;
|
|
53
|
+
completion_tokens: number;
|
|
54
|
+
total_tokens: number;
|
|
55
|
+
prompt_tokens_details: any;
|
|
56
|
+
completion_tokens_details: any;
|
|
57
|
+
}
|
|
58
|
+
export interface OpenAIResponse {
|
|
59
|
+
id: string;
|
|
60
|
+
object: string;
|
|
61
|
+
created: number;
|
|
62
|
+
model: string;
|
|
63
|
+
choices: Array<{
|
|
64
|
+
index: number;
|
|
65
|
+
message: {
|
|
66
|
+
role: string;
|
|
67
|
+
content: string;
|
|
68
|
+
};
|
|
69
|
+
logprobs: null | object;
|
|
70
|
+
finish_reason: string;
|
|
71
|
+
}>;
|
|
72
|
+
usage: {
|
|
73
|
+
prompt_tokens: number;
|
|
74
|
+
completion_tokens: number;
|
|
75
|
+
total_tokens: number;
|
|
76
|
+
prompt_tokens_details: {
|
|
77
|
+
cached_tokens: number;
|
|
78
|
+
};
|
|
79
|
+
completion_tokens_details: {
|
|
80
|
+
reasoning_tokens: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
system_fingerprint: string;
|
|
84
|
+
}
|
|
85
|
+
export declare enum BedrockAnthropicSupportedLLMs {
|
|
86
|
+
CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0",
|
|
87
|
+
CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0",
|
|
88
|
+
CLAUDE_3_OPUS = "anthropic.claude-3-opus-20240229-v1:0",
|
|
89
|
+
CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20241022-v2:0"
|
|
90
|
+
}
|
|
91
|
+
export declare enum BedrockAnthropicContentType {
|
|
92
|
+
TEXT = "text",
|
|
93
|
+
IMAGE = "image",
|
|
94
|
+
TOOL_USE = "tool_use",
|
|
95
|
+
TOOL_RESULT = "tool_result"
|
|
96
|
+
}
|
|
97
|
+
export declare enum BedrockAnthropicMessageRole {
|
|
98
|
+
USER = "user",
|
|
99
|
+
ASSISTANT = "assistant"
|
|
100
|
+
}
|
|
101
|
+
export interface BedrockAnthropicToolUseContent {
|
|
102
|
+
type: BedrockAnthropicContentType.TOOL_USE;
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
input: any;
|
|
106
|
+
}
|
|
107
|
+
export interface BedrockAnthropicTextContent {
|
|
108
|
+
type: BedrockAnthropicContentType.TEXT;
|
|
109
|
+
text: string;
|
|
110
|
+
}
|
|
111
|
+
interface BedrockAnthropicImageContent {
|
|
112
|
+
type: BedrockAnthropicContentType.IMAGE;
|
|
113
|
+
source: {
|
|
114
|
+
type: string;
|
|
115
|
+
media_type: string;
|
|
116
|
+
data: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export interface BedrockAnthropicToolResultContent {
|
|
120
|
+
type: BedrockAnthropicContentType.TOOL_RESULT;
|
|
121
|
+
content: string;
|
|
122
|
+
}
|
|
123
|
+
export type BedrockAnthropicContent = BedrockAnthropicToolUseContent | BedrockAnthropicToolResultContent | BedrockAnthropicTextContent | BedrockAnthropicImageContent;
|
|
124
|
+
export interface BedrockAnthropicMessage {
|
|
125
|
+
role: BedrockAnthropicMessageRole;
|
|
126
|
+
content: BedrockAnthropicContent[];
|
|
127
|
+
}
|
|
128
|
+
export interface BedrockAnthropicFunctionCall {
|
|
129
|
+
id: string;
|
|
130
|
+
name: string;
|
|
131
|
+
arguments: string;
|
|
132
|
+
}
|
|
133
|
+
export type BedrockAnthropicMessages = BedrockAnthropicMessage[];
|
|
134
|
+
export interface BedrockAnthropicOptions {
|
|
135
|
+
outputTokenLength: number;
|
|
136
|
+
temperature: number;
|
|
137
|
+
systemPrompt: string;
|
|
138
|
+
messages: BedrockAnthropicMessages;
|
|
139
|
+
tools: any;
|
|
140
|
+
}
|
|
141
|
+
export interface BedrockAnthropicUsage {
|
|
142
|
+
input_tokens: number;
|
|
143
|
+
output_tokens: number;
|
|
144
|
+
}
|
|
145
|
+
export interface BedrockAnthropicResponse {
|
|
146
|
+
id: string;
|
|
147
|
+
type: "message";
|
|
148
|
+
role: BedrockAnthropicMessageRole;
|
|
149
|
+
model: string;
|
|
150
|
+
content: BedrockAnthropicContent[];
|
|
151
|
+
stop_reason: string;
|
|
152
|
+
stop_sequence: string;
|
|
153
|
+
usage: BedrockAnthropicUsage;
|
|
154
|
+
}
|
|
155
|
+
export interface BedrockAnthropicMessageChunk {
|
|
156
|
+
id: string;
|
|
157
|
+
type: "message";
|
|
158
|
+
model: string;
|
|
159
|
+
role: BedrockAnthropicMessageRole;
|
|
160
|
+
content: BedrockAnthropicContent[];
|
|
161
|
+
stop_reason: string | null;
|
|
162
|
+
stop_sequence: string | null;
|
|
163
|
+
usage: BedrockAnthropicUsage;
|
|
164
|
+
}
|
|
165
|
+
export interface BedrockAnthropicContentBlock {
|
|
166
|
+
type: string;
|
|
167
|
+
text: string;
|
|
168
|
+
name?: string;
|
|
169
|
+
id?: string;
|
|
170
|
+
partial_json?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface BedrockAnthropicMetrics {
|
|
173
|
+
inputTokenCount: number;
|
|
174
|
+
outputTokenCount: number;
|
|
175
|
+
invocationLatency: number;
|
|
176
|
+
firstByteLatency: number;
|
|
177
|
+
}
|
|
178
|
+
export type BedrockAnthropicParsedChunk = {
|
|
179
|
+
type: "message_start";
|
|
180
|
+
message?: BedrockAnthropicMessageChunk;
|
|
181
|
+
content_block?: BedrockAnthropicContentBlock;
|
|
182
|
+
delta?: BedrockAnthropicContentBlock;
|
|
183
|
+
"amazon-bedrock-invocationMetrics"?: BedrockAnthropicMetrics;
|
|
184
|
+
};
|
|
185
|
+
export type Messages = OpenAIMessages | BedrockAnthropicMessages;
|
|
186
|
+
export type LLMResponse = OpenAIResponse | BedrockAnthropicResponse;
|
|
187
|
+
export type SupportedLLMs = {
|
|
188
|
+
type: "OpenAI";
|
|
189
|
+
model: OpenAISupportedLLMs;
|
|
190
|
+
} | {
|
|
191
|
+
type: "BedrockAnthropic";
|
|
192
|
+
model: BedrockAnthropicSupportedLLMs;
|
|
193
|
+
};
|
|
194
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BedrockAnthropicMessageRole = exports.BedrockAnthropicContentType = exports.BedrockAnthropicSupportedLLMs = exports.OpenAISupportedLLMs = exports.OpenAIMessagesRoles = exports.Providers = void 0;
|
|
4
|
+
// GENERAL
|
|
5
|
+
var Providers;
|
|
6
|
+
(function (Providers) {
|
|
7
|
+
Providers["OPENAI"] = "OpenAI";
|
|
8
|
+
Providers["ANTHROPIC_BEDROCK"] = "AnthropicBedrock";
|
|
9
|
+
Providers["COHERE_BEDROCK"] = "CohereBedrock";
|
|
10
|
+
})(Providers || (exports.Providers = Providers = {}));
|
|
11
|
+
// OPENAI
|
|
12
|
+
var OpenAIMessagesRoles;
|
|
13
|
+
(function (OpenAIMessagesRoles) {
|
|
14
|
+
OpenAIMessagesRoles["SYSTEM"] = "system";
|
|
15
|
+
OpenAIMessagesRoles["USER"] = "user";
|
|
16
|
+
OpenAIMessagesRoles["ASSISTANT"] = "assistant";
|
|
17
|
+
OpenAIMessagesRoles["TOOL"] = "tool";
|
|
18
|
+
OpenAIMessagesRoles["FUNCTION"] = "function";
|
|
19
|
+
})(OpenAIMessagesRoles || (exports.OpenAIMessagesRoles = OpenAIMessagesRoles = {}));
|
|
20
|
+
var OpenAISupportedLLMs;
|
|
21
|
+
(function (OpenAISupportedLLMs) {
|
|
22
|
+
OpenAISupportedLLMs["GPT_4_O_LAEST"] = "chatgpt-4o-latest";
|
|
23
|
+
OpenAISupportedLLMs["GPT_4_O"] = "gpt-4o";
|
|
24
|
+
OpenAISupportedLLMs["GPT_4_O_MINI"] = "gpt-4o-mini";
|
|
25
|
+
OpenAISupportedLLMs["GPT_4_TURBO"] = "gpt-4-turbo";
|
|
26
|
+
OpenAISupportedLLMs["GPT_4_TURBO_PREVIEW"] = "gpt-4-turbo-preview";
|
|
27
|
+
OpenAISupportedLLMs["GPT_3_5_TURBO"] = "gpt-3.5-turbo";
|
|
28
|
+
})(OpenAISupportedLLMs || (exports.OpenAISupportedLLMs = OpenAISupportedLLMs = {}));
|
|
29
|
+
// AWS BEDROCK
|
|
30
|
+
// AWS BEDROCK ANTHROPIC
|
|
31
|
+
var BedrockAnthropicSupportedLLMs;
|
|
32
|
+
(function (BedrockAnthropicSupportedLLMs) {
|
|
33
|
+
BedrockAnthropicSupportedLLMs["CLAUDE_3_HAIKU"] = "anthropic.claude-3-haiku-20240307-v1:0";
|
|
34
|
+
BedrockAnthropicSupportedLLMs["CLAUDE_3_SONNET"] = "anthropic.claude-3-sonnet-20240229-v1:0";
|
|
35
|
+
BedrockAnthropicSupportedLLMs["CLAUDE_3_OPUS"] = "anthropic.claude-3-opus-20240229-v1:0";
|
|
36
|
+
BedrockAnthropicSupportedLLMs["CLAUDE_3_5_SONNET"] = "anthropic.claude-3-5-sonnet-20241022-v2:0";
|
|
37
|
+
})(BedrockAnthropicSupportedLLMs || (exports.BedrockAnthropicSupportedLLMs = BedrockAnthropicSupportedLLMs = {}));
|
|
38
|
+
var BedrockAnthropicContentType;
|
|
39
|
+
(function (BedrockAnthropicContentType) {
|
|
40
|
+
BedrockAnthropicContentType["TEXT"] = "text";
|
|
41
|
+
BedrockAnthropicContentType["IMAGE"] = "image";
|
|
42
|
+
BedrockAnthropicContentType["TOOL_USE"] = "tool_use";
|
|
43
|
+
BedrockAnthropicContentType["TOOL_RESULT"] = "tool_result";
|
|
44
|
+
})(BedrockAnthropicContentType || (exports.BedrockAnthropicContentType = BedrockAnthropicContentType = {}));
|
|
45
|
+
var BedrockAnthropicMessageRole;
|
|
46
|
+
(function (BedrockAnthropicMessageRole) {
|
|
47
|
+
BedrockAnthropicMessageRole["USER"] = "user";
|
|
48
|
+
BedrockAnthropicMessageRole["ASSISTANT"] = "assistant";
|
|
49
|
+
})(BedrockAnthropicMessageRole || (exports.BedrockAnthropicMessageRole = BedrockAnthropicMessageRole = {}));
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,UAAU;AACV,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,mDAAsC,CAAA;IACtC,6CAAgC,CAAA;AAClC,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB;AAED,SAAS;AACT,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,oCAAa,CAAA;IACb,8CAAuB,CAAA;IACvB,oCAAa,CAAA;IACb,4CAAqB,CAAA;AACvB,CAAC,EANW,mBAAmB,mCAAnB,mBAAmB,QAM9B;AAsCD,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,0DAAmC,CAAA;IACnC,yCAAkB,CAAA;IAClB,mDAA4B,CAAA;IAC5B,kDAA2B,CAAA;IAC3B,kEAA2C,CAAA;IAC3C,sDAA+B,CAAA;AACjC,CAAC,EAPW,mBAAmB,mCAAnB,mBAAmB,QAO9B;AAyCD,cAAc;AAEd,wBAAwB;AAExB,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACvC,0FAAyD,CAAA;IACzD,4FAA2D,CAAA;IAC3D,wFAAuD,CAAA;IACvD,gGAA+D,CAAA;AACjE,CAAC,EALW,6BAA6B,6CAA7B,6BAA6B,QAKxC;AAED,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,4CAAa,CAAA;IACb,8CAAe,CAAA;IACf,oDAAqB,CAAA;IACrB,0DAA2B,CAAA;AAC7B,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC;AAED,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACrC,4CAAa,CAAA;IACb,sDAAuB,CAAA;AACzB,CAAC,EAHW,2BAA2B,2CAA3B,2BAA2B,QAGtC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-proxy",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "An LLM Proxy that allows the
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.0.2",
|
|
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
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
6
10
|
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepare": "npm run build",
|
|
7
13
|
"test": "jest --config jest.config.js",
|
|
8
14
|
"dev": "ts-node src/index.ts"
|
|
9
15
|
},
|
|
Binary file
|