Download core_creator/app_blueprint.py from mgbam/robosage: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/mgbam/robosage/resolve/d787996f99502a8858b4dac2c75c32c6ec0455e2/core_creator/app_blueprint.py
- Command line
-
hf download hf://spaces/mgbam/robosage@d787996f99502a8858b4dac2c75c32c6ec0455e2/core_creator/app_blueprint.py
-
curl -L -o app_blueprint.py https://huggingface.co/spaces/mgbam/robosage/resolve/d787996f99502a8858b4dac2c75c32c6ec0455e2/core_creator/app_blueprint.py
1.72 kB
| # app_blueprint.py - Translates a robotics idea and intent into an app design blueprint | |
| import os | |
| import json | |
| from openai import OpenAI | |
| # Initialize OpenAI client using environment variable | |
| 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()} | |
| def build_app_code(idea: str, intent: str) -> dict: | |
| return generate_app_blueprint(idea, intent) | |
| # Example | |
| if __name__ == "__main__": | |
| idea = "Make a robot that waves and greets customers at a store entrance." | |
| intent = "retail" | |
| print(generate_app_blueprint(idea, intent)) | |