From 8299e24ccd64987cb898cae74622d5bb06d9e538 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 3 Jul 2025 10:46:08 -0400 Subject: fixed creating docs with ai tool to allow options to be specified. --- src/client/documents/Documents.ts | 1 - .../nodes/chatbot/chatboxcomponents/ChatBox.tsx | 32 ++++++++++++---------- .../nodes/chatbot/tools/DocumentMetadataTool.ts | 18 +++++++++--- .../nodes/chatbot/utils/AgentDocumentManager.ts | 22 +++++++-------- 4 files changed, 42 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 6fd6534a4..22a771a11 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -312,7 +312,6 @@ export class DocumentOptions { title_transform?: STRt = new StrInfo('transformation to apply to title in label box (eg., uppercase)', undefined, undefined, ['uppercase', 'lowercase', 'capitalize']); text_transform?: STRt = new StrInfo('transformation to apply to text in text box (eg., uppercase)', undefined, undefined, ['uppercase', 'lowercase', 'capitalize']); text_placeholder?: BOOLt = new BoolInfo('makes the text act like a placeholder and automatically select when the text box is selected'); - fontSize?: string; _pivotField?: string; // field key used to determine headings for sections in stacking, masonry, pivot views infoWindowOpen?: BOOLt = new BoolInfo('whether info window corresponding to pin is open (on MapDocuments)'); diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index f84a4cd2a..acf6870c3 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -111,13 +111,11 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { super(props); makeObservable(this); - // At mount time, find the DocumentView whose .Document is the collection container. - const parentView = DocumentView.Selected().lastElement(); - if (!parentView) { - console.warn("GPT ChatBox not inside a DocumentView – cannot sort."); - } - - + // At mount time, find the DocumentView whose .Document is the collection container. + const parentView = DocumentView.Selected().lastElement(); + if (!parentView) { + console.warn('GPT ChatBox not inside a DocumentView – cannot sort.'); + } this.messagesRef = React.createRef(); this.docManager = new AgentDocumentManager(this, parentView); @@ -162,7 +160,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { } ); - /* + /* reaction( () => ({ selDoc: DocumentView.Selected().lastElement(), visible: SnappingManager.ChatVisible }), ({ selDoc, visible }) => { @@ -376,15 +374,19 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { @action askGPT = async (event: React.FormEvent): Promise => { event.preventDefault(); + if (!this._textInputRef) { + console.log('ERROR: text input ref is undefined'); + return; + } this._inputValue = ''; // Extract the user's message - const textInput = (event.currentTarget as HTMLFormElement).elements.namedItem('messageInput') as HTMLInputElement; - const trimmedText = textInput.value.trim(); + const textInput = this._textInputRef?.value ?? ''; + const trimmedText = textInput.trim(); if (trimmedText) { + this._textInputRef.value = ''; // Clear the input field try { - textInput.value = ''; // Add the user's message to the history this._history.push({ role: ASSISTANT_ROLE.USER, @@ -511,7 +513,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { @action public whichDoc = (doc: parsedDoc, insideCol: boolean): Opt => { - const options = OmitKeys(doc, ['doct_type', 'data']).omit as DocumentOptions; + const options = OmitKeys(doc, ['doc_type', 'data']).omit as DocumentOptions; const data = (doc as parsedDocData).data; const ndoc = (() => { switch (doc.doc_type) { @@ -1475,20 +1477,20 @@ export class ChatBox extends ViewBoxAnnotatableComponent() {
- (this._inputValue = e.target.value))} + onChange={e => this.setChatInput(e.target.value)} disabled={this._isLoading} />