File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,9 @@ import {
1212import { UUID } from '@lumino/coreutils' ;
1313import type { ChatMistralAI } from '@langchain/mistralai' ;
1414import {
15+ AIMessage ,
1516 HumanMessage ,
16- mergeMessageRuns ,
17- SystemMessage
17+ mergeMessageRuns
1818} from '@langchain/core/messages' ;
1919
2020export type ConnectionMessage = {
@@ -39,21 +39,13 @@ export class CodestralHandler extends ChatModel {
3939 } ;
4040 this . messageAdded ( msg ) ;
4141 this . _history . messages . push ( msg ) ;
42- // const response = await this._mistralClient.chat({
43- // model: 'codestral-latest',
44- // messages: this._history.messages.map(msg => {
45- // return {
46- // role: msg.sender === 'User' ? 'user' : 'assistant',
47- // content: msg.body
48- // };
49- // })
50- // });
42+
5143 const messages = mergeMessageRuns (
5244 this . _history . messages . map ( msg => {
5345 if ( msg . sender . username === 'User' ) {
5446 return new HumanMessage ( msg . body ) ;
5547 }
56- return new SystemMessage ( msg . body ) ;
48+ return new AIMessage ( msg . body ) ;
5749 } )
5850 ) ;
5951 const response = await this . _mistralClient . invoke ( messages ) ;
@@ -67,6 +59,7 @@ export class CodestralHandler extends ChatModel {
6759 type : 'msg'
6860 } ;
6961 this . messageAdded ( botMsg ) ;
62+ this . _history . messages . push ( botMsg ) ;
7063 return true ;
7164 }
7265
You can’t perform that action at this time.
0 commit comments