Update core_creator/intent_parser.py
Browse files
core_creator/intent_parser.py
CHANGED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# intent_parser.py - Extracts purpose and domain of the robotics app idea
|
2 |
+
|
3 |
+
from openai import OpenAI
|
4 |
+
|
5 |
+
# Categories the system understands
|
6 |
+
INTENT_CATEGORIES = [
|
7 |
+
"educational",
|
8 |
+
"assistive",
|
9 |
+
"entertainment",
|
10 |
+
"industrial",
|
11 |
+
"home automation",
|
12 |
+
"healthcare",
|
13 |
+
"retail",
|
14 |
+
"creative"
|
15 |
+
]
|
16 |
+
|
17 |
+
# Simple prompt to detect the category of the robot idea
|
18 |
+
def classify_robot_idea(user_input: str) -> str:
|
19 |
+
system_prompt = f"""
|
20 |
+
Classify this user idea into one of the following categories:
|
21 |
+
{', '.join(INTENT_CATEGORIES)}.
|
22 |
+
Only return the category word. If none fits, return 'creative'.
|
23 |
+
|
24 |
+
Idea: {user_input}
|
25 |
+
Category:
|
26 |
+
"""
|
27 |
+
|
28 |
+
response = OpenAI().chat.completions.create(
|
29 |
+
model="gpt-4o",
|
30 |
+
messages=[
|
31 |
+
{"role": "system", "content": "You are a classification AI for robotics ideas."},
|
32 |
+
{"role": "user", "content": system_prompt},
|
33 |
+
],
|
34 |
+
temperature=0
|
35 |
+
)
|
36 |
+
return response.choices[0].message.content.strip().lower()
|
37 |
+
|
38 |
+
# Example
|
39 |
+
if __name__ == "__main__":
|
40 |
+
example = "Create a robot that helps blind users find objects at home."
|
41 |
+
print("Predicted Intent:", classify_robot_idea(example))
|