From ffb4b0d162cc29b1caa4539d854de37206804225 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Wed, 20 Nov 2024 19:58:16 +0100 Subject: Improve download of generated images, serve images in the api (#2391) * 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 --- g4f/providers/response.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 g4f/providers/response.py (limited to 'g4f/providers/response.py') diff --git a/g4f/providers/response.py b/g4f/providers/response.py new file mode 100644 index 00000000..a4d1467a --- /dev/null +++ b/g4f/providers/response.py @@ -0,0 +1,26 @@ +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 "" \ No newline at end of file -- cgit v1.2.3