yukimama commited on
Commit
ed67e25
·
verified ·
1 Parent(s): 58c8998

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -35
app.py CHANGED
@@ -9,7 +9,7 @@ tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
9
  tokenizer.pad_token = tokenizer.eos_token
10
 
11
  def generate_command(prompt, max_length=100):
12
- full_prompt = f"Generate a Bash command for {prompt}:```bash\n"
13
  inputs = tokenizer.encode(full_prompt, return_tensors="pt")
14
 
15
  output = model.generate(
@@ -42,37 +42,4 @@ iface = gr.Interface(
42
  description="Generate bash commands based on your input prompt."
43
  )
44
 
45
- iface.launch()
46
- ```
47
-
48
- ### 使用示例
49
-
50
- 1. **生成文件操作指令**:
51
- ```python
52
- prompt = "deleting a file"
53
- generated_command = generate_command(prompt)
54
- print(generated_command)
55
- ```
56
-
57
- 可能的輸出:
58
- ```
59
- rm filename.txt
60
- ```
61
-
62
- 2. **生成網絡操作指令**:
63
- ```python
64
- prompt = "downloading a file from a URL"
65
- generated_command = generate_command(prompt)
66
- print(generated_command)
67
- ```
68
-
69
- 可能的輸出:
70
- ```
71
- wget https://example.com/file.txt
72
- ```
73
-
74
- 3. **生成系統管理指令**:
75
- ```python
76
- prompt = "checking system memory usage"
77
- generated_command = generate_command(prompt)
78
- print(generated_command)
 
9
  tokenizer.pad_token = tokenizer.eos_token
10
 
11
  def generate_command(prompt, max_length=100):
12
+ full_prompt = f"Generate a command for {prompt}:```bash\n"
13
  inputs = tokenizer.encode(full_prompt, return_tensors="pt")
14
 
15
  output = model.generate(
 
42
  description="Generate bash commands based on your input prompt."
43
  )
44
 
45
+ iface.launch()