mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
929bec8f31
Stop blocking AI imports/proposals on missing non-critical fields. Records the chat agent drafts now save with safe placeholders, auto-generated file numbers, and a source="ai" marker that surfaces an "Added by AI" badge so a clinician can review/edit them later. Backend: - add `source` (manual|ai) column to patients/appointments/prescriptions (migration 0014) + canonical types, services, validation schemas - relax patient/appointment validation: empty file number allowed, demographic + type/provider/initials fall back to placeholders (initials derived from name) - patients.generateFileNumber() auto-assigns an MRN when one is missing - proposeAppointment accepts a name when no file number resolves; AI commits + /api/ai/import stamp source="ai" Frontend: - `source` on Appointment/Patient/Prescription types; AI commits send source="ai" - reusable <AiBadge> shown on the Patients table/detail and prescriptions list Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
Agent,
|
|
AgentContent,
|
|
AgentHeader,
|
|
AgentInstructions,
|
|
AgentOutput,
|
|
AgentTool,
|
|
AgentTools,
|
|
} from "@/components/ai-elements/agent";
|
|
import { z } from "zod";
|
|
|
|
const webSearchTool = {
|
|
description: "Search the web for information",
|
|
inputSchema: z.object({
|
|
query: z.string().describe("The search query"),
|
|
}),
|
|
};
|
|
|
|
const readUrlTool = {
|
|
description: "Read and parse a URL",
|
|
inputSchema: z.object({
|
|
url: z.string().url().describe("The URL to read"),
|
|
}),
|
|
};
|
|
|
|
const summarizeTool = {
|
|
description: "Summarize text into key points",
|
|
inputSchema: z.object({
|
|
maxPoints: z.number().optional().describe("Maximum number of key points"),
|
|
text: z.string().describe("The text to summarize"),
|
|
}),
|
|
};
|
|
|
|
const outputSchema = `z.object({
|
|
sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
score: z.number(),
|
|
summary: z.string(),
|
|
})`;
|
|
|
|
const Example = () => (
|
|
<Agent>
|
|
<AgentHeader model="openai/gpt-5.2-pro" name="Research Assistant" />
|
|
<AgentContent>
|
|
<AgentInstructions>
|
|
You are a helpful research assistant. Your job is to search the web for
|
|
information and summarize findings for the user. Always cite your
|
|
sources and provide accurate, up-to-date information.
|
|
</AgentInstructions>
|
|
<AgentTools type="multiple">
|
|
<AgentTool tool={webSearchTool} value="web_search" />
|
|
<AgentTool tool={readUrlTool} value="read_url" />
|
|
<AgentTool tool={summarizeTool} value="summarize" />
|
|
</AgentTools>
|
|
<AgentOutput schema={outputSchema} />
|
|
</AgentContent>
|
|
</Agent>
|
|
);
|
|
|
|
export default Example;
|