XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Ollama load api_key

b851fc36
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +3 -0
Modified g4f/Provider/local/Ollama.py +3 -0
@@ -7,6 +7,7 @@ import os
7 7 from ..needs_auth.OpenaiAPI import OpenaiAPI
8 8 from ...requests import StreamSession, raise_for_status
9 9 from ...providers.response import Usage, Reasoning
10 from ...tools.run_tools import AuthManager
10 11 from ...typing import AsyncResult, Messages
11 12
12 13 class Ollama(OpenaiAPI):
@@ -27,6 +28,8 @@ class Ollama(OpenaiAPI):
27 28 def get_models(cls, api_key: str = None, api_base: str = None, **kwargs):
28 29 if not cls.models:
29 30 cls.models = []
31 if not api_key:
32 api_key = AuthManager.load_api_key(cls)
30 33 if api_key:
31 34 models = requests.get("https://ollama.com/api/tags", {"headers": {"Authorization": f"Bearer {api_key}"}}).json()["models"]
32 35 cls.models = [model["name"] for model in models]