mirror of https://github.com/xtekky/gpt4free
Compare commits
4 Commits
b703948969
...
1d02a06456
Author | SHA1 | Date |
---|---|---|
H Lohaus | 1d02a06456 | 2 weeks ago |
H Lohaus | 9dcc9b9bcb | 2 weeks ago |
Heiner Lohaus | 8fcf618bbe | 2 weeks ago |
Hydra566 | d495d732f2 | 2 weeks ago |
@ -0,0 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import requests
|
||||
|
||||
from .needs_auth.Openai import Openai
|
||||
from ..typing import AsyncResult, Messages
|
||||
|
||||
class Ollama(Openai):
|
||||
label = "Ollama"
|
||||
url = "https://ollama.com"
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
@classmethod
|
||||
def get_models(cls):
|
||||
if not cls.models:
|
||||
url = 'http://127.0.0.1:11434/api/tags'
|
||||
models = requests.get(url).json()["models"]
|
||||
cls.models = [model['name'] for model in models]
|
||||
cls.default_model = cls.models[0]
|
||||
return cls.models
|
||||
|
||||
@classmethod
|
||||
def create_async_generator(
|
||||
cls,
|
||||
model: str,
|
||||
messages: Messages,
|
||||
api_base: str = "http://localhost:11434/v1",
|
||||
**kwargs
|
||||
) -> AsyncResult:
|
||||
return super().create_async_generator(
|
||||
model, messages, api_base=api_base, **kwargs
|
||||
)
|
Loading…
Reference in New Issue