Felguk commited on
Commit
24a6e7e
·
verified ·
1 Parent(s): d43122f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,8 +1,9 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load a pre-trained code generation model (replace with your actual model)
5
- code_generator = pipeline("text-generation", model="gpt-3.5-turbo") # Example model
 
6
 
7
  # Function to generate code
8
  def generate_code(prompt, file_type):
@@ -13,7 +14,7 @@ def generate_code(prompt, file_type):
13
  # Handle programming language code generation
14
  prompt_with_file_type = f"Write a {file_type} code for: {prompt}"
15
 
16
- # Generate code using the AI model
17
  generated_code = code_generator(prompt_with_file_type, max_length=200, num_return_sequences=1)
18
  return generated_code[0]['generated_text']
19
 
@@ -22,7 +23,7 @@ def update_code(existing_code, update_prompt):
22
  # Combine the existing code and the update prompt
23
  prompt_with_update = f"Rewrite the following code to: {update_prompt}\n\nExisting Code:\n{existing_code}"
24
 
25
- # Generate updated code using the AI model
26
  updated_code = code_generator(prompt_with_update, max_length=200, num_return_sequences=1)
27
  return updated_code[0]['generated_text']
28
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load a custom model (replace with your DeepSeek model)
5
+ # Example: Using a Hugging Face model as a placeholder
6
+ code_generator = pipeline("text-generation", model="deepseek-ai/deepseek-coder") # Replace with your DeepSeek model
7
 
8
  # Function to generate code
9
  def generate_code(prompt, file_type):
 
14
  # Handle programming language code generation
15
  prompt_with_file_type = f"Write a {file_type} code for: {prompt}"
16
 
17
+ # Generate code using the custom model
18
  generated_code = code_generator(prompt_with_file_type, max_length=200, num_return_sequences=1)
19
  return generated_code[0]['generated_text']
20
 
 
23
  # Combine the existing code and the update prompt
24
  prompt_with_update = f"Rewrite the following code to: {update_prompt}\n\nExisting Code:\n{existing_code}"
25
 
26
+ # Generate updated code using the custom model
27
  updated_code = code_generator(prompt_with_update, max_length=200, num_return_sequences=1)
28
  return updated_code[0]['generated_text']
29