Merge pull request #102 from continuedev/warn-about-bad-models

feat: model capability warning
This commit is contained in:
Nate Sesti 2025-07-27 21:31:00 -07:00 • committed by GitHub
commit 7b9d1e6e5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 221 additions and 1 deletions

View file

@ -4,6 +4,8 @@ import React from "react";
import { parseArgs } from "../args.js";
import { getAllSlashCommands } from "../commands/commands.js";
import { MCPService } from "../mcp.js";
import { isModelCapable } from "../utils/modelCapability.js";
import ModelCapabilityWarning from "./ModelCapabilityWarning.js";
interface IntroMessageProps {
config: AssistantUnrolled;
@ -32,6 +34,9 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
const allRules = [...commandLineRules, ...configRules];
// Check if model is capable
const modelCapable = isModelCapable(model.provider, model.name);
return (
<Box flexDirection="column" paddingX={1} paddingY={1}>
{/* Agent name */}
@ -44,6 +49,14 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
Model: <Text color="white">{model.name.split("/").pop()}</Text>
</Text>
{/* Model capability warning */}
{!modelCapable && (
<>
<Text> </Text>
<ModelCapabilityWarning modelName={model.name.split("/").pop() || model.name} />
</>
)}
<Text> </Text>
{/* Slash commands */}
@ -94,4 +107,4 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
);
};
export default IntroMessage;
export default IntroMessage;

View file

@ -0,0 +1,42 @@
import { render } from 'ink-testing-library';
import React from 'react';
import { describe, expect, test } from '@jest/globals';
import ModelCapabilityWarning from './ModelCapabilityWarning.js';
describe('ModelCapabilityWarning', () => {
test('should render warning message with model name', () => {
const { lastFrame } = render(
React.createElement(ModelCapabilityWarning, { modelName: 'gpt-3-davinci' })
);
const frame = lastFrame();
if (frame) {
expect(frame).toContain('Model Capability Warning');
expect(frame).toContain('gpt-3-davinci');
expect(frame).toContain('is not recommended for use with cn due to limited reasoning and tool');
expect(frame).toContain('calling capabilities');
}
});
test('should handle model names with slashes', () => {
const { lastFrame } = render(
React.createElement(ModelCapabilityWarning, { modelName: 'local/mistral-7b' })
);
const frame = lastFrame();
if (frame) {
expect(frame).toContain('local/mistral-7b');
}
});
test('should display warning icon', () => {
const { lastFrame } = render(
React.createElement(ModelCapabilityWarning, { modelName: 'test-model' })
);
const frame = lastFrame();
if (frame) {
expect(frame).toContain('⚠️');
}
});
});

View file

@ -0,0 +1,27 @@
import { Box, Text } from "ink";
import React from "react";
interface ModelCapabilityWarningProps {
modelName: string;
}
const ModelCapabilityWarning: React.FC<ModelCapabilityWarningProps> = ({
modelName,
}) => {
return (
<Box flexDirection="column" paddingX={1}>
<Box flexDirection="row" alignItems="center">
<Text color="yellow">⚠️ </Text>
<Text color="yellow" bold>
Model Capability Warning
</Text>
</Box>
<Text color="gray">
The model "{modelName}" is not recommended for use with cn due to
limited reasoning and tool calling capabilities
</Text>
</Box>
);
};
export default ModelCapabilityWarning;

1
src/utils/index.ts Normal file
View file

@ -0,0 +1 @@
export { isModelCapable } from './modelCapability.js';

View file

