Spaces:
Build error
Build error
| import os | |
| import json | |
| import gradio as gr | |
| from groq import Groq | |
| client = Groq(api_key=os.environ.get("GROQ_API_KEY")) | |
| def summarize_process(text: str): | |
| """ | |
| summarizes provided description of the proccess in Russian | |
| text: provided source | |
| """ | |
| summarization_prompt = """ | |
| Summarize the provided text in Russian. Use Russian language only. | |
| Extract the main process and briefly summarize it. | |
| Include key steps, participants and final result in summary. | |
| Add those who are responsible for the whole process. | |
| Return the summarized text in Russian only without any comments and explanations. | |
| Return valid JSON with the following schema: | |
| { | |
| "summary": "string (generated summary of the provided source)" | |
| } | |
| Text for summarization:\n\n | |
| """ | |
| summary = client.chat.completions.create(messages=[{"role": "user", | |
| "content": summarization_prompt + text}], | |
| model= "deepseek-r1-distill-llama-70b", | |
| response_format={"type": "json_object"}, | |
| stream=False, | |
| max_tokens=1024, | |
| temperature=0.5, | |
| top_p=0.1 | |
| ).choices[0].message.content | |
| return json.loads(summary)["summary"] | |
| summary_bot = gr.Interface(fn=summarize_process, | |
| inputs=gr.Textbox(lines=2, placeholder="Ваш текст..."), | |
| outputs="text", | |
| title="Summary", | |
| description="Вставьте сюда описание процесса, и я перескажу его!" | |
| ) | |
| if __name__ == "__main__": | |
| summary_bot.launch() |