Implement interaction in oasst_api

This commit is contained in:
klotske
2023-01-05 23:27:44 +03:00
parent 739c073328
commit a4e8d829b1
2 changed files with 27 additions and 22 deletions
+23
View File
@@ -61,4 +61,27 @@ export default class OasstApiClient {
message_id: messageId,
});
}
// TODO return a strongly typed Task?
// This method is used to record interaction with task while fetching next task.
// This is a raw Json type, so we can't use it to strongly type the task.
async interactTask(
updateType: string,
messageId: string,
userMessageId: string,
content: object,
userToken: JWT
): Promise<any> {
return this.post("/api/v1/tasks/interaction", {
type: updateType,
user: {
id: userToken.sub,
display_name: userToken.name || userToken.email,
auth_method: "local",
},
message_id: messageId,
user_message_id: userMessageId,
...content,
});
}
}