|
import os |
|
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer |
|
from transformers import pipeline |
|
model_name = "dbernsohn/roberta-java" |
|
model = AutoModelForSeq2SeqLM.from_pretrained(model_name) |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
def preprocess_input(description): |
|
input_text = "Generate an agent that " + description |
|
inputs = tokenizer.encode(input_text, return_tensors='pt') |
|
return inputs |
|
def generate_agent_code(inputs): |
|
generated_ids = model.generate(inputs) |
|
agent_code = tokenizer.decode(generated_ids[0], skip_special_tokens=True) |
|
return agent_code |
|
import os |
|
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer |
|
from transformers import pipeline |
|
|
|
|
|
model_name = "dbernsohn/roberta-java" |
|
model = AutoModelForSeq2SeqLM.from_pretrained(model_name) |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
|
|
|
|
def preprocess_input(description): |
|
input_text = "Generate an agent that " + description |
|
inputs = tokenizer.encode(input_text, return_tensors='pt') |
|
return inputs |
|
|
|
|
|
def generate_agent_code(inputs): |
|
generated_ids = model.generate(inputs) |
|
agent_code = tokenizer.decode(generated_ids[0], skip_special_tokens=True) |
|
return agent_code |
|
|
|
|
|
user_description = "can perform sentiment analysis on text data." |
|
inputs = preprocess_input(user_description) |
|
generated_code = generate_agent_code(inputs) |
|
print(generated_code) |
|
|