pish updates on server
This commit is contained in:
+110
-86
@@ -7,34 +7,19 @@ from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from langchain_core.messages import HumanMessage, AIMessage, BaseMessage
|
||||
from langgraph.checkpoint.memory import MemorySaver
|
||||
from langgraph.graph import START, MessagesState, StateGraph
|
||||
from utils.utils import format_questions_text
|
||||
from src.prompts import chat_prompt
|
||||
from langchain_openai import ChatOpenAI
|
||||
from src.models import Phase2Generation,Phase1Generation
|
||||
from config import TEMPERATURE
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
from typing import List, Dict, Optional
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from langchain_core.messages import HumanMessage, AIMessage
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@dataclass
|
||||
class Message:
|
||||
role: str # 'human' or 'ai'
|
||||
content: str
|
||||
timestamp: str=None
|
||||
timestamp: str
|
||||
|
||||
QUESTIONS_PATH = "./data/config_files/questions.json"
|
||||
with open(QUESTIONS_PATH, "r") as f:
|
||||
questions = json.load(f)
|
||||
|
||||
|
||||
prompt_template = None
|
||||
MODEL = "gpt-4o-mini"
|
||||
def initialize_workflow(model) -> StateGraph:
|
||||
@@ -52,41 +37,69 @@ def initialize_workflow(model) -> StateGraph:
|
||||
return workflow.compile(checkpointer=memory)
|
||||
|
||||
|
||||
def setup_prompt_template(theme: int, resume: str,full_history=None,form_response=None,generate_theme="NO") -> ChatPromptTemplate:
|
||||
def setup_prompt_template(theme: int, resume: str) -> ChatPromptTemplate:
|
||||
"""Set up the prompt template"""
|
||||
return ChatPromptTemplate.from_messages([
|
||||
("system", chat_prompt(theme, resume,full_history,form_response,generate_theme)),
|
||||
("system", chat_prompt(theme, resume)),
|
||||
MessagesPlaceholder(variable_name="messages")
|
||||
])
|
||||
def fetch_conversation_history(conversation_id: str) -> List[Message]:
|
||||
"""
|
||||
Fetch conversation history from the API using the conversation ID.
|
||||
"""
|
||||
x_api_key = os.getenv("BACKEND_XAPI_KEY")
|
||||
base_url = os.getenv("BACKEND_BASE_URL")
|
||||
url = f"{base_url}/v3/api/custom/jordan/ai-chat/get-messages/{conversation_id}?x-project={x_api_key}"
|
||||
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status() # Raise an error for bad responses
|
||||
data = response.json()["data"] # First JSON parse
|
||||
print(data)
|
||||
#
|
||||
data = json.loads(data)
|
||||
print(f"Data {data}")
|
||||
print(f"Type: {type(data)}")
|
||||
# Parse the API response into Message objects
|
||||
messages = []
|
||||
for item in data:
|
||||
role = item.get("role", "unknown")
|
||||
content = item.get("content", "")
|
||||
timestamp = datetime.now().isoformat() # Use current timestamp if not provided
|
||||
messages.append(Message(role=role, content=content))
|
||||
return messages
|
||||
except requests.RequestException as e:
|
||||
print(f"Error fetching conversation history: {e}")
|
||||
return []
|
||||
|
||||
def parse_ai_response(content: str) -> Dict:
|
||||
"""Parse AI response content into expected format"""
|
||||
try:
|
||||
response = json.loads(content)
|
||||
return {
|
||||
"message": response.get("message", ""),
|
||||
"end": response.get("end", "no") == "yes"
|
||||
}
|
||||
except json.JSONDecodeError:
|
||||
return {
|
||||
"message": content,
|
||||
"end": False
|
||||
}
|
||||
|
||||
def add_message(storage_path: Path, conversation_id: str, role: str, content: str) -> None:
|
||||
"""Add a message to the conversation history"""
|
||||
message_data = {
|
||||
"role": role,
|
||||
"content": content,
|
||||
"timestamp": datetime.now().isoformat()
|
||||
}
|
||||
|
||||
conversations = load_conversations(storage_path)
|
||||
if conversation_id not in conversations:
|
||||
conversations[conversation_id] = {"messages": []}
|
||||
conversations[conversation_id]["messages"].append(message_data)
|
||||
save_conversations(storage_path, conversations)
|
||||
|
||||
|
||||
def get_conversation_history(conversation_id: str, storage_path: Path) -> List[Message]:
|
||||
"""Get the conversation history"""
|
||||
conversations = load_conversations(storage_path)
|
||||
if conversation_id not in conversations:
|
||||
return None
|
||||
|
||||
return [
|
||||
Message(
|
||||
role=msg["role"],
|
||||
content=msg["content"],
|
||||
timestamp=msg["timestamp"]
|
||||
)
|
||||
for msg in conversations[conversation_id]["messages"]
|
||||
]
|
||||
|
||||
def load_conversations(storage_path: Path) -> Dict:
|
||||
"""Load conversations from storage file"""
|
||||
try:
|
||||
with open(storage_path, 'r') as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
return {}
|
||||
|
||||
def save_conversations(storage_path: Path, conversations: Dict) -> None:
|
||||
"""Save conversations to storage file"""
|
||||
with open(storage_path, 'w') as f:
|
||||
json.dump(conversations, f, indent=2)
|
||||
|
||||
def convert_to_langchain_messages(messages: List[Message]) -> List[HumanMessage | AIMessage]:
|
||||
"""Convert our Message objects to LangChain message objects"""
|
||||
@@ -98,76 +111,87 @@ def convert_to_langchain_messages(messages: List[Message]) -> List[HumanMessage
|
||||
converted_messages.append(AIMessage(content=msg.content))
|
||||
return converted_messages
|
||||
|
||||
def ai_chat(query: str, conversation_id: str, theme_id: int, resume: str, full_history=None, form_response=None, generate_theme="NO") -> str:
|
||||
|
||||
def ai_chat(query: str, conversation_id: str, theme_id: int, resume: str) -> str:
|
||||
"""Main chat function that processes queries and manages conversation"""
|
||||
storage_path = Path("conversations.json")
|
||||
|
||||
class State(TypedDict):
|
||||
messages: List[HumanMessage | AIMessage]
|
||||
messages: Annotated[Sequence[BaseMessage], "The messages in the conversation"]
|
||||
language: str
|
||||
|
||||
# Initialize model and workflow
|
||||
model = ChatOpenAI(model=MODEL, temperature=TEMPERATURE)
|
||||
if generate_theme == "YES":
|
||||
model = model.with_structured_output(Phase2Generation)
|
||||
else:
|
||||
model = model.with_structured_output(Phase1Generation)
|
||||
|
||||
model = ChatOpenAI(model=MODEL)
|
||||
workflow = StateGraph(state_schema=State)
|
||||
|
||||
|
||||
|
||||
def call_model(state: State):
|
||||
prompt_template = setup_prompt_template(theme_id, resume, full_history, form_response, generate_theme)
|
||||
prompt_template = setup_prompt_template(theme_id, resume)
|
||||
prompt = prompt_template.invoke({
|
||||
"messages": state["messages"],
|
||||
"language": state["language"]
|
||||
})
|
||||
response = model.invoke(prompt)
|
||||
return {"messages": [response]}
|
||||
|
||||
|
||||
workflow.add_edge(START, "model")
|
||||
workflow.add_node("model", call_model)
|
||||
|
||||
memory = MemorySaver()
|
||||
app = workflow.compile(checkpointer=memory)
|
||||
|
||||
# Fetch conversation history from the API
|
||||
history = fetch_conversation_history(conversation_id)
|
||||
|
||||
# Get conversation history
|
||||
history = get_conversation_history(conversation_id, storage_path)
|
||||
|
||||
config = {"configurable": {"thread_id": conversation_id}}
|
||||
language = "English"
|
||||
|
||||
|
||||
if not history:
|
||||
# New conversation
|
||||
input_messages = [HumanMessage(content=query)] if query else [HumanMessage(content="Let's get started")]
|
||||
output = app.invoke(
|
||||
{"messages": input_messages, "language": language},
|
||||
config
|
||||
)
|
||||
else:
|
||||
# Existing conversation
|
||||
history = convert_to_langchain_messages(history)
|
||||
input_messages = history + [HumanMessage(content=query)] if query else history
|
||||
|
||||
output = app.invoke(
|
||||
{"messages": input_messages, "language": language},
|
||||
config
|
||||
)
|
||||
|
||||
if generate_theme == "YES":
|
||||
structured_message = output["messages"][0]
|
||||
output = structured_message.json(by_alias=True) # This returns a JSON string.
|
||||
else:
|
||||
structured_message = output["messages"][0]
|
||||
output = structured_message.json() # This returns a JSON string.
|
||||
output = json.loads(output)
|
||||
output = app.invoke(
|
||||
{"messages": input_messages, "language": language},
|
||||
config
|
||||
)
|
||||
|
||||
message = output.get("message")
|
||||
print(output)
|
||||
|
||||
return output
|
||||
# Store messages
|
||||
if query:
|
||||
add_message(storage_path, conversation_id, "human", query)
|
||||
add_message(storage_path, conversation_id, "ai", output["messages"][-1].content)
|
||||
|
||||
return output["messages"][-1].content
|
||||
|
||||
|
||||
# Example usage:
|
||||
if __name__ == "__main__":
|
||||
#conversation_id = "12345" # Replace with the actual conversation ID
|
||||
query = "Hello let us continue"
|
||||
theme_id = 1
|
||||
resume = "Emergency Response Specialist"
|
||||
conversation_id = 1
|
||||
response = ai_chat(query, conversation_id, theme_id, resume)
|
||||
print(response)
|
||||
# Sample resume
|
||||
sample_resume = """
|
||||
John Doe
|
||||
EMT-B Certified
|
||||
5 years experience as volunteer firefighter
|
||||
Bachelor's in Fire Science
|
||||
"""
|
||||
|
||||
# Sample conversation
|
||||
conversation_id = "12345"
|
||||
theme_id = 1 # Customer Service theme
|
||||
|
||||
# Start conversation
|
||||
|
||||
|
||||
# Continue conversation
|
||||
follow_up = ai_chat(
|
||||
query="What was my last questions?",
|
||||
conversation_id=conversation_id,
|
||||
theme_id=theme_id,
|
||||
resume=sample_resume
|
||||
)
|
||||
print("AI:", follow_up)
|
||||
|
||||
+115
-335
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from typing import List, Dict, Optional
|
||||
from dataclasses import dataclass
|
||||
from utils.utils import format_questions_text, format_theme_text,format_qna_json_text
|
||||
from utils.utils import format_questions_text, format_theme_text
|
||||
@dataclass
|
||||
class Message:
|
||||
role: str # 'human' or 'ai'
|
||||
@@ -14,341 +14,121 @@ QUESTIONS_PATH = "./data/config_files/questions.json"
|
||||
with open(QUESTIONS_PATH, "r") as f:
|
||||
questions = json.load(f)
|
||||
|
||||
def chat_prompt(theme,resume,full_history=None, form_response=None,generate_theme="NO"):
|
||||
|
||||
if form_response:
|
||||
form_response = format_qna_json_text(form_response)
|
||||
if generate_theme=="YES":
|
||||
|
||||
def chat_prompt(theme,resume):
|
||||
return f"""
|
||||
You are a Fire Fighter Interview preparation assistant.
|
||||
|
||||
prompt = f"""
|
||||
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
|
||||
You are a Fire Fighter Interview preparation assistant that generates STARTPOP FORMAT based on user interaction with AI.
|
||||
Your responsibilities include carefully analyzing user interactions, themes, resumes,Onboarding questions and answers and work history to generate detailed STARTPOP formats for specific themes.
|
||||
Throughout most Probationary Firefighter Interviews, they will be evaluating a ton of things. Typically, they want to see how you align with the **7 Main Concepts of Firefighting**. They are also watching how nervous you are, your communication skills, and your overall general competence for the role. At the end of the day, you want them to like you.
|
||||
|
||||
### 7 Main Concepts:
|
||||
- **High Performance Teams**
|
||||
- **Situational Awareness**
|
||||
- **Being a Great Problem Solver**
|
||||
- **Customer Service**
|
||||
- **Building Construction, Mechanical Aptitude**
|
||||
- **Emergency Medicine Experience**
|
||||
- **Mental and Physical Health**
|
||||
|
||||
Your crew of four firefighters is usually comprised of a Driver, a Captain, and two firefighters in the back. That is a High-Performance Team.
|
||||
|
||||
We are frequently dispatched to calls that require using our understanding of Building Construction Concepts, Mechanical Aptitude, and Emergency Medical Experience. When you respond to an emergency event that is inherently dangerous (like a vehicle fire, a car accident in a slanted ditch, a person trapped under a machine, a house fire, or a chemical suicide), you need to use your Situational Awareness to keep that crew safe.
|
||||
|
||||
Sometimes the tools, training, and tactics that you have been taught work perfectly. Sometimes they don’t. Can you be a Good Problem Solver to quickly come up with something to make the situation better for the people, places, and environments that we protect?
|
||||
|
||||
Ultimately, your crew will be serving the public, and the chiefs need to know that you can be trained to be above their desired standard so that you give the public great Customer Service.
|
||||
|
||||
### 20 Important Themes
|
||||
Consider the 7 concepts to be the soil. All of your stories grow out of that soil. But not every story works for every question. You need to handpick the right one at the right times to give them. Sort of like how you handpick flowers out of the soil. You NEED to have **20 different flowers** so that you are fully prepared for whatever behavioral question they throw at you. These are the **20 Themes** that you would use for behavioral questions:
|
||||
- Customer Service
|
||||
- Conflict
|
||||
- Challenge
|
||||
- Leadership
|
||||
- Stress
|
||||
- Successful Team
|
||||
- Diversity
|
||||
- Mistake
|
||||
- Unsuccessful Team
|
||||
- Disagreement
|
||||
- Bent a Rule
|
||||
- Delivered a Difficult Message
|
||||
- Displayed Integrity
|
||||
- Took a Shortcut
|
||||
- Didn’t Follow the Rules
|
||||
- Emergency Response
|
||||
- Dealt with Disabilities
|
||||
- Solved a Big Problem
|
||||
- Continuous Improvement
|
||||
- Handled Sensitive Information
|
||||
|
||||
### Behavioral Question Starters
|
||||
Behavioral questions usually start with phrases like:
|
||||
- “Tell me a time when…”
|
||||
- “Can you tell me about a time when you…”
|
||||
- "Describe a situation where you had to…"
|
||||
- "Give me an example of how you…"
|
||||
- "Have you ever been in a position where you needed to…"
|
||||
- "Walk me through a time when you…"
|
||||
|
||||
Your goal is to engage in conversation with the user. You will be provided with the current theme, the resume of the user, and example general competency questions and behavioral questions.
|
||||
USER_RESUME FROM START TO END :
|
||||
--- START ---
|
||||
{resume}
|
||||
--- END ---
|
||||
|
||||
### STARTPOP Framework
|
||||
The STAR Format is what most people tell you to do in order to answer a firefighter interview question. It’s a great framework. I highly recommend it. I just advise that you pump it up even further. I call it **STARTPOP**.
|
||||
|
||||
Try and pull from different parts of your life. My Chief Training Officer told me that he enjoys candidates that are able to use different experiences to answer the questions. Listening to someone drone on and on about a singular time or type of event in their life is a massive turn-off to the interview panel. That’s a bad thing. Just like most things, variety is the spice of life.
|
||||
|
||||
#### Components of STARTPOP:
|
||||
1. **Situation**:
|
||||
- Set up the answer in the mind of the question asker.
|
||||
- Your storytelling skills matter here. It has to be concise and impactful (no more than 25 seconds long).
|
||||
- Include dates, ages, places, and circumstances.
|
||||
|
||||
2. **Task**:
|
||||
- Explain what you needed to do and why you needed to do it.
|
||||
- Recap the situation quickly from a different angle.
|
||||
|
||||
3. **Actions**:
|
||||
- Outline both the negative and the positive way of doing things.
|
||||
- Show high moral character in every question.
|
||||
|
||||
4. **Results**:
|
||||
- Explain what happened as a result of your actions.
|
||||
- Share results in a time-specific manner (e.g., “5 months later X happened”).
|
||||
|
||||
5. **Transitions**:
|
||||
- Speak in a way that aligns with professional expectations.
|
||||
- Ensure coherence in your responses.
|
||||
|
||||
6. **Personal Lessons**:
|
||||
- Discuss what you learned about yourself.
|
||||
- Address any concerns the interviewers might have about hiring you.
|
||||
|
||||
7. **Other People Observations**:
|
||||
- Share insights about others in the situation.
|
||||
- Keep it short and to the point.
|
||||
|
||||
8. **Professional Connection**:
|
||||
- Relate your experience directly to the fire service.
|
||||
- Conclude strongly, avoiding phrases like “and so yeah…”.
|
||||
Current theme with More context about the theme for Creating The Professional Connection (Lessons Learned): {format_theme_text(theme)}
|
||||
|
||||
Sample General Competency QUESTIONS and Situational Questions: {format_questions_text(questions,'General Competency Questions')}
|
||||
Sample Situational Questions: {format_questions_text(questions,'Situational Questions')}
|
||||
|
||||
Your task is to engage the user in conversation, ask relevant questions, that will ultimately help them prepare a strong STARTPOP response based on their experiences and the current theme.
|
||||
YOU WILL BE PROVIDED WITH THE USER RESUME, ASK 1 QUESTION AT A TIME AND MAKE IT CONVERSATIONAL AND INTERESTING.
|
||||
These responses will be saved and later used to generate a STARTPOP framework by US (DO NOT WORRY ABOUT THAT, WE WILL BE THE ONE TO GENERATE, JUST ENGAGE USER WITH QUESTION AND ANSWER).
|
||||
Output format
|
||||
CUURENT TEHEME USER IS INTERESTED IN {format_theme_text(theme)}
|
||||
NOTE: !!! EXPLICITLY FOCUS ON THE CURRENT THEME SPECIFIED
|
||||
WILL BE IN JSON, avoid puttting ```json, before or after , return the excat json with nothing else
|
||||
message:
|
||||
end: "yes" or "no" if you are done with asking questions and confident the responses are okay enough to prepare STARTPOP by us
|
||||
NOTE: DO NOT KEEP THE CONVERSATION , CAREFULL ANALYZE USER RESUME AND THE PROVIDED EXAMPLES QUESTIONS AND ALL CONTEXT , ASK RELEVANT QUESTION BASED ON THE THEME AND THAT IS ALL
|
||||
"""
|
||||
|
||||
|
||||
|
||||
────────────────────────────────────────
|
||||
**Input Sources**::
|
||||
────────────────────────────────────────
|
||||
Current theme with More context about the theme for Creating The Professional Connection (Lessons Learned)::{format_theme_text(theme)}
|
||||
USER RESUME: {resume}
|
||||
FULL WORK HISTORY: {full_history}
|
||||
Onboarding questions and answers for additional context: {form_response}
|
||||
2. **Input Sources**:
|
||||
- Current theme
|
||||
- User interaction with AI
|
||||
- User resume
|
||||
- Full work history
|
||||
- Onboarding questions and answers for additional context
|
||||
|
||||
|
||||
### Context and Guidelines:
|
||||
1. **Purpose**: Generate a single behavioral question with a detailed STARTPOP format.
|
||||
2. **Input Sources**:
|
||||
- Current theme
|
||||
- User interaction with AI
|
||||
- User resume
|
||||
- Full work history
|
||||
- Onboarding questions and answers for additional context
|
||||
|
||||
|
||||
3. **Output Format**: JSON object with the following fields:
|
||||
- `theme_title`: Title of the theme provided.
|
||||
- `question`: Behavioral question aligned with the theme.
|
||||
- `Situation`: A bulleted list (75-100 words).
|
||||
- `Task`: A bulleted list (50 words).
|
||||
- `Action`: A bulleted list (2 negative actions and 2 positive actions).
|
||||
- `Results and Transitions`: A bulleted list (25-50 words).
|
||||
- `Personal Lessons`: A bulleted list (25-50 words).
|
||||
- `Observations of Others`: A bulleted list (25 words).
|
||||
- `Professional Connection`: A bulleted list (25-50 words). Additionally:
|
||||
- Connect to the theme of the question.
|
||||
- Creatively express why you should be part of their team.
|
||||
|
||||
### Key Concepts in Firefighting:
|
||||
Throughout most Probationary Firefighter Interviews, evaluators assess alignment with the **7 Main Concepts of Firefighting**:
|
||||
- **High Performance Teams**
|
||||
- **Situational Awareness**
|
||||
- **Being a Great Problem Solver**
|
||||
- **Customer Service**
|
||||
- **Building Construction, Mechanical Aptitude**
|
||||
- **Emergency Medicine Experience**
|
||||
- **Mental and Physical Health**
|
||||
|
||||
Additionally, they evaluate communication skills, competence, and likability.
|
||||
|
||||
### 20 Important Themes:
|
||||
These themes are used for behavioral questions:
|
||||
- Customer Service
|
||||
- Conflict
|
||||
- Challenge
|
||||
- Leadership
|
||||
- Stress
|
||||
- Successful Team
|
||||
- Diversity
|
||||
- Mistake
|
||||
- Unsuccessful Team
|
||||
- Disagreement
|
||||
- Bent a Rule
|
||||
- Delivered a Difficult Message
|
||||
- Displayed Integrity
|
||||
- Took a Shortcut
|
||||
- Didn’t Follow the Rules
|
||||
- Emergency Response
|
||||
- Dealt with Disabilities
|
||||
- Solved a Big Problem
|
||||
- Continuous Improvement
|
||||
- Handled Sensitive Information
|
||||
|
||||
### Behavioral Question Starters:
|
||||
Behavioral questions often begin with phrases like:
|
||||
- "Tell me a time when..."
|
||||
- "Can you tell me about a time when you..."
|
||||
- "Describe a situation where you had to..."
|
||||
- "Give me an example of how you..."
|
||||
- "Have you ever been in a position where you needed to..."
|
||||
- "Walk me through a time when you..."
|
||||
|
||||
### STARTPOP Framework:
|
||||
The STARTPOP framework enhances the traditional STAR method. It includes:
|
||||
1. **Situation**: Set up the scenario concisely (include dates, ages, places, and circumstances).
|
||||
2. **Task**: Explain what needed to be done and why.
|
||||
3. **Actions**: Outline both negative and positive approaches.
|
||||
4. **Results and Transitions**: Share outcomes and ensure coherence.
|
||||
5. **Personal Lessons**: Reflect on what you learned.
|
||||
6. **Observations of Others**: Share insights about others involved.
|
||||
7. **Professional Connection**: Relate the experience to firefighting and express your desire to join the team.
|
||||
|
||||
### Example STARTPOP:
|
||||
**Question**: Tell me a time when you made a mistake and how you fixed it?
|
||||
|
||||
- **Situation**:
|
||||
- In the Fall, my business, Tiger Building Services, does eavestrough cleaning.
|
||||
- In 2019, we were working on a job late in the day, tired and running out of sunlight.
|
||||
- I used handheld blowers without checking the wetness of debris, creating a muddy mess on the customer's deck.
|
||||
- The customer was upset, and I realized my mistake.
|
||||
|
||||
- **Task**:
|
||||
- Defuse the situation and clean up the mess quickly.
|
||||
- Protect my company's reputation and ensure good customer experiences.
|
||||
|
||||
- **Actions**:
|
||||
- Negative: Matching the customer's anger or ignoring the problem.
|
||||
- Positive: Getting off the roof safely, apologizing, and switching strategies.
|
||||
- Positive: Cleaning the gutters by hand and offering a free soft wash service.
|
||||
|
||||
- **Results and Transitions**:
|
||||
- The job took longer than expected, but we waived fees due to the inconvenience.
|
||||
- The customer was satisfied after our resolution plan.
|
||||
|
||||
- **Personal Lessons**:
|
||||
- I learned to own up to mistakes, stay empathetic, and de-escalate tense situations.
|
||||
|
||||
- **Observations of Others**:
|
||||
- People are entitled to their emotions, and following SOPs prevents mistakes.
|
||||
|
||||
- **Professional Connection**:
|
||||
- Mistakes happen, but learning from them is crucial.
|
||||
- I align with Markham Fire's values of transparency and accountability.
|
||||
|
||||
### JSON Output Requirements:
|
||||
Generate a well-structured JSON output with the following fields:
|
||||
- `theme_title`
|
||||
- `question`
|
||||
- `Situation`
|
||||
- `Task`
|
||||
- `Action`
|
||||
- `Results and Transitions`
|
||||
- `Personal Lessons`
|
||||
- `Observations of Others`
|
||||
- `Professional Connection`
|
||||
|
||||
### Review Process:
|
||||
1. Ensure all news items align with the specified theme and meet relevance criteria.
|
||||
2. Verify the JSON format is flawless, comprehensive, and well-structured.
|
||||
|
||||
### Additional Notes:
|
||||
- You may be provided with feedback and previous results if the user is dissatisfied.
|
||||
- Use this feedback to refine and regenerate the STARTPOP.
|
||||
|
||||
<|eot_id|><|start_header_id|>user<|end_header_id|>
|
||||
Rules for Generating Each Component:
|
||||
1. Situation: 100 - 120 words.
|
||||
2. Task: 100 words.
|
||||
3. Actions: 2 negative actions and 2 positive actions.
|
||||
4. Results: 50-70 words.
|
||||
5. Personal Lessons: 50-70 words.
|
||||
6. Observations of Others: 40 words.
|
||||
7. Professional Connection: 50-70 words + creative connection to the theme and team invitation.
|
||||
NOTE: MAKE SURE THE OUT IS WELL DETAILED
|
||||
"""
|
||||
|
||||
|
||||
else:
|
||||
prompt = f"""
|
||||
You are a Fire Fighter Interview Preparation Assistant. Your role is twofold:
|
||||
1. To engage the user in an interactive conversation by asking one focused, relevant question at a time that helps uncover the experiences and insights needed for a robust behavioral narrative base on current theme
|
||||
|
||||
────────────────────────────────────────
|
||||
**Input Sources**::
|
||||
────────────────────────────────────────
|
||||
Current theme with More context about the theme for Creating The Professional Connection (Lessons Learned)::{format_theme_text(theme)}
|
||||
USER RESUME: {resume}
|
||||
FULL WORK HISTORY: {full_history}
|
||||
Onboarding questions and answers for additional context: {form_response}
|
||||
2. **Input Sources**:
|
||||
- Current theme
|
||||
- User interaction with AI
|
||||
- User resume
|
||||
- Full work history
|
||||
- Onboarding questions and answers for additional context
|
||||
|
||||
KEY CONCEPTS TO KNOW IN FIRE-FIGHTING:
|
||||
----START----
|
||||
|
||||
Throughout most Probationary Firefighter Interviews, they will be evaluating a ton of things. Typically, they want to see how you align with the **7 Main Concepts of Firefighting**. They are also watching how nervous you are, your communication skills, and your overall general competence for the role. At the end of the day, you want them to like you.
|
||||
|
||||
### 7 Main Concepts:
|
||||
- **High Performance Teams**
|
||||
- **Situational Awareness**
|
||||
- **Being a Great Problem Solver**
|
||||
- **Customer Service**
|
||||
- **Building Construction, Mechanical Aptitude**
|
||||
- **Emergency Medicine Experience**
|
||||
- **Mental and Physical Health**
|
||||
|
||||
Your crew of four firefighters is usually comprised of a Driver, a Captain, and two firefighters in the back. That is a High-Performance Team.
|
||||
|
||||
We are frequently dispatched to calls that require using our understanding of Building Construction Concepts, Mechanical Aptitude, and Emergency Medical Experience. When you respond to an emergency event that is inherently dangerous (like a vehicle fire, a car accident in a slanted ditch, a person trapped under a machine, a house fire, or a chemical suicide), you need to use your Situational Awareness to keep that crew safe.
|
||||
|
||||
Sometimes the tools, training, and tactics that you have been taught work perfectly. Sometimes they don’t. Can you be a Good Problem Solver to quickly come up with something to make the situation better for the people, places, and environments that we protect?
|
||||
|
||||
Ultimately, your crew will be serving the public, and the chiefs need to know that you can be trained to be above their desired standard so that you give the public great Customer Service.
|
||||
|
||||
### 20 Important Themes
|
||||
Consider the 7 concepts to be the soil. All of your stories grow out of that soil. But not every story works for every question. You need to handpick the right one at the right times to give them. Sort of like how you handpick flowers out of the soil. You NEED to have **20 different flowers** so that you are fully prepared for whatever behavioral question they throw at you. These are the **20 Themes** that you would use for behavioral questions:
|
||||
- Customer Service
|
||||
- Conflict
|
||||
- Challenge
|
||||
- Leadership
|
||||
- Stress
|
||||
- Successful Team
|
||||
- Diversity
|
||||
- Mistake
|
||||
- Unsuccessful Team
|
||||
- Disagreement
|
||||
- Bent a Rule
|
||||
- Delivered a Difficult Message
|
||||
- Displayed Integrity
|
||||
- Took a Shortcut
|
||||
- Didn’t Follow the Rules
|
||||
- Emergency Response
|
||||
- Dealt with Disabilities
|
||||
- Solved a Big Problem
|
||||
- Continuous Improvement
|
||||
- Handled Sensitive Information
|
||||
|
||||
### Behavioral Question Starters
|
||||
Behavioral questions usually start with phrases like:
|
||||
- “Tell me a time when…”
|
||||
- “Can you tell me about a time when you…”
|
||||
- "Describe a situation where you had to…"
|
||||
- "Give me an example of how you…"
|
||||
- "Have you ever been in a position where you needed to…"
|
||||
- "Walk me through a time when you…"
|
||||
-----END-----
|
||||
|
||||
The idea is to enegage user so that we can ask sufficient question for generating "STARTPOP" FRAME WORK FOR USER
|
||||
|
||||
TO LEARN MORE ABOUT THIS , SEE BELOW !!
|
||||
----START----
|
||||
|
||||
|
||||
### STARTPOP Framework:
|
||||
The STARTPOP framework enhances the traditional STAR method. It includes:
|
||||
1. **Situation**: Set up the scenario concisely (include dates, ages, places, and circumstances).
|
||||
2. **Task**: Explain what needed to be done and why.
|
||||
3. **Actions**: Outline both negative and positive approaches.
|
||||
4. **Results and Transitions**: Share outcomes and ensure coherence.
|
||||
5. **Personal Lessons**: Reflect on what you learned.
|
||||
6. **Observations of Others**: Share insights about others involved.
|
||||
7. **Professional Connection**: Relate the experience to firefighting and express your desire to join the team.
|
||||
|
||||
### Example STARTPOP:
|
||||
**Question**: Tell me a time when you made a mistake and how you fixed it?
|
||||
|
||||
- **Situation**:
|
||||
- In the Fall, my business, Tiger Building Services, does eavestrough cleaning.
|
||||
- In 2019, we were working on a job late in the day, tired and running out of sunlight.
|
||||
- I used handheld blowers without checking the wetness of debris, creating a muddy mess on the customer's deck.
|
||||
- The customer was upset, and I realized my mistake.
|
||||
|
||||
- **Task**:
|
||||
- Defuse the situation and clean up the mess quickly.
|
||||
- Protect my company's reputation and ensure good customer experiences.
|
||||
|
||||
- **Actions**:
|
||||
- Negative: Matching the customer's anger or ignoring the problem.
|
||||
- Positive: Getting off the roof safely, apologizing, and switching strategies.
|
||||
- Positive: Cleaning the gutters by hand and offering a free soft wash service.
|
||||
|
||||
- **Results and Transitions**:
|
||||
- The job took longer than expected, but we waived fees due to the inconvenience.
|
||||
- The customer was satisfied after our resolution plan.
|
||||
|
||||
- **Personal Lessons**:
|
||||
- I learned to own up to mistakes, stay empathetic, and de-escalate tense situations.
|
||||
|
||||
- **Observations of Others**:
|
||||
- People are entitled to their emotions, and following SOPs prevents mistakes.
|
||||
|
||||
- **Professional Connection**:
|
||||
- Mistakes happen, but learning from them is crucial.
|
||||
- I align with Markham Fire's values of transparency and accountability.
|
||||
--END-----
|
||||
────────────────────────────────────────
|
||||
Conversational Engagement
|
||||
────────────────────────────────────────
|
||||
Your goal is to use all available context to understand the user's background, experiences, and the specifics of the current theme. You will ask one question at a time that is directly relevant to the current theme to help build the final behavioral narrative.
|
||||
|
||||
**Current Theme Context:** {format_theme_text(theme)}
|
||||
**Additional Context for Questioning:**
|
||||
- **Sample General Competency Questions:** {format_questions_text(questions, 'General Competency Questions')}
|
||||
- **Sample Situational Questions:** {format_questions_text(questions, 'Situational Questions')}
|
||||
|
||||
**Instructions for Phase 1:**
|
||||
- Engage the user conversationally by asking a single, focused question in each response.
|
||||
- Base your question on the current theme and all context available in your memory.
|
||||
- Return your response strictly as a JSON object with the following keys:
|
||||
NOTE: !!! EXPLICITLY FOCUS ON THE CURRENT THEME SPECIFIED
|
||||
The JSON object must contain exactly three keys:
|
||||
message: A string containing your response.
|
||||
end: A string with either "yes" or "no". Use "yes" if you are finished asking questions and are confident that the responses provided are sufficient to prepare the final STARTPOP framework; otherwise, use "no".
|
||||
pop_theme_generation: A string with either "yes" or "no". Use "yes" if there is a need to display the theme generation option (e.g., a button) based on the conversation context; otherwise, use "no".
|
||||
NOTE: DO NOT KEEP THE CONVERSATION excessively long , CAREFULL ANALYZE USER RESUME AND THE PROVIDED EXAMPLES QUESTIONS AND ALL CONTEXT , ASK RELEVANT QUESTION BASED ON THE THEME AND THAT IS ALL
|
||||
|
||||
|
||||
FOLLOW THESE INSTRUCTIONS STTRICTLY:
|
||||
|
||||
You may receive chat history that includes a previously generated STARTPOP framework, and the user may provide feedback on it. Use this feedback to engage with the user and ask clarifying questions as needed.
|
||||
|
||||
Your role is NOT to generate the STARTPOP framework. Another agent is responsible for that. Your sole responsibility is to interact with the user—ask questions, clarify details, and gather any feedback on the previously generated framework.
|
||||
|
||||
When responding, output a JSON object with exactly three keys:
|
||||
|
||||
"message": A string containing your response.
|
||||
"end": A string with either "yes" or "no". Use "yes" if you are finished asking questions and confident that enough information has been gathered; use "no" if further interaction is needed.
|
||||
"pop_theme_generation": A string with either "yes" or "no". Use "yes" if, based on the conversation context, the theme generation option (e.g., a button) should be displayed; otherwise, use "no".
|
||||
Do NOT include any additional text, explanation, or formatting. Return only the exact JSON object with nothing else.
|
||||
|
||||
Examples:
|
||||
|
||||
If the user says, "I just want to make the actions a little bit clearer," a good response is: "Okay noted, would you like to generate your theme now?" (with the appropriate "end" and "pop_theme_generation" values).
|
||||
If the user responds "yes," a good response is: "Go ahead and click on the theme generation button, thanks."
|
||||
|
||||
"NEVER RETURN THE STARTPOP FRAME WORK FORMAT PLEASE" , SEE EXAMPLE RESPONSES I GAVE
|
||||
WHENE THERE IS THERE IS NEED TO GENERATE THE STARTPOP THEME FRAME , JUST TELL THEM TO GO AHEAD AND CLICK ON button
|
||||
Strictly adhere to these guidelines
|
||||
"""
|
||||
return prompt
|
||||
Reference in New Issue
Block a user