Update core_creator/code_generator.py
Browse files
core_creator/code_generator.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
# code_generator.py - Turns app blueprint into executable Python code using OpenAI
|
| 2 |
|
|
|
|
| 3 |
from openai import OpenAI
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
def generate_app_code(blueprint: dict) -> str:
|
| 7 |
base_prompt = f"""
|
|
@@ -25,7 +27,7 @@ def generate_app_code(blueprint: dict) -> str:
|
|
| 25 |
- Return only the Python code, no extra explanation.
|
| 26 |
"""
|
| 27 |
|
| 28 |
-
response =
|
| 29 |
model="gpt-4o",
|
| 30 |
messages=[
|
| 31 |
{"role": "system", "content": "You write production-quality Hugging Face Spaces code."},
|
|
|
|
| 1 |
# code_generator.py - Turns app blueprint into executable Python code using OpenAI
|
| 2 |
|
| 3 |
+
import os
|
| 4 |
from openai import OpenAI
|
| 5 |
+
|
| 6 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 7 |
|
| 8 |
def generate_app_code(blueprint: dict) -> str:
|
| 9 |
base_prompt = f"""
|
|
|
|
| 27 |
- Return only the Python code, no extra explanation.
|
| 28 |
"""
|
| 29 |
|
| 30 |
+
response = client.chat.completions.create(
|
| 31 |
model="gpt-4o",
|
| 32 |
messages=[
|
| 33 |
{"role": "system", "content": "You write production-quality Hugging Face Spaces code."},
|