From 0760db03f81eb794cbcea84b1da27f7d970cbf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Thu, 6 Jul 2023 16:15:41 +0200 Subject: [PATCH 1/8] Perf: Retry for a long time, and also when throttling --- src/conversation-ui/src/Utils.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conversation-ui/src/Utils.jsx b/src/conversation-ui/src/Utils.jsx index ad9ef4d2..943ec94d 100644 --- a/src/conversation-ui/src/Utils.jsx +++ b/src/conversation-ui/src/Utils.jsx @@ -7,10 +7,12 @@ const client = axios.create({ baseURL: 'http://127.0.0.1:8081', }); axiosRetry(client, { - retries: 3, - retryCondition: axiosRetry.isNetworkOrIdempotentRequestError, + retries: 12, retryDelay: axiosRetry.exponentialDelay, shouldResetTimeout: true, + retryCondition: (error) => { + return axiosRetry.isNetworkOrIdempotentRequestError(error) || error.response.status == 429; + } }); const header = (enabled) => { From 9568fccf3d8a689db86cbf197f66b1001d9096cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Thu, 6 Jul 2023 16:15:55 +0200 Subject: [PATCH 2/8] Quality: Ignore ViteJS tmp file --- src/conversation-ui/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/conversation-ui/.gitignore b/src/conversation-ui/.gitignore index 3d3bb879..5c78e512 100644 --- a/src/conversation-ui/.gitignore +++ b/src/conversation-ui/.gitignore @@ -1,3 +1,6 @@ +# Vite.js +.vite/ + # Created by https://www.toptal.com/developers/gitignore/api/node,yarn,react,venv # Edit at https://www.toptal.com/developers/gitignore?templates=node,yarn,react,venv From 3ba03f01108a9d5d63d2dede02833fdba39bcd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Thu, 6 Jul 2023 16:40:14 +0200 Subject: [PATCH 3/8] Perf: Rate-limit API by auth header Allows to not throttle users using the same IP with different accounts. --- .../private-gpt/templates/conversation-api-ingress.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cicd/helm/private-gpt/templates/conversation-api-ingress.yaml b/cicd/helm/private-gpt/templates/conversation-api-ingress.yaml index 379aa95c..d1b48a98 100644 --- a/cicd/helm/private-gpt/templates/conversation-api-ingress.yaml +++ b/cicd/helm/private-gpt/templates/conversation-api-ingress.yaml @@ -17,7 +17,7 @@ spec: middlewares: - name: {{ include "private-gpt.fullname" . }}-conversation-api-prefix - name: {{ include "private-gpt.fullname" . }}-conversation-api-security - - name: {{ include "private-gpt.fullname" . }}-conversation-api-ratelimit + - name: {{ include "private-gpt.fullname" . }}-conversation-api-ratelimit-auth - name: {{ include "private-gpt.fullname" . }}-conversation-api-compress tls: {{- toYaml .Values.ingress.tls | nindent 4 }} @@ -49,7 +49,7 @@ spec: apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: - name: {{ include "private-gpt.fullname" . }}-conversation-api-ratelimit + name: {{ include "private-gpt.fullname" . }}-conversation-api-ratelimit-auth labels: {{- include "private-gpt.labels" . | nindent 4 }} app.kubernetes.io/component: conversation-api @@ -57,6 +57,9 @@ spec: rateLimit: average: 1 burst: 5 + period: 1s + sourceCriterion: + requestHeaderName: Authorization --- apiVersion: traefik.containo.us/v1alpha1 kind: Middleware From ef8697a6896e1f735efb7789b95de7a0cd8f150c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Thu, 6 Jul 2023 16:55:09 +0200 Subject: [PATCH 4/8] Feat: Make header title clickable --- src/conversation-ui/src/Header.jsx | 6 ++++-- src/conversation-ui/src/main.scss | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/conversation-ui/src/Header.jsx b/src/conversation-ui/src/Header.jsx index 3445a5e0..fe73164a 100644 --- a/src/conversation-ui/src/Header.jsx +++ b/src/conversation-ui/src/Header.jsx @@ -3,7 +3,7 @@ import { header } from "./Utils"; import { ThemeContext, ConversationContext } from "./App"; import { useAuth } from "oidc-react"; import { useContext } from "react"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, Link } from "react-router-dom"; import Button from "./Button"; import Conversations from "./Conversations"; @@ -18,7 +18,9 @@ function Header() { return (
-

🔒 Private GPT

+ +

🔒 Private GPT

+