@sqlrooms/ai-settings 0.27.0-rc.3 → 0.27.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,6 @@
1
1
  import { FC } from 'react';
2
- export declare const AiModelParameters: FC;
2
+ export interface AiModelParametersProps {
3
+ showViewInstructions?: boolean;
4
+ }
5
+ export declare const AiModelParameters: FC<AiModelParametersProps>;
3
6
  //# sourceMappingURL=AiModelParameters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiModelParameters.d.ts","sourceRoot":"","sources":["../../src/components/AiModelParameters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAS,MAAM,OAAO,CAAC;AAgBjC,eAAO,MAAM,iBAAiB,EAAE,EAgM/B,CAAC"}
1
+ {"version":3,"file":"AiModelParameters.d.ts","sourceRoot":"","sources":["../../src/components/AiModelParameters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAS,MAAM,OAAO,CAAC;AAgBjC,MAAM,WAAW,sBAAsB;IACrC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAoMxD,CAAC"}
@@ -3,7 +3,7 @@ import { useRef } from 'react';
3
3
  import { Sliders, Wrench, FileText, Upload, Eye } from 'lucide-react';
4
4
  import { Textarea, Input, Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, useDisclosure, useToast, } from '@sqlrooms/ui';
5
5
  import { useStoreWithAiSettings } from '../AiSettingsSlice';
6
- export const AiModelParameters = () => {
6
+ export const AiModelParameters = ({ showViewInstructions = false, }) => {
7
7
  const maxSteps = useStoreWithAiSettings((s) => s.aiSettings.config.modelParameters.maxSteps);
8
8
  const setMaxStepsAiChatUi = useStoreWithAiSettings((s) => s.aiSettings.setMaxSteps);
9
9
  const additionalInstruction = useStoreWithAiSettings((s) => s.aiSettings.config.modelParameters.additionalInstruction);
@@ -74,6 +74,6 @@ export const AiModelParameters = () => {
74
74
  const handleViewFullInstructions = () => {
75
75
  onOpen();
76
76
  };
77
- return (_jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "text-md flex items-center gap-2 pb-6 font-medium", children: [_jsx(Sliders, { className: "h-4 w-4" }), "Model Parameters"] }), _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm font-medium", children: [_jsx(Wrench, { className: "h-4 w-4" }), "Max Tool Steps"] }), _jsx("div", { className: "flex items-center gap-2", children: _jsx(Input, { type: "number", min: "1", max: "20", step: "1", value: maxSteps, onChange: (e) => handleMaxStepsChange(parseInt(e.target.value) || 1), className: "flex-1" }) })] }), _jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm font-medium", children: [_jsx(FileText, { className: "h-4 w-4" }), "Additional Instructions"] }), _jsx(Textarea, { value: additionalInstruction, onChange: (e) => handleAdditionalInstructionChange(e.target.value), placeholder: "Enter custom system instructions for the AI model...", className: "min-h-[80px] resize-y", autoResize: false }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: handleUploadButtonClick, className: "flex items-center gap-2", children: [_jsx(Upload, { className: "h-4 w-4" }), "Upload File"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: handleViewFullInstructions, className: "flex items-center gap-2", children: [_jsx(Eye, { className: "h-4 w-4" }), "View Instructions"] })] }), _jsx(Input, { ref: fileInputRef, type: "file", accept: ".txt,.md,.json,.text,text/plain,text/markdown,application/json", onChange: handleFileUpload, style: { display: 'none' } })] })] }), _jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: _jsxs(DialogContent, { className: "flex h-[80vh] max-w-4xl flex-col", children: [_jsxs(DialogHeader, { className: "flex-shrink-0", children: [_jsx(DialogTitle, { children: "Full System Instructions" }), _jsx(DialogDescription, { children: "Complete system instructions that will be sent to the AI model, including default instructions and your additional custom instructions." })] }), _jsx("div", { className: "mt-4 min-h-0 flex-1 overflow-hidden", children: _jsx("div", { className: "bg-muted/50 h-full overflow-auto rounded-lg p-4", children: _jsx("pre", { className: "overflow-wrap-anywhere w-full max-w-full break-words font-mono text-sm leading-relaxed", children: getFullInstructions() }) }) })] }) })] }));
77
+ return (_jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "text-md flex items-center gap-2 pb-6 font-medium", children: [_jsx(Sliders, { className: "h-4 w-4" }), "Model Parameters"] }), _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm font-medium", children: [_jsx(Wrench, { className: "h-4 w-4" }), "Max Tool Steps"] }), _jsx("div", { className: "flex items-center gap-2", children: _jsx(Input, { type: "number", min: "1", max: "20", step: "1", value: maxSteps, onChange: (e) => handleMaxStepsChange(parseInt(e.target.value) || 1), className: "flex-1" }) })] }), _jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm font-medium", children: [_jsx(FileText, { className: "h-4 w-4" }), "Additional Instructions"] }), _jsx(Textarea, { value: additionalInstruction, onChange: (e) => handleAdditionalInstructionChange(e.target.value), placeholder: "Enter custom system instructions for the AI model...", className: "min-h-[80px] resize-y", autoResize: false }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: handleUploadButtonClick, className: "flex items-center gap-2", children: [_jsx(Upload, { className: "h-4 w-4" }), "Upload File"] }), showViewInstructions && (_jsxs(Button, { variant: "outline", size: "sm", onClick: handleViewFullInstructions, className: "flex items-center gap-2", children: [_jsx(Eye, { className: "h-4 w-4" }), "View Instructions"] }))] }), _jsx(Input, { ref: fileInputRef, type: "file", accept: ".txt,.md,.json,.text,text/plain,text/markdown,application/json", onChange: handleFileUpload, style: { display: 'none' } })] })] }), _jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: _jsxs(DialogContent, { className: "flex h-[80vh] max-w-4xl flex-col", children: [_jsxs(DialogHeader, { className: "flex-shrink-0", children: [_jsx(DialogTitle, { children: "Full System Instructions" }), _jsx(DialogDescription, { children: "Complete system instructions that will be sent to the AI model, including default instructions and your additional custom instructions." })] }), _jsx("div", { className: "mt-4 min-h-0 flex-1 overflow-hidden", children: _jsx("div", { className: "bg-muted/50 h-full overflow-auto rounded-lg p-4", children: _jsx("pre", { className: "overflow-wrap-anywhere w-full max-w-full break-words font-mono text-sm leading-relaxed", children: getFullInstructions() }) }) })] }) })] }));
78
78
  };
