Skip to content

Commit

Permalink
feat: 增加一个chatglm模型
Browse files Browse the repository at this point in the history
  • Loading branch information
brzhang666 committed May 4, 2023
1 parent efba123 commit 79726c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/data/glm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ChatGlM extends LLM {
ValueChanged<Message> onResponse,
ValueChanged<Message> errorCallback,
ValueChanged<Message> onSuccess) async {
var prompt = messages.removeLast().text;
var messageToBeSend = messages.removeLast();
var prompt = messageToBeSend.text;
var history = messages.length >= 2 ? collectHistory(messages) : [];
var body = {'prompt': prompt, 'history': history.isEmpty ? [] : history};
final response = await http.post(
Expand All @@ -29,13 +30,13 @@ class ChatGlM extends LLM {
// ));
onSuccess(Message(
text: jsonObj['response'],
conversationId: messages.last.conversationId,
conversationId: messageToBeSend.conversationId,
role: Role.assistant,
));
} else {
errorCallback(Message(
text: "request glm error,Please try again later",
conversationId: messages.last.conversationId,
conversationId: messageToBeSend.conversationId,
role: Role.assistant,
));
}
Expand Down

0 comments on commit 79726c8

Please sign in to comment.