diff --git a/src/components/forms/ai-form.tsx b/src/components/forms/ai-form.tsx new file mode 100644 index 0000000..249fc5d --- /dev/null +++ b/src/components/forms/ai-form.tsx @@ -0,0 +1,136 @@ +import { Input } from '@/components/base/input/input'; +import { Select } from '@/components/base/select/select'; +import { TextArea } from '@/components/base/textarea/textarea'; + +// AI assistant form — mirrors AiConfig in +// helix-engage-server/src/config/ai.defaults.ts. API keys stay in env vars +// (true secrets, rotated at the infra level); everything the admin can safely +// adjust lives here: provider choice, model, temperature, and an optional +// system-prompt addendum appended to the hospital-specific prompts that the +// WidgetChatService generates. + +export type AiProvider = 'openai' | 'anthropic'; + +export type AiFormValues = { + provider: AiProvider; + model: string; + temperature: string; + systemPromptAddendum: string; +}; + +export const emptyAiFormValues = (): AiFormValues => ({ + provider: 'openai', + model: 'gpt-4o-mini', + temperature: '0.7', + systemPromptAddendum: '', +}); + +const PROVIDER_ITEMS = [ + { id: 'openai', label: 'OpenAI' }, + { id: 'anthropic', label: 'Anthropic' }, +]; + +// Recommended model presets per provider. Admin can still type any model +// string they want — these are suggestions, not the only options. +export const MODEL_SUGGESTIONS: Record = { + openai: ['gpt-4o-mini', 'gpt-4o', 'gpt-4-turbo', 'gpt-3.5-turbo'], + anthropic: ['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest', 'claude-3-opus-latest'], +}; + +type AiFormProps = { + value: AiFormValues; + onChange: (value: AiFormValues) => void; +}; + +export const AiForm = ({ value, onChange }: AiFormProps) => { + const patch = (updates: Partial) => onChange({ ...value, ...updates }); + + const suggestions = MODEL_SUGGESTIONS[value.provider]; + + return ( +
+
+
+

Provider & model

+

+ Choose the AI vendor powering the website widget chat and call-summary features. + Changing providers takes effect immediately. +

+
+ + + +
+ patch({ model: v })} + /> +
+ {suggestions.map((model) => ( + + ))} +
+
+ + patch({ temperature: v })} + /> +
+ +
+
+

System prompt addendum

+

+ Optional — gets appended to the hospital-specific prompts the widget generates + automatically from your doctors and clinics. Use this to add tone guidelines, + escalation rules, or topics the assistant should avoid. Leave blank for the default + behaviour. +

+
+