llm-proxy 1.3.12 → 1.3.13
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.
|
@@ -4,20 +4,30 @@ exports.InputFormatAdapter = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
class InputFormatAdapter {
|
|
6
6
|
static adaptMessages(messages, provider) {
|
|
7
|
+
//
|
|
8
|
+
/**!SECTION
|
|
9
|
+
* There some strange stuff happened, in a function call assistant message the
|
|
10
|
+
* will be by default null, it must be null, but the openai api was returning error
|
|
11
|
+
* and it cannot be null of fine, but using same api version, from different app (CMND)
|
|
12
|
+
* it works well !!!!!!!! it works with null content on the same version,
|
|
13
|
+
* im not convinced with this work to make it empty string instead of null so here is a todo to go back to it
|
|
14
|
+
*/
|
|
15
|
+
var _a;
|
|
7
16
|
switch (provider) {
|
|
8
17
|
case types_1.Providers.OPENAI:
|
|
9
18
|
return {
|
|
10
19
|
adaptedMessages: messages.map((msg) => {
|
|
20
|
+
var _a, _b;
|
|
11
21
|
if (msg.role === "function") {
|
|
12
22
|
return {
|
|
13
23
|
role: msg.role,
|
|
14
|
-
content: msg.content,
|
|
24
|
+
content: (_a = msg.content) !== null && _a !== void 0 ? _a : "",
|
|
15
25
|
name: msg.name,
|
|
16
26
|
};
|
|
17
27
|
}
|
|
18
28
|
return {
|
|
19
29
|
role: msg.role,
|
|
20
|
-
content: msg.content,
|
|
30
|
+
content: (_b = msg.content) !== null && _b !== void 0 ? _b : "",
|
|
21
31
|
};
|
|
22
32
|
}),
|
|
23
33
|
};
|
|
@@ -30,16 +40,19 @@ class InputFormatAdapter {
|
|
|
30
40
|
if (firstMessage.role !== "system") {
|
|
31
41
|
throw new Error("The first message must have a role of 'system' for Anthropic.");
|
|
32
42
|
}
|
|
33
|
-
const systemPrompt = firstMessage.content;
|
|
34
|
-
const adaptedMessages = restMessages.map((msg) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
const systemPrompt = (_a = firstMessage.content) !== null && _a !== void 0 ? _a : "";
|
|
44
|
+
const adaptedMessages = restMessages.map((msg) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return ({
|
|
47
|
+
role: msg.role === "user" ? "user" : "assistant",
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: types_1.BedrockAnthropicContentType.TEXT,
|
|
51
|
+
text: (_a = msg.content) !== null && _a !== void 0 ? _a : "",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
});
|
|
43
56
|
return { adaptedMessages, systemPrompt };
|
|
44
57
|
}
|
|
45
58
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputFormatAdapter.js","sourceRoot":"","sources":["../../src/middleware/InputFormatAdapter.ts"],"names":[],"mappings":";;;AAAA,oCAOkB;AAElB,MAAa,kBAAkB;IAC7B,MAAM,CAAC,aAAa,CAClB,QAAkB,EAClB,QAAmB;QAKnB,QAAQ,QAAQ,EAAE;YAChB,KAAK,iBAAS,CAAC,MAAM;gBACnB,OAAO;oBACL,eAAe,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"InputFormatAdapter.js","sourceRoot":"","sources":["../../src/middleware/InputFormatAdapter.ts"],"names":[],"mappings":";;;AAAA,oCAOkB;AAElB,MAAa,kBAAkB;IAC7B,MAAM,CAAC,aAAa,CAClB,QAAkB,EAClB,QAAmB;QAKnB,EAAE;QACF;;;;;;WAMG;;QAEH,QAAQ,QAAQ,EAAE;YAChB,KAAK,iBAAS,CAAC,MAAM;gBACnB,OAAO;oBACL,eAAe,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;;wBACpC,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE;4BAC3B,OAAO;gCACL,I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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-proxy",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"aws-sdk": "^2.1691.0",
|
|
31
31
|
"axios": "^1.7.7",
|
|
32
32
|
"dotenv": "^16.4.5",
|
|
33
|
-
"llm-proxy": "^1.3.
|
|
33
|
+
"llm-proxy": "^1.3.13",
|
|
34
34
|
"openai": "^4.69.0"
|
|
35
35
|
}
|
|
36
36
|
}
|