|
|
|
|
|
import os |
|
import json |
|
from openai import OpenAI |
|
|
|
|
|
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) |
|
|
|
def generate_app_blueprint(idea: str, intent: str) -> dict: |
|
system_prompt = f""" |
|
You are a robotics app designer. |
|
Given the user's idea and intent category, output a JSON blueprint with: |
|
|
|
- "title": Name of the app |
|
- "description": Summary of what the robot does |
|
- "inputs": Required sensors or input sources |
|
- "outputs": Actions, movements, speech, UI elements |
|
- "voice_commands": Expected voice inputs from the user |
|
- "monetization": Suggested monetization strategies (e.g., subscription, ads, hardware upsells) |
|
|
|
Be concise but complete. Return only a JSON object. |
|
|
|
Example idea: {idea} |
|
Intent category: {intent} |
|
|
|
Blueprint: |
|
""" |
|
|
|
response = client.chat.completions.create( |
|
model="gpt-4o", |
|
messages=[ |
|
{"role": "system", "content": "You are a robotics UX planner."}, |
|
{"role": "user", "content": system_prompt}, |
|
], |
|
temperature=0.7 |
|
) |
|
|
|
try: |
|
blueprint = json.loads(response.choices[0].message.content.strip()) |
|
return blueprint |
|
except Exception as e: |
|
return {"error": str(e), "raw_response": response.choices[0].message.content.strip()} |
|
|
|
|
|
if __name__ == "__main__": |
|
idea = "Make a robot that waves and greets customers at a store entrance." |
|
intent = "retail" |
|
print(generate_app_blueprint(idea, intent)) |
|
|