Update app.py
Browse files
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"
|
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="
|
42 |
-
description="
|
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 = "
|
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)
|