@@ -345,38 +345,19 @@ export class MermaidChart {
345345 public async diagramChat ( request : DiagramChatRequest ) : Promise < DiagramChatResponse > {
346346 const { message, documentID, code = '' , documentChatThreadID } = request ;
347347
348- // Send only the current user message. The backend will prepend the stored
349- // conversation history when autoFetchHistory is true (see AIChatRequestData).
350- const messages = [
351- {
352- id : uuid ( ) ,
353- role : 'user' as const ,
354- content : message ,
355- experimental_attachments : [ ] as [ ] ,
356- } ,
357- ] ;
358-
359- const requestBody = {
360- messages,
361- code,
362- documentID,
363- documentChatThreadID,
364- // parentID null: the backend already handles finding the correct parent
365- parentID : null ,
366- // Tell the backend to fetch DB history and prepend it before calling the AI.
367- autoFetchHistory : true ,
368- } ;
369-
370348 try {
371- const response = await this . axios . post < {
372- text : string ;
373- documentChatThreadID ?: string ;
374- documentID : string ;
375- } > ( URLS . rest . openai . chat , requestBody ) ;
349+ const { data } = await this . axios . post < DiagramChatResponse > ( URLS . rest . openai . chat , {
350+ messages : [ { id : uuid ( ) , role : 'user' as const , content : message , experimental_attachments : [ ] } ] ,
351+ code,
352+ documentID,
353+ documentChatThreadID,
354+ parentID : null ,
355+ autoFetchHistory : true ,
356+ } ) ;
376357
377358 return {
378- text : response . data . text ,
379- documentChatThreadID : response . data . documentChatThreadID ?? documentChatThreadID ,
359+ text : data . text ,
360+ documentChatThreadID : data . documentChatThreadID ?? documentChatThreadID ,
380361 documentID,
381362 } ;
382363 } catch ( error : unknown ) {
0 commit comments