79
79
  //# sourceMappingURL=AiModelParameters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiModelParameters.js","sourceRoot":"","sources":["../../src/components/AiModelParameters.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,MAAM,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAE1D,MAAM,CAAC,MAAM,iBAAiB,GAAO,GAAG,EAAE;IACxC,MAAM,QAAQ,GAAG,sBAAsB,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CACpD,CAAC;IACF,MAAM,mBAAmB,GAAG,sBAAsB,CAChD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAChC,CAAC;IAEF,MAAM,qBAAqB,GAAG,sBAAsB,CAClD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAA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SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAC,yBAAyB,aAEnC,KAAC,GAAG,IAAC,SAAS,EAAC,SAAS,GAAG,yBAEpB,IACL,EACN,KAAC,KAAK,IACJ,GAAG,EAAE,YAAY,EACjB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,gEAAgE,EACvE,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC,GACxB,IACE,IACF,EAGN,KAAC,MAAM,IAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,YACzC,MAAC,aAAa,IAAC,SAAS,EAAC,kCAAkC,aACzD,MAAC,YAAY,IAAC,SAAS,EAAC,eAAe,aACrC,KAAC,WAAW,2CAAuC,EACnD,KAAC,iBAAiB,0JAIE,IACP,EACf,cAAK,SAAS,EAAC,qCAAqC,YAClD,cAAK,SAAS,EAAC,iDAAiD,YAC9D,cAAK,SAAS,EAAC,wFAAwF,YACpG,mBAAmB,EAAE,GAClB,GACF,GACF,IACQ,GACT,IACL,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useRef} from 'react';\nimport {Sliders, Wrench, FileText, Upload, Eye} from 'lucide-react';\nimport {\n Textarea,\n Input,\n Button,\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogDescription,\n useDisclosure,\n useToast,\n} from '@sqlrooms/ui';\nimport {useStoreWithAiSettings} from '../AiSettingsSlice';\n\nexport const AiModelParameters: FC = () => {\n const maxSteps = useStoreWithAiSettings(\n (s) => s.aiSettings.config.modelParameters.maxSteps,\n );\n const setMaxStepsAiChatUi = useStoreWithAiSettings(\n (s) => s.aiSettings.setMaxSteps,\n );\n\n const additionalInstruction = useStoreWithAiSettings(\n (s) => s.aiSettings.config.modelParameters.additionalInstruction,\n );\n const setAdditionalInstruction = useStoreWithAiSettings(\n (s) => s.aiSettings.setAdditionalInstruction,\n );\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const {toast} = useToast();\n\n const {isOpen, onOpen, onClose} = useDisclosure();\n\n const handleMaxStepsChange = (value: number) => {\n setMaxStepsAiChatUi(value);\n };\n\n const handleAdditionalInstructionChange = (value: string) => {\n setAdditionalInstruction(value);\n };\n\n const getFullInstructions = useStoreWithAiSettings(\n (s) => s.ai.getFullInstructions,\n );\n\n const handleFileUpload = async (\n event: React.ChangeEvent<HTMLInputElement>,\n ) => {\n const file = event.target.files?.[0];\n if (!file) return;\n\n // Validate file type\n const allowedTypes = ['text/plain', 'text/markdown', 'application/json'];\n const allowedExtensions = ['.txt', '.md', '.json', '.text'];\n const fileExtension = file.name\n .toLowerCase()\n .slice(file.name.lastIndexOf('.'));\n\n if (\n !allowedTypes.includes(file.type) &&\n !allowedExtensions.includes(fileExtension)\n ) {\n toast({\n title: 'Invalid file type',\n description: 'Please select a text file (.txt, .md, .json)',\n variant: 'destructive',\n });\n return;\n }\n\n // Validate file size (max 1MB)\n const maxSize = 1024 * 1024; // 1MB\n if (file.size > maxSize) {\n toast({\n title: 'File too large',\n description: 'File size must be less than 1MB',\n variant: 'destructive',\n });\n return;\n }\n\n try {\n const text = await file.text();\n setAdditionalInstruction(text);\n toast({\n title: 'File uploaded successfully',\n description:\n 'System instructions have been updated from the uploaded file.',\n });\n } catch (error) {\n console.error('Error reading file:', error);\n toast({\n title: 'Error reading file',\n description: 'Please try again.',\n variant: 'destructive',\n });\n }\n\n // Reset the input so the same file can be selected again\n if (fileInputRef.current) {\n fileInputRef.current.value = '';\n }\n };\n\n const handleUploadButtonClick = () => {\n fileInputRef.current?.click();\n };\n\n const handleViewFullInstructions = () => {\n onOpen();\n };\n\n return (\n <div className=\"space-y-2\">\n <label className=\"text-md flex items-center gap-2 pb-6 font-medium\">\n <Sliders className=\"h-4 w-4\" />\n Model Parameters\n </label>\n <div className=\"grid grid-cols-1 gap-4\">\n {/* Max Steps */}\n <div className=\"space-y-2\">\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <Wrench className=\"h-4 w-4\" />\n Max Tool Steps\n </label>\n <div className=\"flex items-center gap-2\">\n <Input\n type=\"number\"\n min=\"1\"\n max=\"20\"\n step=\"1\"\n value={maxSteps}\n onChange={(e) =>\n handleMaxStepsChange(parseInt(e.target.value) || 1)\n }\n className=\"flex-1\"\n />\n </div>\n </div>\n\n {/* Additional Instruction */}\n <div className=\"space-y-2\">\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <FileText className=\"h-4 w-4\" />\n Additional Instructions\n </label>\n <Textarea\n value={additionalInstruction}\n onChange={(e) => handleAdditionalInstructionChange(e.target.value)}\n placeholder=\"Enter custom system instructions for the AI model...\"\n className=\"min-h-[80px] resize-y\"\n autoResize={false}\n />\n <div className=\"flex items-center gap-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleUploadButtonClick}\n className=\"flex items-center gap-2\"\n >\n <Upload className=\"h-4 w-4\" />\n Upload File\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleViewFullInstructions}\n className=\"flex items-center gap-2\"\n >\n <Eye className=\"h-4 w-4\" />\n View Instructions\n </Button>\n </div>\n <Input\n ref={fileInputRef}\n type=\"file\"\n accept=\".txt,.md,.json,.text,text/plain,text/markdown,application/json\"\n onChange={handleFileUpload}\n style={{display: 'none'}}\n />\n </div>\n </div>\n\n {/* Full Instructions Modal */}\n <Dialog open={isOpen} onOpenChange={onClose}>\n <DialogContent className=\"flex h-[80vh] max-w-4xl flex-col\">\n <DialogHeader className=\"flex-shrink-0\">\n <DialogTitle>Full System Instructions</DialogTitle>\n <DialogDescription>\n Complete system instructions that will be sent to the AI model,\n including default instructions and your additional custom\n instructions.\n </DialogDescription>\n </DialogHeader>\n <div className=\"mt-4 min-h-0 flex-1 overflow-hidden\">\n <div className=\"bg-muted/50 h-full overflow-auto rounded-lg p-4\">\n <pre className=\"overflow-wrap-anywhere w-full max-w-full break-words font-mono text-sm leading-relaxed\">\n {getFullInstructions()}\n </pre>\n </div>\n </div>\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"AiModelParameters.js","sourceRoot":"","sources":["../../src/components/AiModelParameters.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,MAAM,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAM1D,MAAM,CAAC,MAAM,iBAAiB,GAA+B,CAAC,EAC5D,oBAAoB,GAAG,KAAK,GAC7B,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,sBAAsB,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CACpD,CAAC;IACF,MAAM,mBAAmB,GAAG,sBAAsB,CAChD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAChC,CAAC;IAEF,MAAM,qBAAqB,GAAG,sBAAsB,CAClD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,qBAAqB,CACjE,CAAC;IACF,MAAM,wBAAwB,GAAG,sBAAsB,CACrD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,wBAAwB,CAC7C,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IACpD,MAAM,EAAC,KAAK,EAAC,GAAG,QAAQ,EAAE,CAAC;IAE3B,MAAM,EAAC,MAAM,EAAE,MA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OAAO,EAAE,MAAM,EAAC,GACxB,IACE,IACF,EAGN,KAAC,MAAM,IAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,YACzC,MAAC,aAAa,IAAC,SAAS,EAAC,kCAAkC,aACzD,MAAC,YAAY,IAAC,SAAS,EAAC,eAAe,aACrC,KAAC,WAAW,2CAAuC,EACnD,KAAC,iBAAiB,0JAIE,IACP,EACf,cAAK,SAAS,EAAC,qCAAqC,YAClD,cAAK,SAAS,EAAC,iDAAiD,YAC9D,cAAK,SAAS,EAAC,wFAAwF,YACpG,mBAAmB,EAAE,GAClB,GACF,GACF,IACQ,GACT,IACL,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useRef} from 'react';\nimport {Sliders, Wrench, FileText, Upload, Eye} from 'lucide-react';\nimport {\n Textarea,\n Input,\n Button,\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogDescription,\n useDisclosure,\n useToast,\n} from '@sqlrooms/ui';\nimport {useStoreWithAiSettings} from '../AiSettingsSlice';\n\nexport interface AiModelParametersProps {\n showViewInstructions?: boolean;\n}\n\nexport const AiModelParameters: FC<AiModelParametersProps> = ({\n showViewInstructions = false,\n}) => {\n const maxSteps = useStoreWithAiSettings(\n (s) => s.aiSettings.config.modelParameters.maxSteps,\n );\n const setMaxStepsAiChatUi = useStoreWithAiSettings(\n (s) => s.aiSettings.setMaxSteps,\n );\n\n const additionalInstruction = useStoreWithAiSettings(\n (s) => s.aiSettings.config.modelParameters.additionalInstruction,\n );\n const setAdditionalInstruction = useStoreWithAiSettings(\n (s) => s.aiSettings.setAdditionalInstruction,\n );\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const {toast} = useToast();\n\n const {isOpen, onOpen, onClose} = useDisclosure();\n\n const handleMaxStepsChange = (value: number) => {\n setMaxStepsAiChatUi(value);\n };\n\n const handleAdditionalInstructionChange = (value: string) => {\n setAdditionalInstruction(value);\n };\n\n const getFullInstructions = useStoreWithAiSettings(\n (s) => s.ai.getFullInstructions,\n );\n\n const handleFileUpload = async (\n event: React.ChangeEvent<HTMLInputElement>,\n ) => {\n const file = event.target.files?.[0];\n if (!file) return;\n\n // Validate file type\n const allowedTypes = ['text/plain', 'text/markdown', 'application/json'];\n const allowedExtensions = ['.txt', '.md', '.json', '.text'];\n const fileExtension = file.name\n .toLowerCase()\n .slice(file.name.lastIndexOf('.'));\n\n if (\n !allowedTypes.includes(file.type) &&\n !allowedExtensions.includes(fileExtension)\n ) {\n toast({\n title: 'Invalid file type',\n description: 'Please select a text file (.txt, .md, .json)',\n variant: 'destructive',\n });\n return;\n }\n\n // Validate file size (max 1MB)\n const maxSize = 1024 * 1024; // 1MB\n if (file.size > maxSize) {\n toast({\n title: 'File too large',\n description: 'File size must be less than 1MB',\n variant: 'destructive',\n });\n return;\n }\n\n try {\n const text = await file.text();\n setAdditionalInstruction(text);\n toast({\n title: 'File uploaded successfully',\n description:\n 'System instructions have been updated from the uploaded file.',\n });\n } catch (error) {\n console.error('Error reading file:', error);\n toast({\n title: 'Error reading file',\n description: 'Please try again.',\n variant: 'destructive',\n });\n }\n\n // Reset the input so the same file can be selected again\n if (fileInputRef.current) {\n fileInputRef.current.value = '';\n }\n };\n\n const handleUploadButtonClick = () => {\n fileInputRef.current?.click();\n };\n\n const handleViewFullInstructions = () => {\n onOpen();\n };\n\n return (\n <div className=\"space-y-2\">\n <label className=\"text-md flex items-center gap-2 pb-6 font-medium\">\n <Sliders className=\"h-4 w-4\" />\n Model Parameters\n </label>\n <div className=\"grid grid-cols-1 gap-4\">\n {/* Max Steps */}\n <div className=\"space-y-2\">\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <Wrench className=\"h-4 w-4\" />\n Max Tool Steps\n </label>\n <div className=\"flex items-center gap-2\">\n <Input\n type=\"number\"\n min=\"1\"\n max=\"20\"\n step=\"1\"\n value={maxSteps}\n onChange={(e) =>\n handleMaxStepsChange(parseInt(e.target.value) || 1)\n }\n className=\"flex-1\"\n />\n </div>\n </div>\n\n {/* Additional Instruction */}\n <div className=\"space-y-2\">\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <FileText className=\"h-4 w-4\" />\n Additional Instructions\n </label>\n <Textarea\n value={additionalInstruction}\n onChange={(e) => handleAdditionalInstructionChange(e.target.value)}\n placeholder=\"Enter custom system instructions for the AI model...\"\n className=\"min-h-[80px] resize-y\"\n autoResize={false}\n />\n <div className=\"flex items-center gap-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleUploadButtonClick}\n className=\"flex items-center gap-2\"\n >\n <Upload className=\"h-4 w-4\" />\n Upload File\n </Button>\n {showViewInstructions && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleViewFullInstructions}\n className=\"flex items-center gap-2\"\n >\n <Eye className=\"h-4 w-4\" />\n View Instructions\n </Button>\n )}\n </div>\n <Input\n ref={fileInputRef}\n type=\"file\"\n accept=\".txt,.md,.json,.text,text/plain,text/markdown,application/json\"\n onChange={handleFileUpload}\n style={{display: 'none'}}\n />\n </div>\n </div>\n\n {/* Full Instructions Modal */}\n <Dialog open={isOpen} onOpenChange={onClose}>\n <DialogContent className=\"flex h-[80vh] max-w-4xl flex-col\">\n <DialogHeader className=\"flex-shrink-0\">\n <DialogTitle>Full System Instructions</DialogTitle>\n <DialogDescription>\n Complete system instructions that will be sent to the AI model,\n including default instructions and your additional custom\n instructions.\n </DialogDescription>\n </DialogHeader>\n <div className=\"mt-4 min-h-0 flex-1 overflow-hidden\">\n <div className=\"bg-muted/50 h-full overflow-auto rounded-lg p-4\">\n <pre className=\"overflow-wrap-anywhere w-full max-w-full break-words font-mono text-sm leading-relaxed\">\n {getFullInstructions()}\n </pre>\n </div>\n </div>\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n"]}
