typesdigital commited on
Commit
a95c496
·
1 Parent(s): 313a72e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -5,15 +5,15 @@ import openai
5
  openai.api_key = "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"
6
 
7
  # Define the code generation function
8
- def code_generation(message):
9
  # Set the model name and parameters
10
- model = "nlpxucan/wizardlm-base"
11
  max_tokens = 100
12
 
13
- # Generate code using the model
14
  response = openai.Completion.create(
15
- engine="text-davinci-003",
16
- prompt=message,
17
  max_tokens=max_tokens,
18
  temperature=0.7,
19
  top_p=1.0,
@@ -32,13 +32,16 @@ iface = gr.Interface(
32
  fn=code_generation,
33
  inputs="text",
34
  outputs="text",
35
- title="Code Generation with WizardLM",
36
- description="Enter a message as code prompt to generate code.",
37
  examples=[
38
- ["Create a function to calculate the factorial of a number."],
39
- ["Sort a list of integers in ascending order."],
40
  ],
41
- theme="default"
 
 
 
42
  )
43
 
44
  # Run the Gradio interface
 
5
  openai.api_key = "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"
6
 
7
  # Define the code generation function
8
+ def code_generation(code):
9
  # Set the model name and parameters
10
+ model = "openai-codex"
11
  max_tokens = 100
12
 
13
+ # Generate code suggestions using the model
14
  response = openai.Completion.create(
15
+ engine="davinci-codex",
16
+ prompt=code,
17
  max_tokens=max_tokens,
18
  temperature=0.7,
19
  top_p=1.0,
 
32
  fn=code_generation,
33
  inputs="text",
34
  outputs="text",
35
+ title="Code Writing and Debugging",
36
+ description="Write code and get code suggestions.",
37
  examples=[
38
+ ["for i in range(10):", "\tprint(i)"],
39
+ ["def factorial(n):", "\tif n == 0:", "\t\treturn 1", "\telse:", "\t\treturn n * factorial(n-1)"]
40
  ],
41
+ allow_flagging=False,
42
+ layout="vertical",
43
+ theme="compact",
44
+ live=True,
45
  )
46
 
47
  # Run the Gradio interface