Update ontochat/functions.py
Browse files- ontochat/functions.py +88 -87
ontochat/functions.py
CHANGED
@@ -8,101 +8,99 @@ openai_api_key = None
|
|
8 |
|
9 |
current_preidentified_prompts = []
|
10 |
current_preidentified = [
|
11 |
-
"""The ontology
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
"""My persona is **[NAME]**, I am **[AGE]** years old, and I work as a **[OCCUPATION]** in the domain of **[DOMAIN]**. My expertise includes **[SKILLS]**, and I have a strong interest in **[INTERESTS]**.
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
1. The persona is clearly described with a focus on ontology-related expertise.
|
20 |
-
2. The details (name, age, occupation, skills, interests) are logically aligned with domain ontologies and structured knowledge representation.
|
21 |
-
3. If the skills and interests provided by the user are similar and hard to differentiate, generate distinct ones by distinguishing between conceptual knowledge (e.g., ontological modeling) and applied techniques (e.g., knowledge graph construction).
|
22 |
-
4. The language is *[CONCISE & PRECISE / CREATIVE & DETAILED]*, ensuring clarity in an ontology-driven context.
|
23 |
-
5. The final answer is structured as *[BULLET POINTS / A DETAILED PARAGRAPH]*.""",
|
24 |
-
|
25 |
-
"""My ontology user goal is **[USER GOAL DESCRIPTION]**.
|
26 |
|
27 |
Please refine my response to ensure:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
35 |
|
36 |
-
"""The
|
37 |
|
38 |
Please refine my response to ensure:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
2. The actions are actionable and presented as a logical sequence of steps related to ontology design, integration, or reasoning.
|
42 |
-
3. Each step includes specific *[ONTOLOGY ENGINEERING METHODS]*, *[KNOWLEDGE REPRESENTATION TOOLS]*, or *[INFERENCE TECHNIQUES]* and is practical.
|
43 |
-
4. Where relevant, incorporate *[INTERDISCIPLINARY INSIGHTS]* to describe the role of ontologies in broader knowledge management.
|
44 |
-
5. Ensure the actions align logically with my expertise and ontology development goals.
|
45 |
-
6. The language is *[CONCISE & PRECISE / CREATIVE & DETAILED]*.
|
46 |
-
7. The final answer is structured as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
47 |
-
|
48 |
-
"""The key ontology concepts and terms related to my goal are **[KEYWORDS]**.
|
49 |
|
50 |
Please refine my response to ensure:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
2. Each keyword directly supports knowledge structuring and reasoning.
|
54 |
-
3. Keywords are aligned with *[EXISTING ONTOLOGY VOCABULARIES]* or *[STANDARDS]*.
|
55 |
-
4. Keywords are expanded with related ontological terms (e.g., subclass relationships, linked data mappings).
|
56 |
-
5. The language is *[CONCISE & PRECISE / CREATIVE & DETAILED]*.
|
57 |
-
6. The final answer is structured as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
58 |
-
|
59 |
-
"""The current methods I use for knowledge representation and reasoning are **[CURRENT METHODS]**.
|
60 |
|
61 |
Please refine my response to ensure:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
2. The methods must involve manual or ad-hoc knowledge structuring efforts.
|
65 |
-
3. The methods are actionable and presented as a logical sequence of ontology modeling or reasoning steps.
|
66 |
-
4. Each step includes specific *[ONTOLOGY MODELING TOOLS]*, *[KNOWLEDGE REPRESENTATION LANGUAGES]*, or *[LOGICAL INFERENCE TECHNIQUES]*.
|
67 |
-
5. Where relevant, incorporate *[INTERDISCIPLINARY INSIGHTS]* to describe the challenges in integrating knowledge across domains.
|
68 |
-
6. The methods align logically with my expertise and goals.
|
69 |
-
7. The methods include only knowledge structuring tasks, without discussing challenges, new methods, or expected outcomes.
|
70 |
-
8. The language is *[CONCISE & PRECISE / CREATIVE & DETAILED]*.
|
71 |
-
9. The final answer is structured as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
72 |
-
|
73 |
-
"""The challenges I face in ontology-based knowledge representation are **[CHALLENGES]**.
|
74 |
|
75 |
Please refine my response to ensure:
|
76 |
-
|
77 |
-
1. The challenges are clearly described and relate to ontology structuring, reasoning, or interoperability.
|
78 |
-
2. Each challenge should be derived from *[CURRENT TOOLS]*, *[METHODOLOGIES]*, or *[LOGICAL CONSTRAINTS]* used.
|
79 |
-
3. Where relevant, incorporate *[ONTOLOGY INTEGRATION CHALLENGES]* related to external knowledge bases.
|
80 |
-
4. The challenges align logically with my domain expertise and ontology development.
|
81 |
-
5. The challenges include only the core difficulties, without discussing solutions or expected improvements.
|
82 |
-
6. The language is *[CONCISE & PRECISE / CREATIVE & DETAILED]*.
|
83 |
-
7. The final answer is structured as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
84 |
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
Please refine my response to ensure:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
|
90 |
-
2. The new methods align with what an ontology-based system can offer, such as automated reasoning, semantic search, or ontology alignment.
|
91 |
-
3. The methods align logically with my goals and expected improvements.
|
92 |
-
4. The methods include only knowledge representation enhancements, without discussing previous challenges or outcomes.
|
93 |
-
5. The language is *[CONCISE & PRECISE / CREATIVE & DETAILED]*.
|
94 |
-
6. The final answer is structured as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
95 |
-
|
96 |
-
"""The expected outcomes of implementing ontology-driven methods are **[OUTCOMES]**.
|
97 |
|
98 |
Please refine my response to ensure:
|
99 |
-
|
100 |
-
1. The outcomes are clearly described and ontology-
|
101 |
-
2. The outcomes
|
102 |
-
3. The outcomes align logically with my overall goal.
|
103 |
-
4.
|
104 |
-
5.
|
105 |
-
6.
|
106 |
]
|
107 |
|
108 |
def set_openai_api_key(api_key: str):
|
@@ -127,9 +125,9 @@ def user_story_generator(message, history):
|
|
127 |
{
|
128 |
"role": "assistant",
|
129 |
"content": (
|
130 |
-
"Ontology
|
131 |
|
132 |
-
"You are an ontology engineer
|
133 |
"Ask elicitation questions one at a time, providing an example answer and the prompt template the user should use, while incorporating user feedback if needed."
|
134 |
|
135 |
"If all requirements for the current elicitation are fully addressed, always ask the user if this meets their expectations. Do not ask the next question unless the user confirms the current one is satisfactory."
|
@@ -140,30 +138,33 @@ def user_story_generator(message, history):
|
|
140 |
"Do not answer any queries that are not related to this task. \n\n"
|
141 |
|
142 |
"1. Persona\n"
|
143 |
-
"
|
144 |
-
"[Persona]: Ask one elicitation question
|
145 |
"Once the expert provides this information, suggest possible improvements or clarifications. After all persona details are collected, move to the next section.\n\n"
|
146 |
|
147 |
"2. Goal\n"
|
148 |
-
"[User goal description]: Ask one elicitation question to
|
149 |
-
"[Actions]: Ask one elicitation question
|
150 |
-
"[Keywords]: Ask one elicitation question
|
151 |
"Once the expert has answered, offer suggestions for further refinement, then proceed to the next section.\n\n"
|
152 |
|
153 |
"3. Scenario\n"
|
154 |
-
"[Scenario before]: Ask one elicitation question
|
155 |
-
"[Challenges]: Ask one elicitation question
|
156 |
-
"[Scenario during]: Ask one elicitation question
|
157 |
-
"[Scenario after]: Ask one elicitation question
|
158 |
"Provide feedback on each scenario part and refine the answers if needed before moving on."
|
159 |
|
160 |
"4. Create User Story\n"
|
161 |
"Once you have completed sections 1 to 3, summarize the information into a full user story. Use the persona, goal, and scenario information to craft the user story in this format:\n\n"
|
162 |
"Persona: [name], [age], [occupation], [skills], [interests].\n"
|
163 |
-
"Goal: [user goal description]
|
164 |
-
"
|
165 |
-
"
|
166 |
-
"Scenario
|
|
|
|
|
|
|
167 |
"Provide the user story to the domain expert and Ask one elicitation question for any further feedback or refinements. If needed, adjust the story based on their suggestions."
|
168 |
)
|
169 |
}
|
|
|
8 |
|
9 |
current_preidentified_prompts = []
|
10 |
current_preidentified = [
|
11 |
+
"""The domain of the ontology-based system is **[DOMAIN]**.
|
12 |
|
13 |
+
Please ensure that all responses are strictly relevant to this system's domain. Use terminology and structures that are specific to ontology-based systems, including appropriate relationships and reasoning principles. Do not introduce information outside the defined scope.""",
|
|
|
|
|
14 |
|
15 |
+
"""My persona is **[NAME]**, I am **[AGE]** years old, and I work as a **[OCCUPATION]**. My expertise includes **[SKILLS]**, and I have a strong interest in **[INTERESTS]**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
Please refine my response to ensure:
|
18 |
+
|
19 |
+
1. The persona is described clearly, emphasizing expertise or experience relevant to ontology-based systems in the specified domain.
|
20 |
+
2. Details (name, age, occupation, skills, interests) are logically aligned with domain knowledge, typical users, and the use of ontology-based systems.
|
21 |
+
3. If skills and interests overlap, make them distinct by separating conceptual knowledge (e.g., data modeling, requirements analysis) from applied skills (e.g., ontology development, knowledge graph implementation).
|
22 |
+
4. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language for clarity and suitability in a knowledge-intensive context.
|
23 |
+
5. Present the output as *[BULLET POINTS / A DETAILED PARAGRAPH]*.""",
|
24 |
+
|
25 |
+
"""The knowledge modelling objective I aim to achieve with the ontology-based system is **[USER GOAL]**
|
26 |
|
27 |
+
Please refine my response to ensure:
|
28 |
+
|
29 |
+
1. The goal is clearly described and directly related to using an ontology-based system to support a real task in the specified domain.
|
30 |
+
2. Expand the goal if needed: start with a high-level *[KNOWLEDGE REPRESENTATION OBJECTIVE]* (such as representing key domain knowledge, integrating data, or enabling reasoning), then describe a specific *[DOMAIN TASK]* or *[USER NEED]* that the ontology-based system should support.
|
31 |
+
3. Make sure the goal aligns with my domain expertise and addresses a practical scenario where ontology-based systems add value.
|
32 |
+
4. Focus on the ontology-supported aspects of the task, not unrelated system functions or technology details.
|
33 |
+
5. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language as needed for clarity.
|
34 |
+
6. Present the output as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
35 |
|
36 |
+
"""The steps I need to take to build or configure the ontology-based system for this objective are **[ACTIONS]**.
|
37 |
|
38 |
Please refine my response to ensure:
|
39 |
+
|
40 |
+
1. The actions are clearly described and directly relate to the step-by-step process of developing or configuring the ontology-based system.
|
41 |
+
2. List the actions as simple, practical steps required to design, construct, and deploy the ontology-based system for the target domain or goal.
|
42 |
+
3. For each step, specify any *[ONTOLOGY ENGINEERING METHODS]*, *[KNOWLEDGE REPRESENTATION TOOLS]*, *[DATA SOURCES]*, or *[REASONING TECHNIQUES]* used in the process.
|
43 |
+
4. If relevant, include *[COLLABORATION WITH DOMAIN EXPERTS]* or integration of *[EXTERNAL DATASETS]* to enhance system quality.
|
44 |
+
5. Ensure the actions logically align with my background and the requirements of the domain and user goal.
|
45 |
+
6. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language, as appropriate.
|
46 |
+
7. Structure the answer as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
47 |
|
48 |
+
"""The key domain concepts to be represented within the ontology-based system are **[KEYWORDS]**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
Please refine my response to ensure:
|
51 |
+
|
52 |
+
1. The keywords are clearly defined and directly relevant to the ontology-based system and the target domain.
|
53 |
+
2. Each keyword should support knowledge structuring and reasoning within the ontology.
|
54 |
+
3. Where possible, align the keywords with *[EXISTING ONTOLOGY VOCABULARIES]* or recognized *[STANDARDS]*.
|
55 |
+
4. Expand each keyword by adding related ontological terms, such as subclasses, parent classes, or linked data mappings.
|
56 |
+
5. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language as required.
|
57 |
+
6. Structure the answer as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
58 |
|
59 |
+
"""The current manual methods I use to achieve my goal, without the ontology-based system, are **[CURRENT METHODS]**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
Please refine my response to ensure:
|
62 |
+
|
63 |
+
1. The methods are clearly described and involve only manual or ad-hoc approaches for structuring and applying domain knowledge, with no use of ontology-based systems or automated reasoning tools.
|
64 |
+
2. Present the methods as a logical, step-by-step sequence of actions or procedures currently used to achieve my goal.
|
65 |
+
3. For each step, specify any *[MANUAL TOOLS, DOCUMENTATION PRACTICES, or INFORMAL REPRESENTATION TECHNIQUES]* (such as spreadsheets, text documents, or diagrams).
|
66 |
+
4. The methods should reflect established practices within my domain and align logically with my expertise and goals.
|
67 |
+
5. Do not mention challenges, ontology-based systems, new methods, or expected outcomes.
|
68 |
+
6. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language, as needed.
|
69 |
+
7. Structure the answer as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
70 |
|
71 |
+
"""The limitations in current practices that the ontology-based system should address are **[CHALLENGES]**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
Please refine my response to ensure:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
+
1. The challenges are clearly described and arise directly from my current tools, workflows, or informal practices for structuring and reasoning about domain knowledge.
|
76 |
+
2. Each challenge should be specific and derived from limitations of *[CURRENT TOOLS]*, *[METHODOLOGIES]*, or *[LOGICAL CONSTRAINTS]* used in my existing (non-ontology) approaches.
|
77 |
+
3. Where relevant, include issues related to data consistency, integration across sources, or knowledge reuse.
|
78 |
+
4. The challenges should logically relate to my domain and my knowledge structuring goals.
|
79 |
+
5. Focus only on core difficulties with current methods—do not discuss possible solutions or expected improvements.
|
80 |
+
6. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language, as needed.
|
81 |
+
7. Structure the answer as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
82 |
+
|
83 |
+
"""The sequence of interactions I will have with the ontology-based system to address these challenges are **[NEW METHODS]**.
|
84 |
|
85 |
Please refine my response to ensure:
|
86 |
+
|
87 |
+
1. The methods are clearly described and directly enabled by features of the ontology-based system.
|
88 |
+
2. Each method should show how the ontology-based system supports automated reasoning, semantic search, ontology alignment, or other advanced knowledge management functions.
|
89 |
+
3. All methods should logically align with my stated goals and expected improvements in managing or utilizing domain knowledge.
|
90 |
+
4. Only describe new approaches and capabilities that are possible with the ontology-based system—do not discuss previous challenges or prior manual methods.
|
91 |
+
5. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language, as best fits the context.
|
92 |
+
6. Structure the answer as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
93 |
|
94 |
+
"""The expected benefits of using the ontology-based system are [OUTCOMES].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
Please refine my response to ensure:
|
97 |
+
|
98 |
+
1. The outcomes are clearly described and directly result from using the ontology-based system.
|
99 |
+
2. The outcomes reflect benefits such as improved knowledge structuring, reasoning, semantic interoperability, or automation enabled by the ontology-based system.
|
100 |
+
3. The outcomes align logically with my overall goal for the ontology-based application.
|
101 |
+
4. Only include ontology-driven improvements—do not discuss prior methods or challenges.
|
102 |
+
5. Use *[CONCISE & PRECISE / CREATIVE & DETAILED]* language as best fits the context.
|
103 |
+
6. Structure the answer as *[BULLET POINTS / A DETAILED PARAGRAPH / TAXONOMY-LIKE HIERARCHY]*.""",
|
104 |
]
|
105 |
|
106 |
def set_openai_api_key(api_key: str):
|
|
|
125 |
{
|
126 |
"role": "assistant",
|
127 |
"content": (
|
128 |
+
"Ontology-based systems provide structured ways to manage knowledge in a domain. Ontology Requirements Engineering (ORE) ensures these systems meet user needs. Ontology engineers gather user stories by interviewing domain experts. These stories outline typical users (personas), their goals, and the scenarios where the ontology-based system provides solutions. The stories are then translated into Competency Questions (CQs), such as "Which artists have collaborated with a specific composer using this ontology-based system?" These CQs guide the system's design to answer real-world needs and improve practical use and reuse."
|
129 |
|
130 |
+
"You are an ontology engineer interviewing a domain expert to create a user story for an ontology-based system."
|
131 |
"Ask elicitation questions one at a time, providing an example answer and the prompt template the user should use, while incorporating user feedback if needed."
|
132 |
|
133 |
"If all requirements for the current elicitation are fully addressed, always ask the user if this meets their expectations. Do not ask the next question unless the user confirms the current one is satisfactory."
|
|
|
138 |
"Do not answer any queries that are not related to this task. \n\n"
|
139 |
|
140 |
"1. Persona\n"
|
141 |
+
"Begin by creating a persona—a typical user of the ontology-based system."
|
142 |
+
"[Persona]: Ask one elicitation question to the domain expert about their relevant expertise by describing [NAME], [AGE], [OCCUPATION], [SKILLS], [INTERESTS] for the ontology-based system, along with a brief example answer as guidance, and include the message 'Use template **[Create Persona]** to answer' as a reminder.\n"
|
143 |
"Once the expert provides this information, suggest possible improvements or clarifications. After all persona details are collected, move to the next section.\n\n"
|
144 |
|
145 |
"2. Goal\n"
|
146 |
+
"[User goal description]: Ask one elicitation question to the domain expert to specify the knowledge modeling objective they aim to achieve with [USER GOAL DESCRIPTION] in the ontology-based system, along with a brief example answer as guidance, and include the message 'Use template **[Create User Goal]** to answer' as a reminder.\n"
|
147 |
+
"[Actions]: Ask one elicitation question to the domain expert to outline the steps they would take for building or configuring the ontology-based system by describing [ACTIONS], along with a brief example answer as guidance, and include the message 'Use template **[Create Actions]** to answer' as a reminder.\n"
|
148 |
+
"[Keywords]: Ask one elicitation question to the domain expert to identify the key domain concepts that should be included as [KEYWORDS] within the ontology-based system, along with a brief example answer as guidance, and include the message 'Use template **[Create Keywords]** to answer' as a reminder.\n"
|
149 |
"Once the expert has answered, offer suggestions for further refinement, then proceed to the next section.\n\n"
|
150 |
|
151 |
"3. Scenario\n"
|
152 |
+
"[Scenario before]: Ask one elicitation question to the domain expert to explain their current manual methods by detailing [CURRENT METHODS] they use to achieve their goal without the ontology-based system, along with a brief example answer as guidance, and include the message 'Use template **[Create Current Methods]** to answer' as a reminder.\n"
|
153 |
+
"[Challenges]: Ask one elicitation question to the domain expert to highlight the limitations in current practices by describing [CHALLENGES] that the ontology-based system should address, along with a brief example answer as guidance, and include the message 'Use template **[Create Challenges]** to answer' as a reminder.\n"
|
154 |
+
"[Scenario during]: Ask one elicitation question to the domain expert to describe how they would interact with the ontology-based system to address challenges through [NEW METHODS], along with a brief example answer as guidance, and include the message 'Use template **[Create New Methods]** to answer' as a reminder.\n"
|
155 |
+
"[Scenario after]: Ask one elicitation question to the domain expert to describe the expected benefits from using the ontology-based system by stating [OUTCOMES], along with a brief example answer as guidance, and include the message 'Use template **[Create Outcomes]** to answer' as a reminder.\n"
|
156 |
"Provide feedback on each scenario part and refine the answers if needed before moving on."
|
157 |
|
158 |
"4. Create User Story\n"
|
159 |
"Once you have completed sections 1 to 3, summarize the information into a full user story. Use the persona, goal, and scenario information to craft the user story in this format:\n\n"
|
160 |
"Persona: [name], [age], [occupation], [skills], [interests].\n"
|
161 |
+
"Goal: [user goal description].\n"
|
162 |
+
"Actions: [Actions].\n"
|
163 |
+
"Keywords: [Keywords].\n"
|
164 |
+
"Scenario Before: [Current methods].\n"
|
165 |
+
"Challenges: [Challenges].\n"
|
166 |
+
"Scenario During: [New methods].\n"
|
167 |
+
"Scenario After: [Outcomes].\n\n"
|
168 |
"Provide the user story to the domain expert and Ask one elicitation question for any further feedback or refinements. If needed, adjust the story based on their suggestions."
|
169 |
)
|
170 |
}
|