Spaces:
Running
Running
acecalisto3
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -247,10 +247,8 @@ def translate_code(code, source_language, target_language):
|
|
247 |
# 6. Code Generation
|
248 |
def generate_code(idea):
|
249 |
"""Generates code based on a given idea using the EleutherAI/gpt-neo-2.7B model.
|
250 |
-
|
251 |
Args:
|
252 |
idea: The idea for the code to be generated.
|
253 |
-
|
254 |
Returns:
|
255 |
The generated code as a string.
|
256 |
"""
|
@@ -281,7 +279,11 @@ def generate_code(idea):
|
|
281 |
generated_code = tokenizer.decode(output_sequences[0], skip_special_tokens=True)
|
282 |
|
283 |
# Remove the prompt and formatting
|
284 |
-
|
|
|
|
|
|
|
|
|
285 |
|
286 |
return generated_code
|
287 |
|
|
|
247 |
# 6. Code Generation
|
248 |
def generate_code(idea):
|
249 |
"""Generates code based on a given idea using the EleutherAI/gpt-neo-2.7B model.
|
|
|
250 |
Args:
|
251 |
idea: The idea for the code to be generated.
|
|
|
252 |
Returns:
|
253 |
The generated code as a string.
|
254 |
"""
|
|
|
279 |
generated_code = tokenizer.decode(output_sequences[0], skip_special_tokens=True)
|
280 |
|
281 |
# Remove the prompt and formatting
|
282 |
+
parts = generated_code.split("\n# Code:")
|
283 |
+
if len(parts) > 1:
|
284 |
+
generated_code = parts[1].strip()
|
285 |
+
else:
|
286 |
+
generated_code = generated_code.strip()
|
287 |
|
288 |
return generated_code
|
289 |
|