Spaces:
Runtime error
Runtime error
import requests | |
import time | |
from transformers import pipeline | |
import os | |
HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN') | |
headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"} | |
def query(text, url, params=None): | |
data = {"inputs": text, "parameters": params} | |
while True: | |
response = requests.post(url, headers=headers, json=data) | |
if 'error' not in response.json(): | |
output = response.json()[0]["generated_text"] | |
return output | |
else: | |
print(response.json()) | |
time.sleep(15) | |
print('Sending request again', flush=True) | |
def pipe(): | |
pipe = pipeline("text2text-generation", model="boun-tabi-LMG/TURNA", tokenizer="boun-tabi-LMG/TURNA", temperature=0.7, repetition_penalty=0.5, top_p=0.9) |