🐛 Fixes display prompt (#1015)

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-10-05 18:20:51 -03:00 committed by GitHub
commit 19586c4ec6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 22 deletions

View file

@ -202,13 +202,11 @@ class ChatService(Service):
while True:
json_payload = await websocket.receive_json()
try:
if isinstance(json_payload, str):
payload = orjson.loads(json_payload)
# except TypeError or JSONDecodeError how?
except Exception as exc:
logger.error(f"Error decoding JSON: {exc}")
elif isinstance(json_payload, dict):
payload = json_payload
if "clear_history" in payload:
if "clear_history" in payload and payload["clear_history"]:
self.chat_history.history[client_id] = []
continue

View file

@ -31,13 +31,11 @@ function ApiInterceptor() {
logout();
navigate("/login");
}
const res = await renewAccessToken(refreshToken);
if (res?.data?.access_token && res?.data?.refresh_token) {
login(res?.data?.access_token, res?.data?.refresh_token);
}
try {
const res = await renewAccessToken(refreshToken);
if (res?.data?.access_token && res?.data?.refresh_token) {
login(res?.data?.access_token, res?.data?.refresh_token);
}
if (error?.config?.headers) {
delete error.config.headers["Authorization"];
error.config.headers["Authorization"] = `Bearer ${cookies.get(
@ -50,6 +48,10 @@ function ApiInterceptor() {
if (axios.isAxiosError(error) && error.response?.status === 401) {
logout();
navigate("/login");
} else {
console.error(error);
logout();
navigate("/login");
}
}
}

View file

@ -399,7 +399,6 @@ export async function renewAccessToken(token: string) {
return await api.post(`${BASE_URL_API}refresh?token=${token}`);
}
} catch (error) {
console.log("Error:", error);
throw error;
}
}

View file

@ -261,7 +261,11 @@ export default function FormModal({
}
if (data.type === "end") {
if (data.message) {
updateLastMessage({ str: data.message, end: true });
updateLastMessage({
str: data.message,
end: true,
prompt: template.current,
});
}
if (data.intermediate_steps) {
updateLastMessage({
@ -276,19 +280,14 @@ export default function FormModal({
files: data.files,
});
}
if (data.type === "prompt" && data.prompt) {
template.current = data.prompt;
}
setLockChat(false);
isStream = false;
}
if (data.type == "prompt" && data.prompt) {
template.current = data.prompt;
}
if (data.type === "stream" && isStream) {
if (data.prompt) {
updateLastMessage({ prompt: data.prompt });
} else {
updateLastMessage({ str: data.message });
}
updateLastMessage({ str: data.message });
}
}