From fe14cb84e6bc33b1e76e5279786700354999c111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:37:38 +0800 Subject: [PATCH] fix: models fetch --- lib/data/res/openai.dart | 7 ++++--- lib/view/page/settings/profile.dart | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/data/res/openai.dart b/lib/data/res/openai.dart index c2247be..42819b3 100644 --- a/lib/data/res/openai.dart +++ b/lib/data/res/openai.dart @@ -182,12 +182,13 @@ abstract final class _ModelsCacher { if (models_ != null) return models_; } - final uri = Uri.parse(Cfg.current.url); - final endpoint = '${uri.scheme}://${uri.host}'; + final endpoint = Cfg.current.url; // For most compatibility, use dio instead of openai_dart final url = switch (endpoint) { - _ when endpoint.startsWith('https://api.deepseek.com/beta') => + _ when endpoint.startsWith('https://api.deepseek.com') => 'https://api.deepseek.com/v1/models', + _ when endpoint.startsWith('https://models.inference.ai.azure.com') => + 'https://models.inference.ai.azure.com/models', _ => '$endpoint/models', }; final val = await myDio.get( diff --git a/lib/view/page/settings/profile.dart b/lib/view/page/settings/profile.dart index ba51c0e..98cfc2a 100644 --- a/lib/view/page/settings/profile.dart +++ b/lib/view/page/settings/profile.dart @@ -178,7 +178,7 @@ final class _ProfilePageState extends State ); if (ok != true) return; final clipboardData = await Pfs.paste(); - var (key, url) = ('', ''); + var (key, url) = ('', ChatConfig.defaultUrl); if (clipboardData != null) { if (clipboardData.startsWith('https://')) { url = clipboardData;