@ -0,0 +1,121 @@
import { isModelCapable } from './modelCapability.js';
describe('isModelCapable', () => {
describe('OpenAI models', () => {
test('should consider GPT-4 models as capable', () => {
expect(isModelCapable('openai', 'gpt-4')).toBe(true);
expect(isModelCapable('openai', 'gpt-4-turbo')).toBe(true);
expect(isModelCapable('openai', 'gpt-4-0613')).toBe(true);
});
test('should consider GPT-3.5-turbo as capable', () => {
expect(isModelCapable('openai', 'gpt-3.5-turbo')).toBe(true);
expect(isModelCapable('openai', 'gpt-3.5-turbo-16k')).toBe(true);
});
test('should consider O-series models as capable', () => {
expect(isModelCapable('openai', 'o1-preview')).toBe(true);
expect(isModelCapable('openai', 'o1-mini')).toBe(true);
expect(isModelCapable('openai', 'o3')).toBe(true);
});
test('should consider older GPT-3 models as capable', () => {
expect(isModelCapable('openai', 'gpt-3-davinci')).toBe(true);
expect(isModelCapable('openai', 'gpt-3-curie')).toBe(true);
});
});
describe('Anthropic models', () => {
test('should consider Claude-3 models as capable', () => {
expect(isModelCapable('anthropic', 'claude-3-opus')).toBe(true);
expect(isModelCapable('anthropic', 'claude-3-sonnet')).toBe(true);
});
test('should consider Claude-2 as capable', () => {
expect(isModelCapable('anthropic', 'claude-2')).toBe(true);
expect(isModelCapable('anthropic', 'claude-2.1')).toBe(true);
});
test('should consider Claude-1 as capable', () => {
expect(isModelCapable('anthropic', 'claude-1')).toBe(true);
});
});
describe('Google models', () => {
test('should consider Gemini Pro models as capable', () => {
expect(isModelCapable('google', 'gemini-pro')).toBe(true);
expect(isModelCapable('gemini', 'gemini-ultra')).toBe(true);
});
test('should consider PaLM-2 models as not capable', () => {
expect(isModelCapable('google', 'palm-2-chat')).toBe(false);
});
});
describe('Local/Ollama models', () => {
test('should consider larger models as not capable', () => {
expect(isModelCapable('ollama', 'llama2-70b')).toBe(false);
expect(isModelCapable('local', 'codellama-34b')).toBe(false);
});
test('should consider smaller models as less capable', () => {
expect(isModelCapable('ollama', 'llama2-7b')).toBe(false);
expect(isModelCapable('local', 'mistral-7b')).toBe(false);
});
});
describe('Meta/Llama models', () => {
test('should consider large Llama models as not capable', () => {
expect(isModelCapable('llama', 'llama-2-70b')).toBe(false);
expect(isModelCapable('meta', 'llama-65b')).toBe(false);
});
test('should consider small Llama models as less capable', () => {
expect(isModelCapable('llama', 'llama-2-7b')).toBe(false);
expect(isModelCapable('meta', 'llama-13b')).toBe(false);
});
});
describe('Continue Proxy models', () => {
test('should consider continue-proxy models as not capable', () => {
expect(isModelCapable('continue-proxy', 'any-model')).toBe(false);
});
});
describe('Hugging Face models', () => {
test('should consider code-specific models as not capable', () => {
expect(isModelCapable('huggingface', 'codellama-instruct')).toBe(false);
expect(isModelCapable('huggingface', 'starcoder-base')).toBe(false);
});
test('should consider general chat models as less capable', () => {
expect(isModelCapable('huggingface', 'falcon-7b')).toBe(false);
});
});
describe('Unknown providers', () => {
test('should default to not capable for unknown providers', () => {
expect(isModelCapable('unknown-provider', 'some-model')).toBe(false);
});
});
describe('Other capable models', () => {
test('should consider Qwen models as capable', () => {
expect(isModelCapable('alibaba', 'qwen-turbo')).toBe(true);
expect(isModelCapable('dashscope', 'qwen-max')).toBe(true);
});
test('should consider Kimi models as capable', () => {
expect(isModelCapable('moonshot', 'kimi-8k')).toBe(true);
expect(isModelCapable('moonshot', 'kimi-32k')).toBe(true);
});
});
describe('Case insensitivity', () => {
test('should handle different cases correctly', () => {
expect(isModelCapable('OPENAI', 'GPT-4')).toBe(true);
expect(isModelCapable('OpenAI', 'Gpt-4-Turbo')).toBe(true);
expect(isModelCapable('anthropic', 'CLAUDE-3-OPUS')).toBe(true);
});
});
});

View file

@ -0,0 +1,16 @@
/**
* Determines if a model is recommended for use with `cn`
*/
export function isModelCapable(provider: string, model: string): boolean {
const normalizedModel = model.toLowerCase();
if (
[/gemini/, /claude/, /gpt/, /o\d/g, /kimi/, /qwen/].some((pattern) =>
pattern.test(normalizedModel)
)
) {
return true;
}
return false;
}