Spaces:
Sleeping
Sleeping
from transformers import RobertaTokenizer, T5ForConditionalGeneration | |
def query(user_prompt): | |
tokenizer = RobertaTokenizer.from_pretrained('Salesforce/codet5-base-multi-sum') | |
model = T5ForConditionalGeneration.from_pretrained('Salesforce/codet5-base-multi-sum') | |
prompt=f"""<|system|>\nYou are an intelligent chatbot and an expert in python programming language. | |
Your task is to understand and summarize</s>\n<|user|>\n {user_prompt}\n<|assistant|>""" | |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids | |
generated_ids = model.generate(input_ids, max_length=20) | |
return tokenizer.decode(generated_ids[0], skip_special_tokens=True) | |