From b7dd0ff3475c42162b60b5cbec1446a040bac3b6 Mon Sep 17 00:00:00 2001 From: taylor <=> Date: Mon, 14 Oct 2024 14:24:04 +0800 Subject: [PATCH] =?UTF-8?q?add:=20openai=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=89=80=E6=9C=89=E6=A8=A1=E5=9E=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maubot_llmplus/thrid_platform.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/maubot_llmplus/thrid_platform.py b/maubot_llmplus/thrid_platform.py index 2003b5c..f3c5999 100644 --- a/maubot_llmplus/thrid_platform.py +++ b/maubot_llmplus/thrid_platform.py @@ -58,6 +58,16 @@ class OpenAi(Platform): model=choice.get("model", None) ) + async def list_models(self) -> List[str]: + # 调用openai接口获取模型列表 + full_url = f"{self.url}/v1/models" + headers = {'Authorization': self.api_key} + async with self.http.get(full_url, headers=headers) as response: + if response.status != 200: + return [] + response_data = await response.json() + return [m["id"] for m in response_data["data"]] + def get_type(self) -> str: return "openai"