JagadishR commited on
Commit
3a2341a
·
verified ·
1 Parent(s): b1db6f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -1,12 +1,14 @@
1
- #@title Gradio App
2
  import gradio as gr
3
- import os
4
  import google.generativeai as palm
5
 
6
  # load model
7
  # PaLM API Key here
8
- palm.configure(api_key='INSERT_KEY_HERE')
9
-
 
 
 
10
 
11
  # define completion function
12
  def get_completion(code_snippet):
@@ -39,7 +41,7 @@ def get_completion(code_snippet):
39
  """
40
 
41
  prompt = f"""
42
- Your task is to act as a Python Code Explainer.
43
  I'll give you a Code Snippet.
44
  Your job is to explain the Code Snippet step-by-step.
45
  Break down the code into as many steps as possible.
@@ -66,8 +68,8 @@ def get_completion(code_snippet):
66
 
67
  # define app UI
68
  iface = gr.Interface(fn=get_completion, inputs=[gr.Textbox(label="Insert Code Snippet",lines=5)],
69
- outputs=[gr.Textbox(label="Explanation Here",lines=5)],
70
- title="Python Code Explainer"
71
  )
72
 
73
- iface.launch(share=True)
 
1
+ #@title Code Explainer
2
  import gradio as gr
 
3
  import google.generativeai as palm
4
 
5
  # load model
6
  # PaLM API Key here
7
+ palm.configure(api_key='AIzaSyDbNHGiryXeU3CuQtRFBWaYuGt628_FP30')
8
+ # Use the palm.list_models function to find available models
9
+ # PaLM 2 available in 4 sizes: Gecko, Otter, Bison and Unicorn (largest)
10
+ models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]
11
+ model = models[0].name
12
 
13
  # define completion function
14
  def get_completion(code_snippet):
 
41
  """
42
 
43
  prompt = f"""
44
+ Your task is to act as any language Code Explainer.
45
  I'll give you a Code Snippet.
46
  Your job is to explain the Code Snippet step-by-step.
47
  Break down the code into as many steps as possible.
 
68
 
69
  # define app UI
70
  iface = gr.Interface(fn=get_completion, inputs=[gr.Textbox(label="Insert Code Snippet",lines=5)],
71
+ outputs=[gr.Textbox(label="Explanation Here",lines=8)],
72
+ title="Code Explainer"
73
  )
74
 
75
+ iface.launch()