Skip to content

Commit cc6586d

Browse files
committed
use can update base path only
1 parent fa2b2f8 commit cc6586d

22 files changed

Lines changed: 41 additions & 29 deletions

File tree

react/src/components/Chat/CustomModelForm.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ type CustomModelFormProps = {
1717
onSubmit?: (formData: CustomModelFormValues) => void;
1818
};
1919

20+
function parseBaseURL(baseURL: string) {
21+
const { origin, pathname } = new URL(baseURL || '');
22+
return {
23+
origin: `${origin}/`,
24+
pathname: pathname.replace(/^\//, ''),
25+
};
26+
}
27+
2028
const CustomModelForm: React.FC<CustomModelFormProps> = ({
2129
baseURL,
2230
endpointId,
@@ -27,6 +35,7 @@ const CustomModelForm: React.FC<CustomModelFormProps> = ({
2735
const formRef = useRef<FormInstance>(null);
2836

2937
const [isPendingSubmit, startSubmitTransition] = useTransition();
38+
const { origin, pathname } = parseBaseURL(baseURL || '');
3039

3140
return (
3241
<Flex
@@ -58,18 +67,19 @@ const CustomModelForm: React.FC<CustomModelFormProps> = ({
5867
/>
5968
</div>
6069
<Form.Item
61-
label="Base URL"
62-
name="baseURL"
70+
label="Base Path"
71+
name="basePath"
6372
rules={[
64-
{
65-
type: 'url',
66-
},
6773
{
6874
required: true,
6975
},
7076
]}
7177
>
72-
<Input placeholder="https://domain/v1" />
78+
<Input
79+
placeholder="v1"
80+
addonBefore={origin}
81+
defaultValue={pathname}
82+
/>
7383
</Form.Item>
7484
<Form.Item label="Token" name="token">
7585
<EndpointTokenSelect
@@ -82,8 +92,10 @@ const CustomModelForm: React.FC<CustomModelFormProps> = ({
8292
loading={isPendingSubmit}
8393
onClick={() => {
8494
startSubmitTransition(() => {
95+
const basePath =
96+
formRef.current?.getFieldValue('basePath') ?? 'v1';
8597
onSubmit?.({
86-
baseURL: formRef.current?.getFieldValue('baseURL'),
98+
baseURL: new URL(basePath, origin).href,
8799
token: formRef.current?.getFieldValue('token'),
88100
});
89101
});

resources/i18n/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
"chatui": {
9898
"Attachments": "Anhänge",
99-
"CannotFindModel": "LLM-Modelle können nicht gefunden werden. \nBitte passen Sie das Modell an.",
99+
"CannotFindModel": "LLM-Modelle nicht gefunden. Überprüfen Sie den Pfad und die Token-Kompatibilität mit OpenAI und drücken Sie dann auf \"Modelle aktualisieren\".",
100100
"CompareWithOtherModels": "Vergleichen Sie mit anderen Modellen",
101101
"DeleteChatHistory": "Chat löschen",
102102
"DeleteChattingSession": "Chat löschen",

resources/i18n/el.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
"chatui": {
9898
"Attachments": "Συνημμένα",
99-
"CannotFindModel": "Δεν μπορούν να βρεθούν μοντέλα LLM. \nΠροσαρμόστε το μοντέλο.",
99+
"CannotFindModel": "Τα μοντέλα LLM δεν βρέθηκαν. Επαληθεύστε τη διαδρομή και τη συμβατότητα του κουπονιού με το OpenAI και, στη συνέχεια, πατήστε 'Ανανέωση μοντέλων'.",
100100
"CompareWithOtherModels": "Συγκρίνετε με άλλα μοντέλα",
101101
"DeleteChatHistory": "Καθαρή συνομιλία",
102102
"DeleteChattingSession": "Διαγραφή συνομιλίας",

resources/i18n/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"Okay": "Okay",
8686
"Previous": "Previous",
8787
"PushToImage": "Push session to customized image",
88-
"Refresh": "Refresh",
88+
"Refresh": "Refresh Models",
8989
"Reset": "Reset",
9090
"Save": "Save",
9191
"SaveAndClose": "Save And Close",
@@ -98,7 +98,7 @@
9898
},
9999
"chatui": {
100100
"Attachments": "Attachments",
101-
"CannotFindModel": "LLM models cannot be found. Please customize the model.",
101+
"CannotFindModel": "LLM models not found. Verify the path and token compatibility with OpenAI, then press 'Refresh Models'",
102102
"CompareWithOtherModels": "Compare with other models",
103103
"DeleteChatHistory": "Clear Chat",
104104
"DeleteChattingSession": "Delete Chat",

resources/i18n/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
"chatui": {
9898
"Attachments": "Adjuntos",
99-
"CannotFindModel": "No se pueden encontrar modelos LLM. \nPersonaliza el modelo.",
99+
"CannotFindModel": "Modelos LLM no encontrados. Verifique la compatibilidad de la ruta y el token con OpenAI y, a continuación, pulse \"Actualizar modelos\".",
100100
"CompareWithOtherModels": "Comparar con otros modelos",
101101
"DeleteChatHistory": "Chat claro",
102102
"DeleteChattingSession": "Borrar chat",

resources/i18n/fi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
"chatui": {
9898
"Attachments": "Liitteet",
99-
"CannotFindModel": "LLM-malleja ei löydy. \nMukauta mallia.",
99+
"CannotFindModel": "LLM-malleja ei löydy. Tarkista polku ja tokenin yhteensopivuus OpenAI:n kanssa ja paina sitten 'Päivitä mallit'.",
100100
"CompareWithOtherModels": "Vertaa muihin malleihin",
101101
"DeleteChatHistory": "Selkeä keskustelu",
102102
"DeleteChattingSession": "Poista keskustelu",

resources/i18n/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
"chatui": {
9898
"Attachments": "Pièces jointes",
99-
"CannotFindModel": "Les modèles LLM sont introuvables. \nVeuillez personnaliser le modèle.",
99+
"CannotFindModel": "Les modèles LLM ne sont pas trouvés. Vérifiez la compatibilité du chemin et du jeton avec OpenAI, puis cliquez sur \"Rafraîchir les modèles\".",
100100
"CompareWithOtherModels": "Comparez avec d'autres modèles",
101101
"DeleteChatHistory": "Chat clair",
102102
"DeleteChattingSession": "Supprimer le chat",

resources/i18n/id.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
},
9696
"chatui": {
9797
"Attachments": "Lampiran",
98-
"CannotFindModel": "Model LLM tidak dapat ditemukan. \nSilakan sesuaikan modelnya.",
98+
"CannotFindModel": "Model LLM tidak ditemukan. Verifikasi kompatibilitas jalur dan token dengan OpenAI, lalu tekan 'Refresh Models'",
9999
"CompareWithOtherModels": "Bandingkan dengan model lain",
100100
"DeleteChatHistory": "Hapus Obrolan",
101101
"DeleteChattingSession": "Menghapus Obrolan",

resources/i18n/it.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
},
9696
"chatui": {
9797
"Attachments": "Allegati",
98-
"CannotFindModel": "Impossibile trovare i modelli LLM. \nSi prega di personalizzare il modello.",
98+
"CannotFindModel": "Modelli LLM non trovati. Verificare il percorso e la compatibilità del token con OpenAI, quindi premere 'Aggiorna modelli'.",
9999
"CompareWithOtherModels": "Confronta con altri modelli",
100100
"DeleteChatHistory": "Chat chiara",
101101
"DeleteChattingSession": "Cancellare la chat",

resources/i18n/ja.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
},
9696
"chatui": {
9797
"Attachments": "添付ファイル",
98-
"CannotFindModel": "LLM モデルが見つかりません。\nモデルをカスタマイズしてください",
98+
"CannotFindModel": "LLM モデルが見つかりません。OpenAI とのパスとトークンの互換性を確認し、'Refresh Models' を押してください",
9999
"CompareWithOtherModels": "他モデルとの比較",
100100
"DeleteChatHistory": "クリア・チャット",
101101
"DeleteChattingSession": "チャット削除",

0 commit comments

Comments
 (0)