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 {
12
12
import { UUID } from '@lumino/coreutils' ;
13
13
import type { ChatMistralAI } from '@langchain/mistralai' ;
14
14
import {
15
+ AIMessage ,
15
16
HumanMessage ,
16
- mergeMessageRuns ,
17
- SystemMessage
17
+ mergeMessageRuns
18
18
} from '@langchain/core/messages' ;
19
19
20
20
export type ConnectionMessage = {
@@ -39,21 +39,13 @@ export class CodestralHandler extends ChatModel {
39
39
} ;
40
40
this . messageAdded ( msg ) ;
41
41
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
+
51
43
const messages = mergeMessageRuns (
52
44
this . _history . messages . map ( msg => {
53
45
if ( msg . sender . username === 'User' ) {
54
46
return new HumanMessage ( msg . body ) ;
55
47
}
56
- return new SystemMessage ( msg . body ) ;
48
+ return new AIMessage ( msg . body ) ;
57
49
} )
58
50
) ;
59
51
const response = await this . _mistralClient . invoke ( messages ) ;
@@ -67,6 +59,7 @@ export class CodestralHandler extends ChatModel {
67
59
type : 'msg'
68
60
} ;
69
61
this . messageAdded ( botMsg ) ;
62
+ this . _history . messages . push ( botMsg ) ;
70
63
return true ;
71
64
}
72
65
You can’t perform that action at this time.
0 commit comments