mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
* 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
26 lines
No EOL
649 B
Python
26 lines
No EOL
649 B
Python
from __future__ import annotations
|
|
|
|
from abc import abstractmethod
|
|
|
|
class ResponseType:
|
|
@abstractmethod
|
|
def __str__(self) -> str:
|
|
pass
|
|
|
|
class FinishReason():
|
|
def __init__(self, reason: str):
|
|
self.reason = reason
|
|
|
|
def __str__(self) -> str:
|
|
return ""
|
|
|
|
class Sources(ResponseType):
|
|
def __init__(self, sources: list[dict[str, str]]) -> None:
|
|
self.list = sources
|
|
|
|
def __str__(self) -> str:
|
|
return "\n\n" + ("\n".join([f"{idx+1}. [{link['title']}]({link['url']})" for idx, link in enumerate(self.list)]))
|
|
|
|
class BaseConversation(ResponseType):
|
|
def __str__(self) -> str:
|
|
return "" |