11import { http } from "../fetch" ;
2-
3- export interface ChatEmotion {
4- emotion : string ;
5- rate : number ;
6- }
7-
8- export interface ChatSummary {
9- emotions : ChatEmotion [ ] ;
10- keywords : string [ ] ;
11- recommendations : string [ ] ;
12- text : string ;
13- title : string ;
14- }
2+ import { EmotionTypes } from "../onboarding/addition" ;
153
164export interface Chat {
175 chat_duration : string ;
@@ -25,6 +13,28 @@ export interface Chat {
2513 user_timezone : string ;
2614}
2715
16+ export interface ChatSummary {
17+ emotions : {
18+ emotion : EmotionTypes ;
19+ rate : 0 ;
20+ } [ ] ;
21+ keywords : string [ ] ;
22+ recommendations : string [ ] ;
23+ text : string ;
24+ title : string ;
25+ main_topic : {
26+ begin_message_id : string ;
27+ end_message_id : string ;
28+ } ;
29+ topic_messages : History [ ] ;
30+ }
31+
32+ export interface ChatSummaryReponse {
33+ success : boolean ;
34+ created : boolean ;
35+ returning : ChatSummary ;
36+ }
37+
2838export interface ListChatsResponse {
2939 chats : Chat [ ] ;
3040}
@@ -34,11 +44,17 @@ export const listChats = async () => {
3444 return response ;
3545} ;
3646
37- export const getChatSummary = async (
47+ export const putChatSummary = async (
3848 session_id : string
3949) : Promise < ChatSummary > => {
40- const { response } = await http . get < Chat > ( `/chats/${ session_id } ` ) ;
41- return response . summary ;
50+ const { response } = await http . put < ChatSummaryReponse > (
51+ `/chats/${ session_id } /summary`
52+ ) ;
53+ if ( response . success ) {
54+ return response . returning ;
55+ } else {
56+ throw new Error ( "Failed to fetch chat summary." ) ;
57+ }
4258} ;
4359
4460export const archiveChat = async ( session_id : string ) : Promise < void > => {
0 commit comments