Merge branch 'main' of github.com:continuedev/continue into jacob/con-3141

This commit is contained in:
Jacob Kim 2025-08-05 16:19:00 -07:00
commit b2744c159a
16 changed files with 3301 additions and 95 deletions

20
.claude/lint-check.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
# Get file path from hook input
FILE_PATH=$(cat | jq -r '.tool_input.file_path // .tool_input.edits[].file_path // empty' | head -n1)
# Function to run lint and typecheck
run_checks() {
local dir=$1
cd "$dir"
npm run lint >&2 && npm run tsc:check >&2
}
# Run checks based on file location
if [[ "$FILE_PATH" == *"/core/"* ]]; then
run_checks core
elif [[ "$FILE_PATH" == *"/gui/"* ]]; then
run_checks gui
elif [[ "$FILE_PATH" == *"/extensions/vscode/"* ]]; then
run_checks extensions/vscode
fi

15
.claude/settings.json Normal file
View file

@ -0,0 +1,15 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/lint-check.sh"
}
]
}
]
}
}

View file

@ -40,7 +40,7 @@ jobs:
fi
- name: Add PR title guidance comment
if: steps.pr-title-check.outputs.valid == 'false'
if: always() && steps.pr-title-check.outputs.valid == 'false'
uses: actions/github-script@v7
with:
script: |
@ -88,6 +88,9 @@ jobs:
].join('\n')
});
}
- name: Ensure job always succeeds
if: always()
run: echo "✅ Conventional commits check completed (warning only)"
security-audit:
name: Security Audit

505
docs/c15t-cookie-banner.js Normal file
View file

