Spaces:
Sleeping
Sleeping
import gradio as gr | |
#from huggingface_hub import InferenceClient | |
import openai | |
from markdown import markdown | |
from markdownify import markdownify | |
openai.base_url = "https://text.pollinations.ai/openai" | |
openai.api_key = "aaa" | |
""" | |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference | |
""" | |
#client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") | |
def respond( | |
message, | |
history: list[tuple[str, str]] | |
): | |
system_message = """Привет! Ты должен рисовать и править рисунки по запросу пользователя. Для генерации ты должен написать промпт на английском для ИИ который будет генерировать картинку. Чтобы отобразить картинку в сообщении в месте где должна быть картинка напиши ![](https://image.pollinations.ai/prompt/{prompt}) где {prompt} Твой промпт. ГОВОРИ ПО-АНГЛИЙСКИ!""" | |
messages = [{"role": "system", "content": system_message}] | |
for val in history: | |
if val[0]: | |
messages.append({"role": "user", "content": val[0]}) | |
if val[1]: | |
messages.append({"role": "assistant", "content": markdownify(val[1])}) | |
messages.append({"role": "user", "content": message}) | |
response = "" | |
response = openai.chat.completions.create(messages=messages, model="openai").choices[0].message.content | |
return markdown(response) | |
""" | |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface | |
""" | |
with gr.Blocks() as demo: | |
gr.Markdown("# Painter") | |
gr.Markdown("⚠️WARNING⚠️: The picture will not be displayed immediately. It will be displayed when generated. DO NOT TELL ME THAT THERE IS NO PICTURE!!! Thank you for your attention.") | |
gr.ChatInterface( | |
respond | |
) | |
gr.Markdown("[Gallery](https://huggingface.co/spaces/Arigadam/paint/discussions?status=open&type=discussion)\n\n in the gallery, photos are all that have in the title [PHOTO].") | |
gr.HTML("<small>Made by Arigadam</small>") | |
if __name__ == "__main__": | |
demo.launch(show_api=False) | |