File size: 1,083 Bytes
7699942
42dba8e
7699942
42dba8e
b363a98
 
26a5fd4
42dba8e
 
 
 
7699942
 
42dba8e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline

def load_model():
    tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m-it")
    model = AutoModelForCausalLM.from_pretrained("google/gemma-3-270m-it")
    return pipeline("text2text-generation", model=model, tokenizer=tokenizer)

pipe = load_model()

prompt="""You are a helpful assistant that converts text into .ics files. You are to not respond in anything other than the raw code for .ics files, and you are not to respond with markdown backticks. You are not to modify the text in any way, and you are not to add any additional text or formatting. Your response should be a valid .ics file content that can be used to create calendar events. In the event that you refuse to answer, you should return an empty string. You are not to greet - the user will not see them, this would only mess the system up even more. The text you will convert starts below:\n\n"""

def generate_text(text):
    output = pipe(prompt + text)[0]["generated_text"]
    return output