@jaypie/llm 1.2.0-rc.4 → 1.2.0-rc.6
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/cjs/index.cjs +23 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +23 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -158,6 +158,14 @@ function determineModelProvider(input) {
|
|
|
158
158
|
provider: DEFAULT.PROVIDER.NAME,
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
+
// Check for explicit openrouter: prefix
|
|
162
|
+
if (input.startsWith("openrouter:")) {
|
|
163
|
+
const model = input.slice("openrouter:".length);
|
|
164
|
+
return {
|
|
165
|
+
model,
|
|
166
|
+
provider: PROVIDER.OPENROUTER.NAME,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
161
169
|
// Check if input is a provider name
|
|
162
170
|
if (input === PROVIDER.ANTHROPIC.NAME) {
|
|
163
171
|
return {
|
|
@@ -219,6 +227,14 @@ function determineModelProvider(input) {
|
|
|
219
227
|
};
|
|
220
228
|
}
|
|
221
229
|
}
|
|
230
|
+
// Assume OpenRouter for models containing "/" (e.g., "openai/gpt-4", "anthropic/claude-3-opus")
|
|
231
|
+
// This check must come before match words so that "openai/gpt-4" is not matched by "openai" keyword
|
|
232
|
+
if (input.includes("/")) {
|
|
233
|
+
return {
|
|
234
|
+
model: input,
|
|
235
|
+
provider: PROVIDER.OPENROUTER.NAME,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
222
238
|
// Check Anthropic match words
|
|
223
239
|
const lowerInput = input.toLowerCase();
|
|
224
240
|
for (const matchWord of PROVIDER.ANTHROPIC.MODEL_MATCH_WORDS) {
|
|
@@ -735,7 +751,13 @@ class AnthropicAdapter extends BaseProviderAdapter {
|
|
|
735
751
|
//
|
|
736
752
|
buildRequest(request) {
|
|
737
753
|
// Convert messages to Anthropic format (remove 'type' property)
|
|
738
|
-
|
|
754
|
+
// Filter out system messages - Anthropic only accepts system as a top-level field
|
|
755
|
+
const messages = request.messages
|
|
756
|
+
.filter((msg) => {
|
|
757
|
+
const role = msg.role;
|
|
758
|
+
return role !== "system";
|
|
759
|
+
})
|
|
760
|
+
.map((msg) => {
|
|
739
761
|
const anthropicMsg = structuredClone(msg);
|
|
740
762
|
delete anthropicMsg.type;
|
|
741
763
|
return anthropicMsg;
|