1hangzhao commited on
Commit
9be9f46
·
verified ·
1 Parent(s): a66d732

Update ontochat/functions.py

Browse files
Files changed (1) hide show
  1. ontochat/functions.py +52 -48
ontochat/functions.py CHANGED
@@ -8,14 +8,14 @@ openai_api_key = None
8
 
9
  current_preidentified_prompts = []
10
  current_preidentified = [
11
- "My name is [Name], I am [Age] years old, and I work as a [Occupation]. My skills include [skills], and I have a strong interest in [interests]. Could you assist me in refining and expanding my skills and interests, ensuring they are aligned with my occupation?",
12
- "My user goal description is [user goal description]. Can you help me refine this goal, without changing the actions or keywords, and ensure it aligns with my interests and domain?",
13
- "The actions I need to take to achieve my goal are [actions]. Can you help me expand these actions, ensuring they align with my occupation and skills, without changing the goal description or keywords?",
14
- "The keywords for my user goal and actions are [keywords]. Can you help me refine these keywords, ensuring they are relevant to my goal and actions, without changing the goal or actions themselves?",
15
- "The current methods I use to perform my actions are [current methods]. Can you help me elaborate on these methods, ensuring they align with my occupation, skills, and goal, without changing the challenges, new methods, or outcomes?",
16
- "The challenges I face with my current methods are [challenges]. Can you help me expand on these challenges, ensuring they logically relate to my skills and goal, without changing the current methods, new methods, or outcomes?",
17
- "The new methods I will use through this ontology to address my challenges are [new methods]. Can you help me elaborate on these new methods, ensuring they align with my occupation, skills, and goal, without changing the current methods, challenges, or outcomes?",
18
- "The outcomes I expect after implementing the new methods are [outcomes]. Can you help me refine these outcomes, ensuring they address the challenges and benefit my goal, without changing the current methods, challenges, or new methods?"
19
  ]
20
 
21
  def load_example(selection):
@@ -41,55 +41,59 @@ def check_api_key():
41
  def user_story_generator(message, history):
42
  instructions = [
43
  {
44
- "role": "system",
45
- "content":
46
- "Ontology construction involves creating structured frameworks to represent knowledge in a specific domain. Ontology Requirements Engineering (ORE) ensures these frameworks align with user needs by having ontology engineers conduct interviews with domain experts to gather user stories. These stories outline typical users (personas), their goals, and scenarios where the ontology provides solutions. They are then translated into Competency Questions (CQs), such as 'Which artists have collaborated with a specific composer?', guiding the ontology's design to address real-world queries and enhance its practical use and reuse."
47
-
48
- "You are an ontology engineer conducting an interview with a domain expert to gather information for writing an ontology user story. Follow the instructions below, asking one elicitation question each time and explain in one sentence on how to answer it, answering domain expert queries when needed."
49
- "If all requirements for the current elicitation are fully addressed, always ask the user if they need any further modifications or we can moving forward. Do not ask the next question unless the user confirms the current one is satisfactory or explicitly says to proceed."
50
- "When a domain expert requests expansion, provide just one focused point in one sentence, directly aligned with their current answer."
51
- "If the user's answer doesn't address the current question, gently remind them of the question and prompt them to respond accordingly."
52
- "If the user doesn't confirm the current result is satisfactory or request to move on, their attempt to answer the next question should be rejected, and they should be asked to respond to the current one."
53
- "Do not answer any queries that are not related to this task. \n\n"
54
-
55
- "1. Persona\n"
56
- "Start by creating a persona that represents a typical user of your ontology. Ask one elicitation question for details includes [name], [age], [occupation], [skills], and [interests].\n"
57
- "Once the expert provides this information, suggest possible improvements or clarifications. After all persona details are collected, move to the next section.\n\n"
58
-
59
- "2. Goal\n"
60
- "Ask one elicitation question for a description of the [user goal], explaining what the persona wants to achieve using your ontology. Ensure that it aligns with their skills and occupation.\n"
61
- "Ask one elicitation question for the specific [actions] the persona will take to accomplish the goal and ask one elicitation question for gathering up to 5 relevant [keywords] that summarize the goal and actions.\n"
62
- "Once the expert has answered, offer suggestions for further refinement, then proceed to the next section.\n\n"
63
-
64
- "3. Scenario\n"
65
- "[Scenario before]: Ask one elicitation question for the expert to describe the [current methods] the persona uses to perform the actions. Ask one elicitation question for the [challenges] they face when performing current methods, making sure these align with the persona's occupation and skills.\n"
66
- "[Scenario during]: Ask one elicitation question for the expert to explain how their ontology introduces [new methods] to help them overcome these challenges, ensuring the methods are relevant to their role.\n"
67
- "[Scenario after]: Ask one elicitation question for the expert to describe the [outcomes] after using the ontology and how it helps them achieve their goal.\n"
68
- "Provide feedback on each scenario part and refine the answers if needed before moving on."
69
-
70
- "4. Create User Story\n"
71
- "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"
72
- "Persona: [name], [age], [occupation], [skills], [interests].\n"
73
- "Goal: [user goal description], with actions such as [actions]. Keywords: [keywords].\n"
74
- "Scenario Before: [current methods] the persona uses and the [challenges] they face.\n"
75
- "Scenario During: How your ontology introduces [new methods] to overcome these challenges.\n"
76
- "Scenario After: The [outcomes] achieved by using the ontology and how the persona's goal has been accomplished.\n\n"
77
- "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."
 
 
 
78
  }
79
  ]