@@ -11,7 +11,7 @@ export declare const AiSettingsPanel: FC<PropsWithChildren<AiSettingsPanelProps>
11
11
  className?: string;
12
12
  modelUsage?: import("./AiModelUsage").ModelUsageData;
13
13
  }>;
14
- ModelParametersSettings: FC;
14
+ ModelParametersSettings: FC<import("./AiModelParameters").AiModelParametersProps>;
15
15
  };
16
16
  export {};
17
17
  //# sourceMappingURL=AiSettingsPanel.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/ai-settings",
3
- "version": "0.27.0-rc.3",
3
+ "version": "0.27.0-rc.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -19,11 +19,11 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@sqlrooms/ai-config": "0.27.0-rc.3",
23
- "@sqlrooms/ai-core": "0.27.0-rc.3",
24
- "@sqlrooms/recharts": "0.27.0-rc.3",
25
- "@sqlrooms/room-store": "0.27.0-rc.3",
26
- "@sqlrooms/ui": "0.27.0-rc.3",
22
+ "@sqlrooms/ai-config": "0.27.0-rc.5",
23
+ "@sqlrooms/ai-core": "0.27.0-rc.5",
24
+ "@sqlrooms/recharts": "0.27.0-rc.5",
25
+ "@sqlrooms/room-store": "0.27.0-rc.5",
26
+ "@sqlrooms/ui": "0.27.0-rc.5",
27
27
  "immer": "^11.0.1",
28
28
  "lucide-react": "^0.556.0",
29
29
  "recharts": "^2.12.7"
@@ -39,5 +39,5 @@
39
39
  "typecheck": "tsc --noEmit",
40
40
  "typedoc": "typedoc"
41
41
  },
42
- "gitHead": "41dabd4b989c2c15d9aed822714aae869a31197e"
42
+ "gitHead": "d860b9100d63e0d4029712872741abfa3a9c31a1"
43
43
  }