Views
No views yet
google/flan-t5-large, specialized in translating natural language instructions into Linux Bash commands.package.json (npm), requirements.txt (pip), or go.mod (go) before generating the command.echo or :) instead of attempting to execute dangerous code.grep, awk, sed, sort, and uniq for forensic log analysis and data processing.sudo, creating missing directories, or resolving git conflicts).Contexto: [file_list] | Instrucción1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3model_name = "jrodriiguezg/lime-t5-large-770m"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
6
7def generate_command(files, instruction):
8 # Strictly format the prompt using the training keywords
9 input_text = f"Contexto: {files} | {instruction}"
10
11 inputs = tokenizer(input_text, return_tensors="pt", max_length=128, truncation=True)
12 outputs = model.generate(**inputs, max_length=128, num_beams=5, early_stopping=True)
13
14 return tokenizer.decode(outputs[0], skip_special_tokens=True)
15
16# Case 1: Context Usage
17files = '["main.py", "requirements.txt", ".env"]'
18instruction = "Inicia el servidor"
19print(generate_command(files, instruction))
20# Expected output: python3 main.py (or context-specific command)
21
22# Case 2: Self-Correction
23files = '[]'
24instruction = "El comando 'apt install nginx' falló con error: 'Permission denied'. Corrígelo."
25print(generate_command(files, instruction))
26# Expected output: sudo apt install nginx