muhtasham commited on
Commit
48e8117
1 Parent(s): fe9d921

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -13,6 +13,10 @@ name_list = ['huggingface/lvwerra/codeparrot','huggingface/facebook/incoder-1B',
13
 
14
  open_ai_name = ['openai/code-davinci-002', 'openai/code-cushman-001']
15
 
 
 
 
 
16
  def generate_code_os(text):
17
  interfaces = [gr.Interface.load(name) for name in name_list]
18
  return [interface(text) for interface in interfaces]
@@ -42,7 +46,9 @@ def generate_code_cs_2(text):
42
  ).choices[0].text
43
  return response_2
44
 
45
-
 
 
46
  with gr.Blocks() as demo:
47
  gr.Markdown("# Compare OpenAI and HuggingFace Code Generators")
48
  with gr.Box():
@@ -52,7 +58,11 @@ with gr.Blocks() as demo:
52
  with gr.Row():
53
  btn = gr.Button("Open-Source models Generate code brrr ...")
54
  btn2 = gr.Button("OpenAI models Generate code brrr ...")
55
-
 
 
 
 
56
  with gr.Column():
57
  gr.Markdown("Let’s Compare code generators ")
58
  btn2.click(generate_code_cs_1, inputs = input_text, outputs = [gr.Textbox(label=open_ai_name[_], lines=4) for _ in range(len(open_ai_name))])
 
13
 
14
  open_ai_name = ['openai/code-davinci-002', 'openai/code-cushman-001']
15
 
16
+ examples = [ ["import numpy as np \n from sklearn.ensemble import RandomForestClassifier \n # create training data \n X = np.random.randn(100, 100) y = np.random.randint(0, 1, 100)# setup train test split \n "],
17
+ ['def get_file_size(filepath):'],
18
+ ]
19
+
20
  def generate_code_os(text):
21
  interfaces = [gr.Interface.load(name) for name in name_list]
22
  return [interface(text) for interface in interfaces]
 
46
  ).choices[0].text
47
  return response_2
48
 
49
+ def set_example(example: list) -> dict:
50
+ return gr.Textbox.update(value=example[0])
51
+
52
  with gr.Blocks() as demo:
53
  gr.Markdown("# Compare OpenAI and HuggingFace Code Generators")
54
  with gr.Box():
 
58
  with gr.Row():
59
  btn = gr.Button("Open-Source models Generate code brrr ...")
60
  btn2 = gr.Button("OpenAI models Generate code brrr ...")
61
+
62
+ example_text = gr.Dataset(components=[input_text], samples=examples)
63
+ example_text.click(fn=set_example,
64
+ inputs = example_text,
65
+ outputs= example_text.components)
66
  with gr.Column():
67
  gr.Markdown("Let’s Compare code generators ")
68
  btn2.click(generate_code_cs_1, inputs = input_text, outputs = [gr.Textbox(label=open_ai_name[_], lines=4) for _ in range(len(open_ai_name))])