Asna-DifiNative commited on
Commit
ccffeee
·
1 Parent(s): ed7b53e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
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 = "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
@@ -15,6 +19,7 @@ def translate_instruction(context, input_text):
15
  outputs = model.generate(input_ids, max_length=50, num_beams=4, early_stopping=True)
16
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
17
  return translated_text
 
18
 
19
  # Gradio Interface
20
  iface = gr.Interface(
@@ -27,17 +32,16 @@ iface = gr.Interface(
27
  title="CLI Command Generator",
28
  description="<p>This tool generates CLI commands from human instructions and context.</p>"
29
  "<p>Provide a context and human instruction, and click 'Generate' to get the CLI command.</p>",
30
- examples="""<div style='text-align: left'>
31
- <p>Examples:</p>
32
- <ul>
33
- <li>Pod xyz is called as tiger. -> Show me a list of pods in the current namespace.</li>
34
- <li>Nickname of deployment development is cap -> Display the pods running in the cap.</li>
35
- <li>Production is also known as -> List all pods in the 'production' environment.</li>
36
- <li>Kubernetes -> Show the pods running in the 'testing' namespace?</li>
37
- <li>Docker -> What command should I use to get the list of containers?</li>
38
- </ul>
39
- </div>"""
40
  )
41
 
 
 
42
  # Launch the Gradio app using Ngrok
43
- 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 = "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
 
19
  outputs = model.generate(input_ids, max_length=50, num_beams=4, early_stopping=True)
20
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
21
  return translated_text
22
+
23
 
24
  # Gradio Interface
25
  iface = gr.Interface(
 
32
  title="CLI Command Generator",
33
  description="<p>This tool generates CLI commands from human instructions and context.</p>"
34
  "<p>Provide a context and human instruction, and click 'Generate' to get the CLI command.</p>",
35
+ examples=[
36
+ ["Pod xyz is called as tiger.", "Show me a list of pods in the current namespace."],
37
+ ["Nickname of deployment development is cap", "Display the pods running in the cap."],
38
+ ["Production is also known as", "List all pods in the 'production' environment."],
39
+ ["Kubernetes", "Show the pods running in the 'testing' namespace?"],
40
+ ["Docker", "What command should I use to get the list of containers?"]
41
+ ]
 
 
 
42
  )
43
 
44
+
45
+
46
  # Launch the Gradio app using Ngrok
47
+ iface.launch()