@ -0,0 +1,505 @@
// Cookie Banner Implementation for Continue Documentation
// This script implements a cookie consent banner in offline mode
(function () {
"use strict";
// Configuration
const COOKIE_NAME = "continue_cookie_consent";
const COOKIE_EXPIRY_DAYS = 365;
// Default consent state
const defaultConsent = {
necessary: true,
analytics: false,
marketing: false,
};
// Wait for the page to fully load
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initializeCookieBanner);
} else {
initializeCookieBanner();
}
function initializeCookieBanner() {
// Check if banner is already initialized
if (window.cookieBannerInitialized) {
return;
}
window.cookieBannerInitialized = true;
// Get stored consent
const storedConsent = getStoredConsent();
// Apply stored consent or show banner
if (storedConsent) {
applyConsent(storedConsent);
} else {
// Set default consent (deny all except necessary)
applyConsent(defaultConsent);
showCookieBanner();
}
}
function getStoredConsent() {
const cookie = document.cookie
.split(";")
.find((c) => c.trim().startsWith(COOKIE_NAME + "="));
if (cookie) {
try {
return JSON.parse(decodeURIComponent(cookie.split("=")[1]));
} catch (e) {
console.error("Failed to parse consent cookie:", e);
}
}
return null;
}
function setConsentCookie(consent) {
const date = new Date();
date.setTime(date.getTime() + COOKIE_EXPIRY_DAYS * 24 * 60 * 60 * 1000);
const expires = "expires=" + date.toUTCString();
document.cookie =
COOKIE_NAME +
"=" +
encodeURIComponent(JSON.stringify(consent)) +
";" +
expires +
";path=/;SameSite=Lax";
}
function applyConsent(consent) {
// Apply Google Analytics consent
if (window.gtag) {
window.gtag("consent", "update", {
analytics_storage: consent.analytics ? "granted" : "denied",
ad_user_data: consent.marketing ? "granted" : "denied",
ad_personalization: consent.marketing ? "granted" : "denied",
});
}
// Apply PostHog consent
if (window.posthog) {
if (consent.analytics) {
window.posthog.opt_in_capturing();
} else {
window.posthog.opt_out_capturing();
}
}
// Store consent
setConsentCookie(consent);
}
function showCookieBanner() {
// Create banner (no overlay - users can continue browsing)
const banner = document.createElement("div");
banner.className = "cookie-banner";
banner.innerHTML = `
<div class="cookie-banner-content">
<div class="cookie-banner-text">
<p>We use cookies to enhance your experience on our documentation site. By continuing to browse, you agree to our use of cookies.</p>
</div>
<div class="cookie-banner-actions">
<button class="cookie-btn cookie-btn-secondary" onclick="window.showPreferencesDialog()">Manage Preferences</button>
<button class="cookie-btn cookie-btn-primary" onclick="window.acceptAllCookies()">Accept All</button>
</div>
</div>
`;
document.body.appendChild(banner);
// Make functions globally available
window.acceptAllCookies = function () {
const consent = {
necessary: true,
analytics: true,
marketing: true,
};
applyConsent(consent);
hideCookieBanner();
};
window.showPreferencesDialog = showPreferencesDialog;
}
function hideCookieBanner() {
const banner = document.querySelector(".cookie-banner");
if (banner) banner.remove();
}
function showPreferencesDialog() {
hideCookieBanner();
const currentConsent = getStoredConsent() || defaultConsent;
// Create dialog overlay
const dialogOverlay = document.createElement("div");
dialogOverlay.className = "cookie-dialog-overlay";
dialogOverlay.onclick = function (e) {
if (e.target === dialogOverlay) {
hidePreferencesDialog();
}
};
// Create dialog
const dialog = document.createElement("div");
dialog.className = "cookie-dialog";
dialog.innerHTML = `
<div class="cookie-dialog-header">
<h2>Cookie Preferences</h2>
<button class="cookie-dialog-close" onclick="window.hidePreferencesDialog()">×</button>
</div>
<div class="cookie-dialog-body">
<p>We use cookies and similar technologies to help personalize content and offer a better experience. You can customize your preferences below:</p>
<div class="cookie-category">
<div class="cookie-category-header">
<label class="cookie-switch">
<input type="checkbox" id="cookie-necessary" checked disabled>
<span class="cookie-slider"></span>
</label>
<div class="cookie-category-info">
<h3>Necessary Cookies</h3>
<p>These cookies are essential for the website to function properly and cannot be disabled.</p>
</div>
</div>
</div>
<div class="cookie-category">
<div class="cookie-category-header">
<label class="cookie-switch">
<input type="checkbox" id="cookie-analytics" ${currentConsent.analytics ? "checked" : ""}>
<span class="cookie-slider"></span>
</label>
<div class="cookie-category-info">
<h3>Analytics Cookies</h3>
<p>These cookies help us understand how visitors interact with our website by collecting and reporting information anonymously.</p>
</div>
</div>
</div>
<div class="cookie-category">
<div class="cookie-category-header">
<label class="cookie-switch">
<input type="checkbox" id="cookie-marketing" ${currentConsent.marketing ? "checked" : ""}>
<span class="cookie-slider"></span>
</label>
<div class="cookie-category-info">
<h3>Identification Cookies</h3>
<p>These cookies help us understand how you use our documentation and allow us to recognize you across visits. We use this data to improve your experience and help you get the most value from our products.</p>
</div>
</div>
</div>
</div>
<div class="cookie-dialog-footer">
<button class="cookie-btn cookie-btn-secondary" onclick="window.rejectAllCookies()">Reject All</button>
<button class="cookie-btn cookie-btn-primary" onclick="window.savePreferences()">Save Preferences</button>
</div>
`;
dialogOverlay.appendChild(dialog);
document.body.appendChild(dialogOverlay);
// Make functions globally available
window.hidePreferencesDialog = hidePreferencesDialog;
window.rejectAllCookies = function () {
const consent = {
necessary: true,
analytics: false,
marketing: false,
};
applyConsent(consent);
hidePreferencesDialog();
};
window.savePreferences = function () {
const consent = {
necessary: true,
analytics: document.getElementById("cookie-analytics").checked,
marketing: document.getElementById("cookie-marketing").checked,
};
applyConsent(consent);
hidePreferencesDialog();
};
}
function hidePreferencesDialog() {
const dialogOverlay = document.querySelector(".cookie-dialog-overlay");
if (dialogOverlay) dialogOverlay.remove();
}
// Add styles
const style = document.createElement("style");
style.textContent = `
.cookie-banner {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #1a1a1a;
color: #ffffff;
padding: 1.5rem;
z-index: 9999;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}
.cookie-banner-content {
max-width: 1200px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
gap: 2rem;
flex-wrap: wrap;
}
.cookie-banner-text {
flex: 1;
min-width: 300px;
}
.cookie-banner-text p {
margin: 0;
font-size: 14px;
line-height: 1.5;
}
.cookie-banner-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.cookie-btn {
padding: 0.5rem 1.5rem;
border: none;
border-radius: 4px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
white-space: nowrap;
}
.cookie-btn-primary {
background: #6b7280;
color: #ffffff;
}
.cookie-btn-primary:hover {
background: #4b5563;
}
.cookie-btn-secondary {
background: transparent;
color: #ffffff;
border: 1px solid #6b7280;
}
.cookie-btn-secondary:hover {
background: #6b7280;
}
/* Dialog-specific button styles */
.cookie-dialog-footer .cookie-btn-secondary {
color: #6b7280;
border-color: #6b7280;
}
.cookie-dialog-footer .cookie-btn-secondary:hover {
color: #ffffff;
background: #6b7280;
}
.cookie-dialog-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.cookie-dialog {
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
max-width: 600px;
width: 100%;
max-height: 90vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
.cookie-dialog-header {
padding: 1.5rem;
border-bottom: 1px solid #e5e7eb;
display: flex;
align-items: center;
justify-content: space-between;
}
.cookie-dialog-header h2 {
margin: 0;
font-size: 1.5rem;
color: #1a1a1a;
}
.cookie-dialog-close {
background: none;
border: none;
font-size: 1.5rem;
color: #6b7280;
cursor: pointer;
padding: 0;
width: 2rem;
height: 2rem;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
transition: all 0.2s;
}
.cookie-dialog-close:hover {
background: #f3f4f6;
}
.cookie-dialog-body {
padding: 1.5rem;
overflow-y: auto;
flex: 1;
}
.cookie-dialog-body > p {
margin: 0 0 1.5rem 0;
color: #6b7280;
line-height: 1.5;
}
.cookie-category {
margin-bottom: 1.5rem;
padding-bottom: 1.5rem;
border-bottom: 1px solid #e5e7eb;
}
.cookie-category:last-child {
margin-bottom: 0;
padding-bottom: 0;
border-bottom: none;
}
.cookie-category-header {
display: flex;
align-items: flex-start;
gap: 1rem;
}
.cookie-category-info {
flex: 1;
}
.cookie-category-info h3 {
margin: 0 0 0.5rem 0;
font-size: 1.1rem;
color: #1a1a1a;
}
.cookie-category-info p {
margin: 0;
color: #6b7280;
font-size: 14px;
line-height: 1.5;
}
.cookie-switch {
position: relative;
display: inline-block;
width: 48px;
height: 24px;
flex-shrink: 0;
}
.cookie-switch input {
opacity: 0;
width: 0;
height: 0;
}
.cookie-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #e5e7eb;
transition: .4s;
border-radius: 24px;
}
.cookie-slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
.cookie-switch input:checked + .cookie-slider {
background-color: #6b7280;
}
.cookie-switch input:checked + .cookie-slider:before {
transform: translateX(24px);
}
.cookie-switch input:disabled + .cookie-slider {
background-color: #9ca3af;
cursor: not-allowed;
}
.cookie-dialog-footer {
padding: 1.5rem;
border-top: 1px solid #e5e7eb;
display: flex;
justify-content: flex-end;
gap: 1rem;
}
@media (max-width: 640px) {
.cookie-banner-content {
flex-direction: column;
align-items: stretch;
}
.cookie-banner-actions {
justify-content: stretch;
}
.cookie-btn {
flex: 1;
}
.cookie-dialog {
margin: 1rem;
}
}
`;
document.head.appendChild(style);
})();

