Spaces:
Sleeping
Sleeping
Update app.py
Browse files24 unmodified lines2526272829303132333435363738394041424324 unmodified linesreturn PlainTextResponse("Пустое сообщение")try:prompt = f"Answer the question: {message}"inputs = tokenizer(prompt, return_tensors="pt")with torch.no_grad():outputs = model.generate(**inputs,max_new_tokens=80)reply = tokenizer.decode(outputs[0], skip_special_tokens=True)return PlainTextResponse(reply)except Exception as e:return PlainTextResponse(f"ERROR: {str(e)}")24 unmodified lines25262728293031323334353637383940414243444524 unmodified linesreturn PlainTextResponse("Пустое сообщение")try:prompt = f"You are a friendly AI assistant.\nUser: {message}\nAssistant:"inputs = tokenizer(prompt, return_tensors="pt")with torch.no_grad():outputs = model.generate(**inputs,max_new_tokens=60,temperature=0.7)reply = tokenizer.decode(outputs[0], skip_special_tokens=True)# Убираем часть промпта из ответаreply = reply.split("Assistant:")[-1].strip()except Exception as e:return PlainTextResponse(f"ERROR: {str(e)}")
app.py+11-9