LeoWalker commited on
Commit
419fcc8
·
1 Parent(s): b43cf6c

first node is working!

Browse files
README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ ## HypePack
3
+
4
+ A Python package for developing your own hype session with AI to motivate you to work on your goals.
hype_pack/api/__init__.py ADDED
File without changes
hype_pack/hype_agent.py CHANGED
@@ -1,27 +1,29 @@
1
- from utils.state import State
2
- from utils.tools import read_pdf
 
3
 
4
- def upload_documents(pdf_path: str, personal_history_text: str, aspiring_position_text: str) -> State:
5
- """
6
- Uploads documents and updates the state with focus points.
7
-
8
- Args:
9
- - pdf_path (str): Path to the PDF file.
10
- - personal_history_text (str): Free text input for personal history.
11
- - aspiring_position_text (str): Free text input for aspiring position.
12
-
13
- Returns:
14
- - State: Updated state with focus points.
15
- """
16
- # Read PDF and create a new state instance
17
- pdf_text = read_pdf(pdf_path)
18
-
19
- # Create a new State instance with the gathered data
20
- state = State(
21
- personal_history_focus_points=pdf_text + personal_history_text,
22
- aspiring_position_focus_points=aspiring_position_text
23
- )
24
-
25
- # Here you would add logic to generate focus points from the text
26
- # For now, we just return the state
27
- return state
 
 
1
+ from hype_pack.utils.state import InterviewState
2
+ from hype_pack.utils.nodes import build_reference_material_node
3
+ from hype_pack.utils.state import InitialInput
4
 
