# intent_parser.py - Extracts purpose and domain of the robotics app idea | |
from openai import OpenAI | |
# Categories the system understands | |
INTENT_CATEGORIES = [ | |
"educational", | |
"assistive", | |
"entertainment", | |
"industrial", | |
"home automation", | |
"healthcare", | |
"retail", | |
"creative" | |
] | |
# Simple prompt to detect the category of the robot idea | |
def classify_robot_idea(user_input: str) -> str: | |
system_prompt = f""" | |
Classify this user idea into one of the following categories: | |
{', '.join(INTENT_CATEGORIES)}. | |
Only return the category word. If none fits, return 'creative'. | |
Idea: {user_input} | |
Category: | |
""" | |
response = OpenAI().chat.completions.create( | |
model="gpt-4o", | |
messages=[ | |
{"role": "system", "content": "You are a classification AI for robotics ideas."}, | |
{"role": "user", "content": system_prompt}, | |
], | |
temperature=0 | |
) | |
return response.choices[0].message.content.strip().lower() | |
# Example | |
if __name__ == "__main__": | |
example = "Create a robot that helps blind users find objects at home." | |
print("Predicted Intent:", classify_robot_idea(example)) | |