File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed
tools/server/webui/src/utils Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -66,10 +66,16 @@ export function normalizeMsgsForAPI(messages: Readonly<Message[]>) {
6666
6767 newContent += msg . content ;
6868
69- return {
69+ const apiMsg = {
7070 role : msg . role ,
7171 content : newContent ,
72- } ;
72+ } as APIMessage ;
73+
74+ if ( msg . tool_calls && msg . tool_calls . length > 0 ) {
75+ apiMsg . tool_calls = msg . tool_calls ;
76+ }
77+
78+ return apiMsg ;
7379 } ) as APIMessage [ ] ;
7480}
7581
@@ -78,13 +84,19 @@ export function normalizeMsgsForAPI(messages: Readonly<Message[]>) {
7884 */
7985export function filterThoughtFromMsgs ( messages : APIMessage [ ] ) {
8086 return messages . map ( ( msg ) => {
81- return {
87+ const filteredMessage : APIMessage = {
8288 role : msg . role ,
8389 content :
8490 msg . role === 'assistant'
8591 ? msg . content . split ( '</think>' ) . at ( - 1 ) ! . trim ( )
8692 : msg . content ,
87- } as APIMessage ;
93+ } ;
94+
95+ if ( msg . tool_calls && msg . tool_calls . length > 0 ) {
96+ filteredMessage . tool_calls = msg . tool_calls ;
97+ }
98+
99+ return filteredMessage ;
88100 } ) ;
89101}
90102
Original file line number Diff line number Diff line change @@ -136,8 +136,6 @@ const StorageUtils = {
136136 ) : Promise < void > {
137137 if ( messages . length === 0 ) return ;
138138
139- console . log ( 'Saving messges! ' + JSON . stringify ( messages ) ) ;
140-
141139 const { convId } = messages [ 0 ] ;
142140
143141 // Verify conversation exists
@@ -196,15 +194,11 @@ const StorageUtils = {
196194 currNode : lastMsgId ,
197195 } ) ;
198196 } ) ;
199-
200- console . log ( `Successfully saved chain of ${ messages . length } messages` ) ;
201197 } catch ( error ) {
202198 console . error ( 'Error saving message chain:' , error ) ;
203199 throw error ;
204200 }
205201
206- if ( isDev ) console . log ( 'Updated conversation:' , convId ) ;
207-
208202 dispatchConversationChange ( convId ) ;
209203 } ,
210204
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ export interface MessageExtraContext {
6262 content : string ;
6363}
6464
65- export type APIMessage = Pick < Message , 'role' | 'content' > ;
65+ export type APIMessage = Pick < Message , 'role' | 'content' | 'tool_calls' > ;
6666
6767export interface Conversation {
6868 id : string ; // format: `conv-{timestamp}`
You can’t perform that action at this time.
0 commit comments