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