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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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"生成一個Bash指令,用於{prompt}:```bash\n"
13
  inputs = tokenizer.encode(full_prompt, return_tensors="pt")
14
 
15
  output = model.generate(
@@ -36,10 +36,10 @@ def predict(input_text):
36
 
37
  iface = gr.Interface(
38
  fn=predict,
39
- inputs=gr.Textbox(lines=2, placeholder="請輸入你的指令生成提示..."),
40
  outputs="text",
41
- title="使用 GPT2 生成指令",
42
- description="根據你的中文輸入提示生成 Bash 指令。"
43
  )
44
 
45
  iface.launch()
@@ -49,7 +49,7 @@ iface.launch()
49
 
50
  1. **生成文件操作指令**:
51
  ```python
52
- prompt = "刪除一個文件"
53
  generated_command = generate_command(prompt)
54
  print(generated_command)
55
  ```
@@ -61,7 +61,7 @@ iface.launch()
61
 
62
  2. **生成網絡操作指令**:
63
  ```python
64
- prompt = "URL下載一個文件"
65
  generated_command = generate_command(prompt)
66
  print(generated_command)
67
  ```
@@ -73,6 +73,6 @@ iface.launch()
73
 
74
  3. **生成系統管理指令**:
75
  ```python
76
- prompt = "檢查系統記憶體使用情況"
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 Bash command for {prompt}:```bash\n"
13
  inputs = tokenizer.encode(full_prompt, return_tensors="pt")
14
 
15
  output = model.generate(
 
36
 
37
  iface = gr.Interface(
38
  fn=predict,
39
+ inputs=gr.Textbox(lines=2, placeholder="Enter your command generation prompt here..."),
40
  outputs="text",
41
+ title="Command Generation with GPT2",
42
+ description="Generate bash commands based on your input prompt."
43
  )
44
 
45
  iface.launch()
 
49
 
50
  1. **生成文件操作指令**:
51
  ```python
52
+ prompt = "deleting a file"
53
  generated_command = generate_command(prompt)
54
  print(generated_command)
55
  ```
 
61
 
62
  2. **生成網絡操作指令**:
63
  ```python
64
+ prompt = "downloading a file from a URL"
65
  generated_command = generate_command(prompt)
66
  print(generated_command)
67
  ```
 
73
 
74
  3. **生成系統管理指令**:
75
  ```python
76
+ prompt = "checking system memory usage"
77
  generated_command = generate_command(prompt)
78
  print(generated_command)