UNPKG

@ai-stack/payloadcms

Version:

<p align="center"> <img alt="Payload AI Plugin" src="assets/payload-ai-intro.gif" width="100%" /> </p>

129 lines (128 loc) 4.31 kB
import { anthropic } from '@ai-sdk/anthropic'; import { defaultSystemPrompt } from '../../prompts.js'; import { generateObject } from '../generateObject.js'; const MODEL_KEY = 'ANTH-C'; const MODELS = [ 'claude-opus-4-1', 'claude-opus-4-0', 'claude-sonnet-4-0', 'claude-3-opus-latest', 'claude-3-5-haiku-latest', 'claude-3-5-sonnet-latest', 'claude-3-7-sonnet-latest' ]; export const AnthropicConfig = { models: [ { id: `${MODEL_KEY}-text`, name: 'Anthropic Claude', fields: [ 'text', 'textarea' ], handler: (prompt, options)=>{ return generateObject(prompt, { ...options, system: options.system || defaultSystemPrompt }, anthropic(options.model)); }, output: 'text', settings: { name: `${MODEL_KEY}-text-settings`, type: 'group', admin: { condition (data) { return data['model-id'] === `${MODEL_KEY}-text`; } }, fields: [ { name: 'model', type: 'select', defaultValue: 'claude-3-5-sonnet-latest', label: 'Model', options: MODELS }, { type: 'row', fields: [ { name: 'maxTokens', type: 'number', defaultValue: 5000 }, { name: 'temperature', type: 'number', defaultValue: 0.7, max: 1, min: 0 } ] }, { name: 'extractAttachments', type: 'checkbox' } ], label: 'Anthropic Claude Settings' } }, { id: `${MODEL_KEY}-object`, name: 'Anthropic Claude', fields: [ 'richText' ], handler: (text, options)=>{ return generateObject(text, { ...options, system: options.system || defaultSystemPrompt }, anthropic(options.model)); }, output: 'text', settings: { name: `${MODEL_KEY}-object-settings`, type: 'group', admin: { condition (data) { return data['model-id'] === `${MODEL_KEY}-object`; } }, fields: [ { name: 'model', type: 'select', defaultValue: 'claude-3-5-sonnet-latest', label: 'Model', options: MODELS }, { type: 'row', fields: [ { name: 'maxTokens', type: 'number', defaultValue: 5000 }, { name: 'temperature', type: 'number', defaultValue: 0.7, max: 1, min: 0 } ] }, { name: 'extractAttachments', type: 'checkbox' } ], label: 'Anthropic Claude Settings' } } ], provider: 'Anthropic' }; //# sourceMappingURL=index.js.map