Skip to content

Commit

Permalink
default serviceType to "docker" + rename chatId to historyId (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janaka-Steph authored Nov 15, 2023
1 parent 9ccda26 commit 9e56b96
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/modules/prem-chat/components/PremChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function PremChat() {
<PremChatContainer
historyId={historyId}
serviceName={service?.name ?? ""}
serviceId={serviceId!}
serviceType={serviceType!}
serviceId={serviceId ?? ""}
serviceType={serviceType ?? "docker"}
isPetals={service?.petals ?? false}
/>
);
Expand Down
12 changes: 6 additions & 6 deletions src/modules/service/components/ServiceActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ const ServiceActions = ({
const isPlayground = interfaces.some((app) => app.playground);
if (isPlayground) {
if (interfaces.some((app) => app.id === CHAT_ID)) {
navigate(`/prem-chat/${service.id}/${service.serviceType}`);
navigate(`/prem-chat/${service.id}/${service.serviceType ?? "docker"}`);
} else if (interfaces.some((app) => app.id === DIFFUSER_ID)) {
navigate(`/prem-image/${service.id}/${service.serviceType}`);
navigate(`/prem-image/${service.id}/${service.serviceType ?? "docker"}`);
} else if (interfaces.some((app) => app.id === AUDIO_TO_TEXT_ID)) {
navigate(`/prem-audio/${service.id}/${service.serviceType}`);
navigate(`/prem-audio/${service.id}/${service.serviceType ?? "docker"}`);
} else if (interfaces.some((app) => app.id === TEXT_TO_AUDIO_ID)) {
navigate(`/prem-text-audio/${service.id}/${service.serviceType}`);
navigate(`/prem-text-audio/${service.id}/${service.serviceType ?? "docker"}`);
} else if (interfaces.some((app) => app.id === UPSCALER_ID)) {
navigate(`/prem-upscaler/${service.id}/${service.serviceType}`);
navigate(`/prem-upscaler/${service.id}/${service.serviceType ?? "docker"}`);
} else if (interfaces.some((app) => app.id === CODER_ID)) {
navigate(`/prem-coder/${service.id}/${service.serviceType}`);
navigate(`/prem-coder/${service.id}/${service.serviceType ?? "docker"}`);
}
return;
}
Expand Down
18 changes: 9 additions & 9 deletions src/shared/hooks/usePremChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import useGetService from "./useGetService";
const usePremChatStream = (
serviceId: string,
serviceType: Service["serviceType"],
chatId: string | null,
historyId: string | null,
): PremChatResponse => {
const [question, setQuestion] = useState("");
const [tempQuestion, setTempQuestion] = useState("");
Expand Down Expand Up @@ -67,7 +67,7 @@ const usePremChatStream = (
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [service]);

const messages = history.find((_history) => _history.id === chatId)?.messages || [];
const messages = history.find((_history) => _history.id === historyId)?.messages || [];

const onSubmit = useCallback(
(e: React.FormEvent) => {
Expand Down Expand Up @@ -143,8 +143,8 @@ const usePremChatStream = (
const onRegenerate = useCallback(() => {
const newMessages = [...messages];
const lastConversation = newMessages.splice(-2);
if (chatId) {
updateHistoryMessages(chatId, newMessages);
if (historyId) {
updateHistoryMessages(historyId, newMessages);
processQuestion(lastConversation[0].content);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -162,18 +162,18 @@ const usePremChatStream = (
if (!isLoading && pending) {
setTempQuestion("");
setPending(undefined);
if (!chatId) {
const newChatId = uuid();
if (!historyId) {
const newHistoryId = uuid();
addHistory({
id: newChatId,
id: newHistoryId,
model: serviceId,
title: tempConversation[0].content,
messages: [...tempConversation],
timestamp: Date.now(),
});
navigate(`/prem-chat/${serviceId}/${serviceType}/${newChatId}`);
navigate(`/prem-chat/${serviceId}/${serviceType}/${newHistoryId}`);
} else {
updateHistoryMessages(chatId, [...messages, ...tempConversation]);
updateHistoryMessages(historyId, [...messages, ...tempConversation]);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 9e56b96

Please sign in to comment.