一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
64 行
1.7 KiB
TypeScript
64 行
1.7 KiB
TypeScript
import { ChatRole } from '../types';
|
|
import { _internal } from './Anthropic';
|
|
|
|
describe('ai/providers/Anthropic', () => {
|
|
it('should make tool calls compatible with the Anthropic API', () => {
|
|
const { turnMessages } = _internal.convertMessages([
|
|
{ role: ChatRole.User, content: 'Do something' },
|
|
{
|
|
role: ChatRole.Assistant,
|
|
content: 'okay',
|
|
toolCalls: [
|
|
{ toolName: 'replaceRange', callId: 'call-1', arguments: { text: 'test', anchor: 'original' }, parseError: null },
|
|
{ toolName: 'replaceRange', callId: 'call-2', arguments: { text: 'test-2', anchor: 'other' }, parseError: null },
|
|
],
|
|
},
|
|
{
|
|
role: ChatRole.Tool,
|
|
content: 'success',
|
|
userDescription: 'replaced',
|
|
toolCallId: 'call-1',
|
|
toolName: 'replaceRange',
|
|
isError: false,
|
|
isEdit: true,
|
|
},
|
|
{
|
|
role: ChatRole.Tool,
|
|
userDescription: 'failed',
|
|
content: 'anchor-not-found',
|
|
toolCallId: 'call-2',
|
|
toolName: 'replaceRange',
|
|
isError: true,
|
|
isEdit: true,
|
|
},
|
|
{
|
|
role: ChatRole.User,
|
|
content: 'testing...',
|
|
},
|
|
]);
|
|
|
|
expect(turnMessages).toMatchObject([
|
|
{ role: 'user', content: 'Do something' },
|
|
{
|
|
role: 'assistant',
|
|
content: [
|
|
{ type: 'text', text: 'okay' },
|
|
{ type: 'tool_use', name: 'replaceRange', id: 'call-1', input: { text: 'test', anchor: 'original' } },
|
|
{ type: 'tool_use', name: 'replaceRange', id: 'call-2', input: { text: 'test-2', anchor: 'other' } },
|
|
],
|
|
},
|
|
{
|
|
role: 'user',
|
|
content: [
|
|
{ type: 'tool_result', tool_use_id: 'call-1', content: 'success' },
|
|
{ type: 'tool_result', tool_use_id: 'call-2', content: 'anchor-not-found' },
|
|
],
|
|
},
|
|
{
|
|
role: 'user',
|
|
content: 'testing...',
|
|
},
|
|
]);
|
|
});
|
|
});
|