5
+ def hype_agent(initial_input: InitialInput) -> InterviewState:
6
+ interview_state = InterviewState(user_inital_input=initial_input)
7
+ interview_state = build_reference_material_node(interview_state)
8
+ return interview_state
9
+
10
+ if __name__ == "__main__":
11
+ initial_input = InitialInput(
12
+ resume_text=(
13
+ "John Doe\n"
14
+ "Experienced data scientist with expertise in machine learning, data analysis, and business intelligence.\n"
15
+ ),
16
+ personal_text="Seeking to transition into a leadership role within the AI/ML domain.",
17
+ job_text=(
18
+ "Role: Senior Data Scientist\n"
19
+ "Responsibilities:\n"
20
+ "- Develop machine learning models to enhance product recommendations.\n"
21
+ "- Lead data science team to design experiments and analyze data.\n"
22
+ "- Communicate findings to stakeholders using dashboards and reports.\n"
23
+ "Requirements:\n"
24
+ "- 8+ years experience in data science or related fields.\n"
25
+ "- Proficiency in Python, SQL, and visualization tools like Power BI or Tableau.\n"
26
+ "- Experience with leadership and team management."
27
+ )
28
+ )
29
+ hype_agent(initial_input)
hype_pack/tests/test_reference_material_node.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from hype_pack.utils.state import InterviewState, InitialInput, ReferenceMaterial
2
+ from hype_pack.utils.nodes import build_reference_material_node # Import the function to be tested
3
+
4
+ # Define the initial input for the interview
5
+ initial_input = InitialInput(
6
+ resume_text=(
7
+ "John Doe\n"
8
+ "Experienced data scientist with expertise in machine learning, data analysis, and business intelligence.\n"
9
+ "10+ years experience in Python, SQL, and Tableau. Developed predictive models improving operational efficiency by 25%.\n"
10
+ "Education: MSc in Data Science from XYZ University."
11
+ ),
12
+ personal_text="Seeking to transition into a leadership role within the AI/ML domain.",
13
+ job_text=(
14
+ "Role: Senior Data Scientist\n"
15
+ "Responsibilities:\n"
16
+ "- Develop machine learning models to enhance product recommendations.\n"
17
+ "- Lead data science team to design experiments and analyze data.\n"
18
+ "- Communicate findings to stakeholders using dashboards and reports.\n"
19
+ "Requirements:\n"
20
+ "- 8+ years experience in data science or related fields.\n"
21
+ "- Proficiency in Python, SQL, and visualization tools like Power BI or Tableau.\n"
22
+ "- Experience with leadership and team management."
23
+ )
24
+ )
25
+
26
+ # Create an empty reference material object
27
+ empty_reference_material = ReferenceMaterial()
28
+
29
+ # Create the interview state with the provided initial input
30
+ interview_state = InterviewState(
31
+ user_inital_input=initial_input,
32
+ reference_material=empty_reference_material
33
+ )
34
+
35
+ # Now this `interview_state` can be used to test the function.
36
+ updated_state = build_reference_material_node(interview_state)
37
+
38
+ # Output the updated state for inspection
39
+ print(updated_state.reference_material)
40
+
41
+ # Add assertions to verify the expected behavior
42
+ assert updated_state.reference_material is not None, "Reference material should not be None"
43
+ # Add more specific assertions based on expected structure and content of reference_material
hype_pack/utils/nodes.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_openai import ChatOpenAI
2
+ from langchain.prompts import ChatPromptTemplate
3
+ from hype_pack.utils.state import InterviewState, ReferenceMaterial
4
+
5
+ def build_reference_material_node(interview_state: InterviewState) -> InterviewState:
6
+ """
7
+ Analyzes candidate background and job requirements to generate structured reference material.
8
+ """
9
+ print(f"Start State: {interview_state}")
10
+ print(f"\n\n")
11
+
12
+ # Initialize the LLM with structured output
13
+ llm = ChatOpenAI(
14
+ model="gpt-4o-mini",
15
+ temperature=0.1
16
+ ).with_structured_output(ReferenceMaterial)
17
+
18
+ # Create a simple prompt
19
+ prompt = ChatPromptTemplate.from_messages([
20
+ ("system", "You are an expert career analyst. Analyze the provided information to generate a structured analysis."),
21
+ ("human", """
22
+ Resume: {resume}
23
+ Personal Info: {personal}
24
+ Job Description: {job}
25
+ """)
26
+ ])
27
+
28
+ # Get structured output directly
29
+ reference_material = llm.invoke(prompt.format_messages(
30
+ resume=interview_state.user_inital_input.resume_text,
31
+ personal=interview_state.user_inital_input.personal_text or "",
32
+ job=interview_state.user_inital_input.job_text or ""
33
+ ))
34
+ print(reference_material)
35
+ # Convert ReferenceMaterial instance to a dictionary if needed
36
+ if isinstance(reference_material, ReferenceMaterial):
37
+ reference_material = reference_material.model_dump()
38
+
39
+ # Update state with reference material only
40
+ interview_state.reference_material = reference_material
41
+ print(f"EndState: {interview_state.reference_material}")
42
+
43
+ return interview_state
hype_pack/utils/state.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import List, Optional
3
+
4
+ class ReferenceMaterial(BaseModel):
5
+ """Structured analysis of candidate background and target position."""
6
+
7
+ personal_history_summary: str = Field(
8
+ description="Summary of candidate's career background and key achievements"
9
+ )
10
+
11
+ aspiring_position_summary: str = Field(
12
+ description="Overview of the target role and its key requirements"
13
+ )
14
+
15
+ personal_focus_points: List[str] = Field(
16
+ default_factory=list,
17
+ description="Key points highlighting candidate's relevant experiences and skills"
18
+ )
19
+
20
+ aspiring_position_focus_points: List[str] = Field(
21
+ default_factory=list,
22
+ description="Essential requirements and expectations of the target role"
23
+ )
24
+
25
+ class QAPair(BaseModel):
26
+ """Individual question-answer interaction during the interview process."""
27
+
28
+ question_id: int = Field(description="Unique identifier for the Q&A pair")
29
+ question: str = Field(description="The question asked")
30
+ answer: Optional[str] = Field(default=None, description="The generated or provided answer")
31
+
32
+ class InitialInput(BaseModel):
33
+ """Raw input from the user."""
34
+ resume_text: str = Field(default="", description="Raw text extracted from the resume")
35
+ personal_text: Optional[str] = Field(default=None, description="Additional personal information provided by the user")
36
+ job_text: Optional[str] = Field(default=None, description="Job description or position-related text")
37
+
38
+ class InterviewState(BaseModel):
39
+ """Current state of the interview process."""
40
+ user_inital_input: InitialInput
41
+ reference_material: Optional[ReferenceMaterial] = None
42
+ qa_history: List[QAPair] = Field(default_factory=list)
43
+ message_history: List[str] = Field(default_factory=list) # Consider using specific message types if applicable
44
+ transcript: str = Field(default="", description="Generated podcast transcript as a single string")
hype_pack/utils/tools.py ADDED
File without changes