80
  messages = build_messages(history)
81
- messages.append({
82
- "role": "user",
83
- "content": message
84
- })
85
  bot_message = chat_completion(openai_api_key, instructions + messages)
86
- history.append([message, bot_message])
 
 
 
87
  return history, ""
88
 
89
  def cq_generator(message, history):
90
  check_api_key()
91
  instructions = [{
92
- "role": "system",
93
  "content": "You are a conversational ontology engineering assistant."
94
  }, {
95
  "role": "user",
 
8
 
9
  current_preidentified_prompts = []
10
  current_preidentified = [
11
+ "My name is **[NAME]**, I am **[AGE]** years old, and I work as a **[OCCUPATION]**. My skills include **[SKILLS]**, and I have a strong interest in **[INTERESTS]**. Can you help me refine my answers to ensure: 1. Each detail is clearly described, specific, and easy to understand, avoiding vague or overly broad statements. 2. The details (name, age, occupation, skills, interests) are logically and professionally aligned to showcase a cohesive and relevant persona. 3. The refined skills and interests highlight areas of expertise and enthusiasm directly connected to my occupation and goals. 4. The language is polished, concise, and written in a professional tone suitable for formal contexts. 5. The refined output is structured in a clear, well-organized bullet-point format for easy readability and usability.",
12
+ "My user goal description is **[USER GOAL DESCRIPTION]**. Can you help me refine my answer to ensure: 1. The goal is clearly articulated, specific, and easy to understand, avoiding ambiguity or overly broad statements. 2. The description is aligned with my interests, domain expertise, and intended purpose, showcasing its relevance to my context. 3. The focus remains solely on the goal, without referencing or including actions, keywords, or unrelated details. 4. The refined description highlights the significance of the goal and its practical value within my domain. 5. The language is polished, concise, and professionally written, suitable for formal contexts. 6. The original intent and relevance of the goal are preserved without altering its meaning or purpose. 7. The final refined answer is presented in a single, clear, and well-crafted sentence.",
13
+ "The actions I need to take to achieve my goal are **[ACTIONS]**. Can you help me refine my answer to ensure: 1. The actions are clearly described and actionable, detailing specific steps or processes. 2. They align logically with my skills, expertise, and overall goal, showcasing their relevance and practicality. 3. Each action is specific enough to illustrate its purpose but adaptable enough to apply to varying scenarios. 4. The description avoids redundancy and focuses solely on the actions without referencing unrelated elements. 5. The language is concise, precise, and written in a professional tone. 6. The final refined answer is presented as a single, polished, and well-crafted sentence.",
14
+ "The keywords for my user goal and actions are **[KEYWORDS]**. Can you help me refine these keywords to ensure: 1. They are clearly articulated, specific, and easy to understand, avoiding vague or overly broad terms. 2. Each keyword is highly relevant and directly connected to my goal and actions, reflecting their significance. 3. The list is free of unnecessary or redundant keywords, focusing on terms with high practical value. 4. The language is concise, precise, and aligned with the professional context of my domain. 5. The refined list includes at most 5 keywords, presented in a clear, structured, and organized manner.",
15
+ "The current methods I use to perform my actions are **[CURRENT METHODS]**. Can you help me refine these methods to ensure: 1. They are clearly described and actionable, reflecting accurate steps or processes. 2. They align with my occupation, skills, and overall goal. 3. The language is concise, precise, and free from unnecessary details. 4. The focus is solely on the current methods, without including challenges, new methods, or outcomes. 5. The final refined answer is presented as a single, well-crafted sentence.",
16
+ "The challenges I face with my current methods are **[CHALLENGES]**. Can you help me refine these challenges to ensure: 1. They are realistic and grounded in the context of my current methods. 2. Each challenge is clearly articulated and highlights specific obstacles or difficulties I encounter. 3. They logically relate to my skills, occupation, and overall goal, providing insight into areas that need improvement. 4. The challenges are actionable, meaning they identify issues that can be realistically addressed or mitigated. 5. The language is concise and professional, focusing only on the challenges without referencing or altering the current methods, new methods, or outcomes. 6. The final refined answer is presented as a single, well-crafted sentence.",
17
+ "The new methods I will use through this ontology to address my challenges are **[NEW METHODS]**. Can you help me refine these new methods to ensure: 1. They are clearly described and actionable, demonstrating how they address the specified challenges. 2. They logically align with my occupation, skills, and overall goal, showcasing their relevance and practicality. 3. The refined methods focus solely on new approaches, without referencing or altering the current methods, challenges, or outcomes. 4. Each method is specific enough to illustrate its purpose but general enough to allow flexibility in implementation. 5. The language is concise, precise, and professionally written. 6. The final refined answer is presented as a single, well-crafted sentence.",
18
+ "The outcomes I expect after implementing the new methods are **[OUTCOMES]**. Can you help me refine these outcomes to ensure: 1. They are clearly described and measurable, showing the direct results of addressing the specified challenges. 2. They align logically with my occupation, skills, and overall goal, demonstrating tangible benefits or improvements. 3. The refined outcomes focus solely on the results, without altering or referencing the current methods, challenges, or new methods. 4. Each outcome is specific enough to highlight its value but general enough to apply across relevant scenarios. 5. The language is concise, precise, and professionally articulated. 6. The final refined answer is presented as a single, well-crafted sentence."
19
  ]
20
 
21
  def load_example(selection):
 
41
  def user_story_generator(message, history):
42
  instructions = [
43
  {
44
+ "role": "assistant",
45
+ "content": (
46
+ "Ontology construction involves creating structured frameworks to represent knowledge in a specific domain. Ontology Requirements Engineering (ORE) ensures these frameworks align with user needs by having ontology engineers conduct interviews with domain experts to gather user stories. These stories outline typical users (personas), their goals, and scenarios where the ontology provides solutions. They are then translated into Competency Questions (CQs), such as 'Which artists have collaborated with a specific composer?', guiding the ontology's design to address real-world queries and enhance its practical use and reuse."
47
+
48
+ "You are an ontology engineer conducting an interview with a domain expert to gather information for writing an ontology user story. Follow the instructions below, asking one elicitation question at a time and provide a brief explanation in one sentence on how to answer it, along with an example answer for reference, answering domain expert queries when needed."
49
+ "If all requirements for the current elicitation are fully addressed, always ask the user if they need any further modifications or we can moving forward. Do not ask the next question unless the user confirms the current one is satisfactory or explicitly says to proceed."
50
+ "When a domain expert requests expansion, provide just one focused point in one sentence, directly aligned with their current answer."
51
+ "If the user's answer doesn't address the current question, gently remind them of the question and prompt them to respond accordingly."
52
+ "If the user doesn't confirm the current result is satisfactory or request to move on, their attempt to answer the next question should be rejected, and they should be asked to respond to the current one."
53
+ "Do not answer any queries that are not related to this task. \n\n"
54
+
55
+ "1. Persona\n"
56
+ "Start by creating a persona that represents a typical user of your ontology. Ask one elicitation question for details includes [name], [age], [occupation], [skills], and [interests].\n"
57
+ "Once the expert provides this information, suggest possible improvements or clarifications. After all persona details are collected, move to the next section.\n\n"
58
+
59
+ "2. Goal\n"
60
+ "[User goal description]: Ask one elicitation question for a description of the [user goal description], explaining what the persona wants to achieve using your ontology. Ensure that it aligns with their skills and occupation. Mention '[user goal description]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
61
+ "[Actions]: Ask one elicitation question for the specific [actions] the persona will take to accomplish the goal. Mention '[actions]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
62
+ "[Keywords]: Ask one elicitation question for gathering up to 5 relevant [keywords] that summarize the goal and actions. Mention '[keywords]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
63
+ "Once the expert has answered, offer suggestions for further refinement, then proceed to the next section.\n\n"
64
+
65
+ "3. Scenario\n"
66
+ "[Scenario before]: Ask one elicitation question for the expert to describe the [current methods] the persona uses to perform the actions. Mention '[current methods]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
67
+ "[Challenges]: Ask one elicitation question for the [challenges] they face when performing current methods, making sure these align with the persona's occupation and skills. Mention '[challenges]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
68
+ "[Scenario during]: Ask one elicitation question for the expert to explain how their ontology introduces [new methods] to help them overcome these challenges, ensuring the methods are relevant to their role. Mention '[new methods]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
69
+ "[Scenario after]: Ask one elicitation question for the expert to describe the [outcomes] after using the ontology and how it helps them achieve their goal. Mention '[outcomes]' in question for user reference, and provide a brief explanation along with the question in one sentence on how to answer it, along with an example answer for reference.\n"
70
+ "Provide feedback on each scenario part and refine the answers if needed before moving on."
71
+
72
+ "4. Create User Story\n"
73
+ "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"
74
+ "Persona: [name], [age], [occupation], [skills], [interests].\n"
75
+ "Goal: [user goal description], with actions such as [actions]. Keywords: [keywords].\n"
76
+ "Scenario Before: [current methods] the persona uses and the [challenges] they face.\n"
77
+ "Scenario During: How your ontology introduces [new methods] to overcome these challenges.\n"
78
+ "Scenario After: The [outcomes] achieved by using the ontology and how the persona's goal has been accomplished.\n\n"
79
+ "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."
80
+ )
81
  }
82
  ]
83
  messages = build_messages(history)
84
+ messages.append({"role": "user", "content": message})
85
+
 
 
86
  bot_message = chat_completion(openai_api_key, instructions + messages)
87
+
88
+ history.append({"role": "user", "content": message})
89
+ history.append({"role": "assistant", "content": bot_message})
90
+
91
  return history, ""
92
 
93
  def cq_generator(message, history):
94
  check_api_key()
95
  instructions = [{
96
+ "role": "assistant",
97
  "content": "You are a conversational ontology engineering assistant."
98
  }, {
99
  "role": "user",