S-Dreamer commited on
Commit
1d6229c
·
verified ·
1 Parent(s): bf3d2e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -1,15 +1,11 @@
1
- import os
2
  import gradio as gr
3
  import requests
4
-
5
- # Retrieve the API key from the environment variable
6
- api_key = os.getenv('CODEPAL_API_KEY')
7
- if not api_key:
8
- raise ValueError("API key not found. Please set the CODEPAL_API_KEY environment variable.")
9
 
10
  # Function to call CodePal's Code Generator API
11
  def generate_code(instructions, language, generation_type):
12
  api_url = 'https://api.codepal.ai/v1/code-generator/query'
 
13
  headers = {'Authorization': f'Bearer {api_key}'}
14
  data = {
15
  'instructions': instructions,
@@ -29,6 +25,7 @@ with gr.Blocks() as demo:
29
  gr.Markdown("# Code Generator Interface\nGenerate code snippets using CodePal's Code Generator API.")
30
  with gr.Row():
31
  with gr.Column():
 
32
  instructions_input = gr.Textbox(label='Function Description', placeholder='Describe the function to generate...')
33
  language_input = gr.Dropdown(label='Programming Language', choices=['python', 'javascript', 'go', 'java', 'csharp'])
34
  generation_type_input = gr.Radio(label='Generation Type', choices=['minimal', 'standard', 'documented'], value='standard')
 
 
1
  import gradio as gr
2
  import requests
3
+ import os
 
 
 
 
4
 
5
  # Function to call CodePal's Code Generator API
6
  def generate_code(instructions, language, generation_type):
7
  api_url = 'https://api.codepal.ai/v1/code-generator/query'
8
+ api_key = os.getenv('CODEPAL_API_KEY')
9
  headers = {'Authorization': f'Bearer {api_key}'}
10
  data = {
11
  'instructions': instructions,
 
25
  gr.Markdown("# Code Generator Interface\nGenerate code snippets using CodePal's Code Generator API.")
26
  with gr.Row():
27
  with gr.Column():
28
+ login_button = gr.LoginButton()
29
  instructions_input = gr.Textbox(label='Function Description', placeholder='Describe the function to generate...')
30
  language_input = gr.Dropdown(label='Programming Language', choices=['python', 'javascript', 'go', 'java', 'csharp'])
31
  generation_type_input = gr.Radio(label='Generation Type', choices=['minimal', 'standard', 'documented'], value='standard')