import gradio as gr import requests import os # from dotenv import load_dotenv # load_dotenv() API_URL = os.getenv("API_URL") AUTH_TOKEN = os.getenv("AUTH_TOKEN") headers = {"Authorization": f"Bearer {AUTH_TOKEN}"} def postproccess(responce): try: return ' '.join(x['entity_group'] for x in responce) except Exception as ex: print(list(responce.items())) print(f"Exception: {ex}") # return f"Exception: {ex}" return query(inp.value) def query(request): response = requests.post(API_URL, headers=headers, json=request) return postproccess(response.json()) with gr.Blocks() as demo: gr.Markdown( """ # Модель для определения скелетной структуры текста Это веб-приожение демонстрирует работу модели. - [Модель](https://huggingface.co./disk0dancer/ruBert-base-finetuned-pos) - [Проект](https://huggingface.co./spaces/disk0dancer/demo-rubert-base-finetuned-pos) - [Код и Документация](https://github.com/disk0Dancer/rubert-finetuned-pos) """) inp = gr.Textbox(placeholder="Введите текст на русском языке...", label="input") out = gr.Textbox(label="output") inp.change(query, inp, out) with open('tags.txt', 'r') as f: gr.Markdown(f.read()) if __name__ == "__main__": demo.launch()