Spaces:
Runtime error
Runtime error
Commit ·
f41e052
1
Parent(s): acc2563
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,11 +2,15 @@ import torch
|
|
| 2 |
from transformers import BartForConditionalGeneration, BartTokenizer
|
| 3 |
import gradio as gr
|
| 4 |
|
|
|
|
|
|
|
| 5 |
# Load the fine-tuned model and tokenizer
|
| 6 |
model_path = "Asna-DifiNative/AIBuddy" # Path to the pretrained fine-tuned model
|
| 7 |
model = BartForConditionalGeneration.from_pretrained(model_path)
|
| 8 |
tokenizer = BartTokenizer.from_pretrained(model_path)
|
| 9 |
|
|
|
|
|
|
|
| 10 |
# Translate function using the fine-tuned model
|
| 11 |
def translate_instruction(context, input_text):
|
| 12 |
full_input = context + " " + input_text
|
|
@@ -16,15 +20,20 @@ def translate_instruction(context, input_text):
|
|
| 16 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 17 |
return translated_text
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
# Example instructions
|
| 20 |
example_instructions = [
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
]
|
| 27 |
|
|
|
|
|
|
|
| 28 |
# Gradio Interface
|
| 29 |
iface = gr.Interface(
|
| 30 |
fn=translate_instruction,
|
|
@@ -34,18 +43,18 @@ iface = gr.Interface(
|
|
| 34 |
],
|
| 35 |
outputs=gr.outputs.Textbox(label="Generated CLI Command"),
|
| 36 |
title="CLI Command Generator",
|
| 37 |
-
description=
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
f"</table>",
|
| 47 |
-
examples=example_instructions
|
| 48 |
)
|
| 49 |
|
|
|
|
|
|
|
| 50 |
# Launch the Gradio app using Ngrok
|
| 51 |
-
iface.launch()
|
|
|
|
| 2 |
from transformers import BartForConditionalGeneration, BartTokenizer
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
|
| 6 |
+
|
| 7 |
# Load the fine-tuned model and tokenizer
|
| 8 |
model_path = "Asna-DifiNative/AIBuddy" # Path to the pretrained fine-tuned model
|
| 9 |
model = BartForConditionalGeneration.from_pretrained(model_path)
|
| 10 |
tokenizer = BartTokenizer.from_pretrained(model_path)
|
| 11 |
|
| 12 |
+
|
| 13 |
+
|
| 14 |
# Translate function using the fine-tuned model
|
| 15 |
def translate_instruction(context, input_text):
|
| 16 |
full_input = context + " " + input_text
|
|
|
|
| 20 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 21 |
return translated_text
|
| 22 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
# Example instructions
|
| 27 |
example_instructions = [
|
| 28 |
+
"Show me a list of pods in the current namespace.",
|
| 29 |
+
"Display the pods running in the 'development' namespace.",
|
| 30 |
+
"List all pods in the 'production' environment.",
|
| 31 |
+
"How can I see the pods in the 'testing' namespace?",
|
| 32 |
+
"What command should I use to get the list of containers?"
|
| 33 |
]
|
| 34 |
|
| 35 |
+
|
| 36 |
+
|
| 37 |
# Gradio Interface
|
| 38 |
iface = gr.Interface(
|
| 39 |
fn=translate_instruction,
|
|
|
|
| 43 |
],
|
| 44 |
outputs=gr.outputs.Textbox(label="Generated CLI Command"),
|
| 45 |
title="CLI Command Generator",
|
| 46 |
+
description="<p>This tool generates CLI commands from human instructions and context.</p>"
|
| 47 |
+
"<p>Provide a context and human instruction, and click 'Generate' to get the CLI command.</p>",
|
| 48 |
+
examples=[
|
| 49 |
+
["Pod xyz is called as tiger.", "Show me a list of pods in the current namespace."],
|
| 50 |
+
["Nickname of deployment development is cap", "Display the pods running in the cap."],
|
| 51 |
+
["Production is also known as", "List all pods in the 'production' environment."],
|
| 52 |
+
["Kubernetes", "Show the pods running in the 'testing' namespace?"],
|
| 53 |
+
["Docker", "What command should I use to get the list of containers?"]
|
| 54 |
+
]
|
|
|
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
+
|
| 58 |
+
|
| 59 |
# Launch the Gradio app using Ngrok
|
| 60 |
+
iface.launch()
|