Skip to content

Commit

Permalink
🐛 Fixes display prompt (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielluiz authored Oct 5, 2023
2 parents a2e7a91 + 56c2be5 commit 19586c4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
8 changes: 3 additions & 5 deletions src/backend/langflow/services/chat/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,11 @@ async def handle_websocket(self, client_id: str, websocket: WebSocket):

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

Expand Down
14 changes: 8 additions & 6 deletions src/frontend/src/controllers/API/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -50,6 +48,10 @@ function ApiInterceptor() {
if (axios.isAxiosError(error) && error.response?.status === 401) {
logout();
navigate("/login");
} else {
console.error(error);
logout();
navigate("/login");
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/controllers/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/frontend/src/modals/formModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 });
}
}

Expand Down

0 comments on commit 19586c4

Please sign in to comment.