mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-25 04:01:52 +03:00
ffb4b0d162
* Improve download of generated images, serve images in the api Add support for conversation handling in the api * Add orginal prompt to image response * Add download images option in gui, fix loading model list in Airforce * Add download images option in gui, fix loading model list in Airforce
33 lines
1021 B
Python
33 lines
1021 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
from .stubs import ChatCompletion, ChatCompletionChunk
|
|
from ..providers.types import BaseProvider
|
|
from typing import Union, Iterator, AsyncIterator
|
|
|
|
ImageProvider = Union[BaseProvider, object]
|
|
Proxies = Union[dict, str]
|
|
IterResponse = Iterator[Union[ChatCompletion, ChatCompletionChunk]]
|
|
AsyncIterResponse = AsyncIterator[Union[ChatCompletion, ChatCompletionChunk]]
|
|
|
|
class Client():
|
|
def __init__(
|
|
self,
|
|
api_key: str = None,
|
|
proxies: Proxies = None,
|
|
**kwargs
|
|
) -> None:
|
|
self.api_key: str = api_key
|
|
self.proxies= proxies
|
|
self.proxy: str = self.get_proxy()
|
|
|
|
def get_proxy(self) -> Union[str, None]:
|
|
if isinstance(self.proxies, str):
|
|
return self.proxies
|
|
elif self.proxies is None:
|
|
return os.environ.get("G4F_PROXY")
|
|
elif "all" in self.proxies:
|
|
return self.proxies["all"]
|
|
elif "https" in self.proxies:
|
|
return self.proxies["https"] |