File size: 1,175 Bytes
ddaad63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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))
|