Spaces:
Sleeping
Sleeping
| from openai import OpenAI | |
| import os | |
| client = OpenAI( | |
| base_url="https://api.studio.nebius.ai/v1/", | |
| api_key=os.environ["NEBIUS_API_KEY"] | |
| ) | |
| def steps_from_transcript(txt:str,category:str)->list[str]: | |
| prompt = f""" | |
| Użytkownik oglądał materiał video. | |
| Na podstawie transkrypcji wygeneruj **7 mikro kroków** prowadzących do działania. | |
| Krótko. Zero lania wody. | |
| Kategoriа: {category} | |
| Transkrypcja (fragment): | |
| {txt[:2000]} | |
| """ | |
| out = client.chat.completions.create( | |
| model="moonshotai/Kimi-K2-Instruct", | |
| messages=[{"role":"user","content":prompt}], | |
| max_tokens=450 | |
| ).choices[0].message.content.split("\n") | |
| # czyścimy listę i skracamy do 7 | |
| steps=[s.strip("-• ") for s in out if len(s.strip())>10][:7] | |
| return steps |