add: 添加命令ai model list的逻辑

This commit is contained in:
taylor
2024-10-13 18:53:42 +08:00
parent 7e1af58c84
commit dc5162b662
3 changed files with 36 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import json
from typing import List
from aiohttp import ClientSession
from maubot import Plugin
@@ -40,6 +41,14 @@ class Ollama(Platform):
model=response_json['model']
)
async def list_models(self) -> List[str]:
full_url = f"{self.url}/api/tags"
async with self.http.get(full_url) as response:
if response.status != 200:
return []
response_data = json.loads(await response.json())
return [model['name'] for model in response_data]
def get_type(self) -> str:
return "local_ai"