Skip to content

Commit cbb8433

Browse files
committed
Add copyright info and Pylance fixes
1 parent 69a6f19 commit cbb8433

16 files changed

+54
-31
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
**/__pycache__/
22
venv/
3+
files/venv/
34
**/config.py
45
.DS_Store
56
data/
67
*.log
7-
*.txt
8+
*.txt

ai/generative-ai-service/hr-goal-alignment/files/Org_Chart.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import streamlit as st
23
from urllib.parse import quote, unquote
34

@@ -99,7 +100,7 @@ def create_org_chart():
99100
"""
100101

101102
# Display the chart with HTML component
102-
st.components.v1.html(html_chart, height=520, scrolling=True)
103+
st.components.v1.html(html_chart, height=520, scrolling=True) # type: ignore
103104

104105
# Show details section for selected employee
105106
# ------------------------------------------------------------
@@ -181,5 +182,5 @@ def chip_style(val):
181182
else "background-color:#f8d7da;font-weight:bold"
182183
)
183184

184-
styled = goals_pretty.style.applymap(chip_style, subset=[LABEL_COL])
185+
styled = goals_pretty.style.applymap(chip_style, subset=[LABEL_COL]) # type: ignore
185186
st.dataframe(styled, use_container_width=True, hide_index=True)

ai/generative-ai-service/hr-goal-alignment/files/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import streamlit as st
23
from pathlib import Path
34

@@ -29,4 +30,4 @@
2930

3031

3132
pg = st.navigation(pages)
32-
pg.run()
33+
pg.run()

ai/generative-ai-service/hr-goal-alignment/files/config_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
# config_template.py
23

34
# === OCI Configuration ===

ai/generative-ai-service/hr-goal-alignment/files/course_vector_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
from typing import List, Dict, Optional
23
from langchain_community.vectorstores import OracleVS
34
import os
@@ -12,6 +13,7 @@
1213
from langchain_text_splitters import RecursiveCharacterTextSplitter
1314
from langchain_community.embeddings import OCIGenAIEmbeddings
1415
from langchain_core.documents import Document
16+
from langchain_community.vectorstores.utils import DistanceStrategy
1517

1618
# Use the project's config file
1719
import config
@@ -60,7 +62,7 @@ def _initialize_vector_store(self) -> OracleVS:
6062
client=self.db_conn, # Use the connection passed in __init__
6163
embedding_function=self.embeddings, # Use the embeddings initialized in __init__
6264
table_name=config.VECTOR_TABLE_NAME, # Use table name from project config
63-
distance_strategy="COSINE"
65+
distance_strategy=DistanceStrategy.COSINE
6466
)
6567

6668
# LLM initialization removed.
@@ -167,5 +169,3 @@ def similarity_search(self, query: str, k: int = 5) -> List[Document]:
167169
except Exception as e:
168170
logger.error(f"Error during similarity search: {e}", exc_info=True)
169171
return []
170-
171-

ai/generative-ai-service/hr-goal-alignment/files/data_ingestion_courses.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import logging
23
import sys
34
import oracledb

ai/generative-ai-service/hr-goal-alignment/files/gen_ai_service/inference.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import json
23
import logging
34
import sys
@@ -65,7 +66,7 @@ def recommend_courses(profile, feedback) -> dict:
6566
except Exception as e:
6667
logger.error(f"Error during recommended_courses execution: {e}")
6768

68-
return response
69+
return response # type: ignore
6970

7071

7172

@@ -81,7 +82,7 @@ def classify_smart_goal(goal_description) -> dict:
8182
except Exception as e:
8283
logger.error(f"Error during recommended_courses execution: {e}")
8384

84-
return json.loads(response.content)
85+
return json.loads(response.content) # type: ignore
8586

8687

8788
prompt_sys = """

ai/generative-ai-service/hr-goal-alignment/files/goal_alignment_backend.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import oracledb
23
import config
34
import json
@@ -14,7 +15,7 @@
1415
model_kwargs={"temperature": 0.1, "max_tokens": 500},
1516
)
1617

17-
def query_llm(prompt_template, inputs):
18+
def query_llm(prompt_template, inputs) -> str:
1819
"""Formats prompt and calls the Oracle LLM"""
1920
if not isinstance(prompt_template, PromptTemplate):
2021
raise TypeError(" query_llm expected a PromptTemplate object.")
@@ -28,7 +29,7 @@ def query_llm(prompt_template, inputs):
2829
chain = RunnableSequence(prompt_template | llm)
2930
response = chain.invoke(inputs)
3031

31-
return response.content if isinstance(response, AIMessage) else response
32+
return response.content if isinstance(response, AIMessage) else str(response) # type: ignore
3233

3334
# --- Database Data Loading Functions ---
3435

@@ -522,6 +523,3 @@ def update_employee_goal_objective(connection, employee_id, new_objective):
522523
print("Error updating goal objective:")
523524
print(error)
524525
return "Error updating goal objective."
525-
526-
527-

ai/generative-ai-service/hr-goal-alignment/files/org_chart_backend.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import oracledb
23
import pandas as pd
34

@@ -8,13 +9,14 @@
89
connection = oracledb.connect(
910
**config.CONNECT_ARGS_VECTOR
1011
)
11-
def mapping_all_employees() -> dict[str, list[str]]:
12+
def mapping_all_employees() -> tuple[dict[str, list[str]], pd.DataFrame]:
1213
query = (
1314
"SELECT employee_id, name, role, manager_id "
1415
"FROM Employees"
1516
)
17+
df_db = pd.DataFrame() # Initialize df_db
1618
try:
17-
df_db = pd.read_sql(query, connection)
19+
df_db = pd.read_sql(query, connection) # type: ignore
1820

1921
except Exception as err:
2022
print(f"Query failed: {err}")
@@ -53,17 +55,20 @@ def check_smart_goal(df_row: pd.Series) -> str:
5355
return goal_smart.get("classification", "N/A")
5456

5557

56-
def fetch_goals_from_emp(df, emp_data) -> list[str]:
57-
df_db = None
58+
def fetch_goals_from_emp(df, emp_data) -> pd.DataFrame:
59+
df_db = pd.DataFrame() # Initialize as empty DataFrame
5860
try:
5961
emp_id = search_employee(df, emp_data)
60-
query = f"SELECT title, objective, metrics, timeline FROM Goals WHERE employee_id = '{emp_id}'"
61-
df_db = pd.read_sql(query, connection)
62+
if emp_id: # Only proceed if emp_id is found
63+
query = f"SELECT title, objective, metrics, timeline FROM Goals WHERE employee_id = '{emp_id}'"
64+
df_db = pd.read_sql(query, connection) # type: ignore
6265

6366
except oracledb.Error as err:
6467
print(f"Oracle connection error: {err}")
68+
# df_db remains an empty DataFrame if an error occurs
6569

66-
df_db["smart"] = df_db.apply(check_smart_goal, axis=1)
70+
if not df_db.empty: # Check if DataFrame is not empty before applying
71+
df_db["smart"] = df_db.apply(check_smart_goal, axis=1)
6772

6873
return df_db
6974

@@ -103,4 +108,4 @@ def check_goal_alignment(df, emp_data, manager_data):
103108
else:
104109
vertical = None
105110

106-
return vertical, horizontal
111+
return vertical, horizontal

ai/generative-ai-service/hr-goal-alignment/files/pages/course_recommendation_chatbot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
12
import streamlit as st
23
import logging
34
import oracledb

0 commit comments

Comments
 (0)