mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-26 09:57:24 +03:00
Improve compatibility of openai-node (#1966)
* improve compatibility of openai-node * improve compatibility with OpenAI's models api * allow image upload
This commit is contained in:
parent
0332c0c0dd
commit
1d66c57a65
@ -120,7 +120,10 @@ class Api:
|
|||||||
'created': 0,
|
'created': 0,
|
||||||
'owned_by': model.base_provider
|
'owned_by': model.base_provider
|
||||||
} for model_id, model in model_list.items()]
|
} for model_id, model in model_list.items()]
|
||||||
return JSONResponse(model_list)
|
return JSONResponse({
|
||||||
|
"object": "list",
|
||||||
|
"data": model_list,
|
||||||
|
})
|
||||||
|
|
||||||
@self.app.get("/v1/models/{model_name}")
|
@self.app.get("/v1/models/{model_name}")
|
||||||
async def model_info(model_name: str):
|
async def model_info(model_name: str):
|
||||||
|
@ -78,12 +78,14 @@ class ChatCompletionDelta(Model):
|
|||||||
def __init__(self, content: Union[str, None]):
|
def __init__(self, content: Union[str, None]):
|
||||||
if content is not None:
|
if content is not None:
|
||||||
self.content = content
|
self.content = content
|
||||||
|
self.role = "assistant"
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return self.__dict__
|
return self.__dict__
|
||||||
|
|
||||||
class ChatCompletionDeltaChoice(Model):
|
class ChatCompletionDeltaChoice(Model):
|
||||||
def __init__(self, delta: ChatCompletionDelta, finish_reason: Union[str, None]):
|
def __init__(self, delta: ChatCompletionDelta, finish_reason: Union[str, None]):
|
||||||
|
self.index = 0
|
||||||
self.delta = delta
|
self.delta = delta
|
||||||
self.finish_reason = finish_reason
|
self.finish_reason = finish_reason
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ else:
|
|||||||
SHA256 = NewType('sha_256_hash', str)
|
SHA256 = NewType('sha_256_hash', str)
|
||||||
CreateResult = Iterator[str]
|
CreateResult = Iterator[str]
|
||||||
AsyncResult = AsyncIterator[str]
|
AsyncResult = AsyncIterator[str]
|
||||||
Messages = List[Dict[str, str]]
|
Messages = List[Dict[str, Union[str,List[Dict[str,Union[str,Dict[str,str]]]]]]]
|
||||||
Cookies = Dict[str, str]
|
Cookies = Dict[str, str]
|
||||||
ImageType = Union[str, bytes, IO, Image, None]
|
ImageType = Union[str, bytes, IO, Image, None]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user