ANASAKHTAR commited on
Commit
f2b45ff
·
verified ·
1 Parent(s): 10662c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -8,9 +8,9 @@ from transformers import pipeline
8
  code_writer = pipeline("text-generation", model="Qwen/Qwen2.5-Coder-7B-Instruct",torch_dtype=torch.bfloat16 )
9
 
10
  # Define the code generation function
11
- def generate_code(prompt, max_length):
12
- # Generate code based on the input prompt and maximum length
13
- output = code_writer(prompt, max_length=max_length, num_return_sequences=1, do_sample=True)
14
  return output[0]['generated_text']
15
 
16
  # Close any existing Gradio instances
@@ -20,11 +20,7 @@ gr.close_all()
20
  Demo = gr.Interface(
21
  fn=generate_code,
22
  inputs=[
23
- gr.Textbox(label="Code Prompt", lines=5, placeholder="Enter a description or snippet for code generation."),
24
- gr.Slider(
25
- label="Code Length (Tokens Approx.)",
26
- minimum=10, maximum=2000, step=20, value=50
27
- )
28
  ],
29
  outputs=[gr.Textbox(label="Generated Code", lines=10)],
30
  title="Code_Generator_App",
@@ -33,4 +29,3 @@ Demo = gr.Interface(
33
 
34
  # Launch the app with a public link
35
  Demo.launch(share=True)
36
-
 
8
  code_writer = pipeline("text-generation", model="Qwen/Qwen2.5-Coder-7B-Instruct",torch_dtype=torch.bfloat16 )
9
 
10
  # Define the code generation function
11
+ def generate_code(prompt):
12
+ # Generate code based on the input prompt
13
+ output = code_writer(prompt, num_return_sequences=1, do_sample=True)
14
  return output[0]['generated_text']
15
 
16
  # Close any existing Gradio instances
 
20
  Demo = gr.Interface(
21
  fn=generate_code,
22
  inputs=[
23
+ gr.Textbox(label="Code Prompt", lines=5, placeholder="Enter a description or snippet for code generation.")
 
 
 
 
24
  ],
25
  outputs=[gr.Textbox(label="Generated Code", lines=10)],
26
  title="Code_Generator_App",
 
29
 
30
  # Launch the app with a public link
31
  Demo.launch(share=True)