Skip to content

Commit a640bed

Browse files
authored
Update website for new routes (#2704)
1 parent e8510c3 commit a640bed

6 files changed

Lines changed: 16 additions & 14 deletions

File tree

website/src/components/Chat/ChatListItem.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export const ChatListItem = ({
3333
},
3434
});
3535
const { trigger: updateChatTitle, isMutating: isUpdatingTitle } = useSWRMutation(
36-
API_ROUTES.UPDATE_CHAT_TITLE(chat.id),
36+
API_ROUTES.UPDATE_CHAT(chat.id),
3737
put
3838
);
3939
const handleConfirmEdit = useCallback(async () => {
4040
const title = inputRef.current?.value.trim();
4141
if (!title) return;
42-
await updateChatTitle({ title, chat_id: chat.id });
42+
await updateChatTitle({ chat_id: chat.id, title });
4343
setIsEditing.off();
4444
onUpdateTitle({ chatId: chat.id, title });
4545
}, [chat.id, onUpdateTitle, setIsEditing, updateChatTitle]);
@@ -145,10 +145,10 @@ const EditChatButton = ({ onClick }: { onClick: () => void }) => {
145145
};
146146

147147
const HideChatButton = ({ chatId, onHide }: { chatId: string; onHide?: (params: { chatId: string }) => void }) => {
148-
const { trigger: triggerHide } = useSWRMutation(API_ROUTES.HIDE_CHAT(chatId), put);
148+
const { trigger: triggerHide } = useSWRMutation(API_ROUTES.UPDATE_CHAT(chatId), put);
149149

150150
const onClick = useCallback(async () => {
151-
await triggerHide({ chat_id: chatId });
151+
await triggerHide({ chat_id: chatId, hidden: true });
152152
onHide?.({ chatId });
153153
}, [onHide, triggerHide, chatId]);
154154

website/src/lib/oasst_inference_client.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
InferenceMessage,
77
InferencePostAssistantMessageParams,
88
InferencePostPrompterMessageParams,
9+
InferenceUpdateChatParams,
910
ModelInfo,
1011
TrustedClient,
1112
} from "src/types/Chat";
@@ -96,12 +97,8 @@ export class OasstInferenceClient {
9697
return this.request<ModelInfo[]>("/configs/model_configs");
9798
}
9899

99-
update_chat_title({ chat_id, title }: { chat_id: string; title: string }) {
100-
return this.request(`/chats/${chat_id}/title`, { method: "PUT", data: { title } });
101-
}
102-
103-
hide_chat({ chat_id }: { chat_id: string }) {
104-
return this.request(`/chats/${chat_id}/hide`, { method: "PUT", data: { hidden: true } });
100+
update_chat({ chat_id, ...data }: InferenceUpdateChatParams) {
101+
return this.request(`/chats/${chat_id}`, { method: "PUT", data: data });
105102
}
106103

107104
delete_account() {

website/src/lib/routes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,5 @@ export const API_ROUTES = {
6060
STREAM_CHAT_MESSAGE: (chat_id: string, message_id: string) =>
6161
createRoute(`/api/chat/events`, { chat_id, message_id }),
6262
GET_CHAT_MODELS: "/api/chat/models",
63-
UPDATE_CHAT_TITLE: (id: string) => `/api/chat/title`,
64-
HIDE_CHAT: (id: string) => `/api/chat/hide`,
63+
UPDATE_CHAT: (id: string) => `/api/chat`,
6564
};

website/src/pages/api/chat/hide.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const handler = withoutRole("banned", async (req, res, token) => {
99
const client = createInferenceClient(token);
1010
const { chat_id } = req.body as { chat_id: string };
1111

12-
await client.hide_chat({ chat_id });
12+
await client.update_chat({ chat_id, hidden: true });
1313

1414
res.status(200).end();
1515
});

website/src/pages/api/chat/title.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const handler = withoutRole("banned", async (req, res, token) => {
99
const client = createInferenceClient(token);
1010
const { chat_id, title } = req.body as { chat_id: string; title: string };
1111

12-
await client.update_chat_title({ chat_id, title });
12+
await client.update_chat({ chat_id, title });
1313

1414
res.status(200).end();
1515
});

website/src/types/Chat.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,9 @@ export interface InferencePostAssistantMessageParams {
115115
model_config_name: string;
116116
sampling_parameters: SamplingParameters;
117117
}
118+
119+
export interface InferenceUpdateChatParams {
120+
chat_id: string;
121+
title?: string;
122+
hidden?: boolean;
123+
}

0 commit comments

Comments
 (0)