View file

@ -13,4 +13,4 @@ description: "Model Context Protocol servers provide specialized functionality:"
## Learn More
Learn more in the [MCP deep dive](/customization/mcp-tools), and view [`mcpServers`](/reference#mcpservers) in the YAML Reference for more details.
Learn more in the [MCP deep dive](/customize/deep-dives/mcp), and view [`mcpServers`](/reference#mcpservers) in the YAML Reference for more details.

View file

@ -4,13 +4,17 @@ title: "LM Studio"
[LM Studio](https://lmstudio.ai) is an application for Mac, Windows, and Linux that makes it easy to locally run open-source models and comes with a great UI. To get started with LM Studio, download from the website, use the UI to download a model, and then start the local inference server. Continue can then be configured to use the `LMStudio` LLM class:
## Chat model
We recommend configuring **Llama3.1 8B** as your chat model.
<Tabs>
<Tab title="YAML">
```yaml title="config.yaml"
models:
- name: LM Studio
- name: Llama3.1 8B Instruct
provider: lmstudio
model: llama2-7b
model: meta-llama-3.1-8b-instruct
```
</Tab>
<Tab title="JSON">
@ -18,9 +22,9 @@ title: "LM Studio"
{
"models": [
{
"title": "LM Studio",
"title": "Llama3.1 8B Instruct",
"provider": "lmstudio",
"model": "llama2-7b"
"model": "meta-llama-3.1-8b-instruct"
}
]
}
@ -28,7 +32,7 @@ title: "LM Studio"
</Tab>
</Tabs>
### Embeddings model
## Embeddings model
LMStudio supports embeddings endpoints, and comes with the `nomic-ai/nomic-embed-text-v1.5-GGUF` model (as of Nov 2024, check your models)
@ -63,21 +67,24 @@ To configure a remote instance of LM Studio, add the `"apiBase"` property to you
<Tab title="YAML">
```yaml title="config.yaml"
models:
- name: Nomic Embed Text
- name: Llama3.1 8B Instruct
provider: lmstudio
model: nomic-ai/nomic-embed-text-v1.5-GGUF
roles:
- embed
model: meta-llama-3.1-8b-instruct
apiBase: http://<MY ENDPOINT>/v1
```
</Tab>
<Tab title="JSON">
```json title="config.json"
{
"embeddingsProvider": {
"provider": "lmstudio",
"model": "nomic-ai/nomic-embed-text-v1.5-GGUF"
{
"models": [
{
"title": "Llama3.1 8B Instruct",
"provider": "lmstudio",
"model": "meta-llama-3.1-8b-instruct",
"apiBase": "http://<MY ENDPOINT>/v1"
}
]
}
}
```
</Tab>
</Tabs>

View file

@ -84,3 +84,9 @@ cn --ask Bash(curl*)
# Never use the Fetch tool
cn --exclude Fetch
```
## Troubleshooting
Run `cn` with the `--verbose` flag to see more detailed logs. These will be output to `~/.continue/logs/cn.log`.
If you have feedback on the alpha, please [share in our Discord](https://discord.com/invite/EfJEfdFnDQ).

View file

@ -24,13 +24,13 @@ Learn more in the [@Docs context provider documentation](/customize/context/docu
Model Context Protocol (MCP) is a standard way of building and sharing tools for language models. MCP Servers can be defined in `mcpServers` blocks. [Explore MCP Servers](https://hub.continue.dev/explore/mcp) on the hub.
Learn more in the [MCP deep dive](/customization/mcp-tools), and view [`mcpServers`](/reference#mcpservers) in the YAML Reference for more details.
Learn more in the [MCP deep dive](/customize/deep-dives/mcp), and view [`mcpServers`](/reference#mcpservers) in the YAML Reference for more details.
## Rules
Rules blocks are instructions that your custom AI code assistant will always keep in mind - the contents of rules are inserted into the system message for all Chat requests. [Explore rules](https://hub.continue.dev/explore/rules) on the hub.
Learn more in the [rules deep dive](/customization/rules), and view [`rules`](/reference#rules) in the YAML Reference for more details.
Learn more in the [rules deep dive](/customize/deep-dives/rules), and view [`rules`](/reference#rules) in the YAML Reference for more details.
## Prompts

2583
docs/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,5 +14,8 @@
"type": "commonjs",
"devDependencies": {
"mintlify": "^4.2.3"
},
"dependencies": {
"@c15t/react": "^1.4.4"
}
}

View file

@ -1,5 +1,3 @@
import * as path from "path";
import { getContinueRcPath, getTsConfigPath } from "core/util/paths";
import { Telemetry } from "core/util/posthog";
import * as vscode from "vscode";
@ -58,10 +56,10 @@ export async function activateExtension(context: vscode.ExtensionContext) {
const yamlMatcher = ".continue/**/*.yaml";
const yamlConfig = vscode.workspace.getConfiguration("yaml");
const newPath = path.join(
context.extension.extensionUri.fsPath,
const newPath = vscode.Uri.joinPath(
context.extension.extensionUri,
"config-yaml-schema.json",
);
).toString();
try {
await yamlConfig.update(

View file

@ -110,21 +110,18 @@ export default function StepContainer(props: StepContainerProps) {
{props.isLast && <ThinkingIndicator historyItem={props.item} />}
</div>
{shouldRenderResponseAction() && (
// We want to occupy space in the DOM regardless of whether the actions are visible to avoid jank on stream complete
{shouldRenderResponseAction() && !isStreaming && (
<div
className={`mt-2 h-7 transition-opacity duration-300 ease-in-out ${isBeforeLatestSummary ? "opacity-35" : ""}`}
>
{!isStreaming && (
<ResponseActions
isTruncated={isTruncated}
onDelete={onDelete}
onContinueGeneration={onContinueGeneration}
index={props.index}
item={props.item}
isLast={props.isLast}
/>
)}
<ResponseActions
isTruncated={isTruncated}
onDelete={onDelete}
onContinueGeneration={onContinueGeneration}
index={props.index}
item={props.item}
isLast={props.isLast}
/>
</div>
)}

View file

@ -35,4 +35,5 @@ export const GradientBorder = styled.div<{
display: flex;
flex-direction: row;
align-items: center;
margin-top: ${(props) => (props.loading ? "8px" : "")};
`;

View file

@ -4645,6 +4645,19 @@
"node": ">=8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
@ -5291,6 +5304,20 @@
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/duplexer2": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
@ -5533,6 +5560,24 @@
"is-arrayish": "^0.2.1"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-module-lexer": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
@ -5540,6 +5585,33 @@
"dev": true,
"license": "MIT"
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-set-tostringtag": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6",
"has-tostringtag": "^1.0.2",
"hasown": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/esbuild": {
"version": "0.25.8",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.8.tgz",
@ -5898,12 +5970,15 @@
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"es-set-tostringtag": "^2.1.0",
"hasown": "^2.0.2",
"mime-types": "^2.1.12"
},
"engines": {
@ -5995,8 +6070,6 @@
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"dev": true,
"peer": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@ -6060,6 +6133,30 @@
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-package-type": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
@ -6070,6 +6167,19 @@
"node": ">=8.0.0"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
@ -6211,6 +6321,18 @@
"node": ">=14"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
@ -6260,12 +6382,37 @@
"node": ">=8"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-tostringtag": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
"license": "MIT",
"dependencies": {
"has-symbols": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"dev": true,
"peer": true,
"dependencies": {
"function-bind": "^1.1.2"
},
@ -7727,6 +7874,15 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/meow": {
"version": "13.2.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz",

View file

@ -55,6 +55,14 @@ export class AnthropicApi implements BaseLlmApi {
return cachingStrategy(cleanBody);
}
private maxTokensForModel(model: string): number {
if (model.includes("haiku")) {
return 8192;
}
return 32_000;
}
public _convertToCleanAnthropicBody(oaiBody: ChatCompletionCreateParams) {
let stop = undefined;
if (oaiBody.stop && Array.isArray(oaiBody.stop)) {
@ -81,7 +89,7 @@ export class AnthropicApi implements BaseLlmApi {
: systemMessage,
top_p: oaiBody.top_p,
temperature: oaiBody.temperature,
max_tokens: oaiBody.max_tokens ?? 4096, // max_tokens is required
max_tokens: oaiBody.max_tokens ?? this.maxTokensForModel(oaiBody.model), // max_tokens is required
model: oaiBody.model,
stop_sequences: stop,
stream: oaiBody.stream,

View file

@ -1,4 +1,4 @@
import { describe, test, vi, expect, afterEach } from "vitest";
import { afterEach, describe, expect, test, vi } from "vitest";
import { runAdapterTest } from "./adapter-test-utils.js";
// Mock the fetch package
@ -53,7 +53,7 @@ describe("Anthropic Adapter Tests", () => {
messages: [{ role: "user", content: "hello" }],
system: undefined,
model: "claude-3-5-sonnet-20241022",
max_tokens: 4096,
max_tokens: 32000,
stream: undefined,
},
},
@ -107,7 +107,7 @@ describe("Anthropic Adapter Tests", () => {
messages: [{ role: "user", content: "hello" }],
system: undefined,
model: "claude-3-5-sonnet-20241022",
max_tokens: 4096,
max_tokens: 32000,
stream: true,
},
},
@ -168,7 +168,7 @@ describe("Anthropic Adapter Tests", () => {
},
],
model: "claude-3-5-sonnet-20241022",
max_tokens: 4096,
max_tokens: 32000,
stream: true,
},
},