Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import os
|
2 |
import glob
|
3 |
from pathlib import Path
|
4 |
from typing import List
|
@@ -24,6 +24,61 @@ print("Loaded OPENAI_API_KEY:", OPENAI_API_KEY[:6] + "..." if OPENAI_API_KEY els
|
|
24 |
# Initialize OpenAI client
|
25 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Initialize Pinecone (us-east-1)
|
28 |
def init_pinecone(index_name: str):
|
29 |
pc = Pinecone(api_key=PINECONE_API_KEY)
|
@@ -34,7 +89,7 @@ def init_pinecone(index_name: str):
|
|
34 |
metric="cosine",
|
35 |
spec=ServerlessSpec(
|
36 |
cloud="aws",
|
37 |
-
region="us-east-1"
|
38 |
)
|
39 |
)
|
40 |
return pc.Index(index_name)
|
@@ -100,72 +155,13 @@ if __name__ == "__main__":
|
|
100 |
|
101 |
categories = sorted(set(Path(p).parts[0] for p in glob.glob('*/*.txt')) | set(recommended.keys()) - {"all"})
|
102 |
|
103 |
-
recommended = {
|
104 |
-
"all": [
|
105 |
-
"Where can I find benefits information?",
|
106 |
-
"How do I request time off?",
|
107 |
-
"What is TechScheme and how does it work?",
|
108 |
-
"What is chalet time?",
|
109 |
-
],
|
110 |
-
"benefits": [
|
111 |
-
"What does private medical insurance cover?",
|
112 |
-
"How do I join the pension scheme?",
|
113 |
-
"What is TechScheme and how does it work?",
|
114 |
-
"What is the maximum amount I can apply for under the Cycle to Work scheme?",
|
115 |
-
"How do I request a flexible working pattern?",
|
116 |
-
"How do I apply for Help to Buy Tech through TechScheme?",
|
117 |
-
"Can I increase or decrease my pension contributions?",
|
118 |
-
"When are Winter and Summer company parties held?",
|
119 |
-
|
120 |
-
],
|
121 |
-
"company": [
|
122 |
-
"What is the company's mission?",
|
123 |
-
"What values guide the work and culture at Made Tech?",
|
124 |
-
"What is Made Tech's purpose?",
|
125 |
-
"What is the role of a peer buddy in the onboarding process?",
|
126 |
-
"What policies should I read as a new employee?",
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
],
|
131 |
-
"guides": [
|
132 |
-
"How do I submit an expense?",
|
133 |
-
"Where is the hiring policy?",
|
134 |
-
"What is chalet time?",
|
135 |
-
"What accounts and tools are introduced during onboarding?",
|
136 |
-
"Will I receive a laptop before my first day?",
|
137 |
-
"What is Chalet Time? What are the priorities for using Chalet Time?",
|
138 |
-
|
139 |
-
"What should I do if I am planning to relocate?",
|
140 |
-
"How can I contribute to the handbook?",
|
141 |
-
],
|
142 |
-
"roles": [
|
143 |
-
"What does a data scientist do?",
|
144 |
-
"What is the duration of the Software Engineering Academy at Made Tech?",
|
145 |
-
"How do career levels work?",
|
146 |
-
"What types of needs does an Associate Product Manager explore in their role?",
|
147 |
-
"How are success criteria and measurable outcomes defined?",
|
148 |
-
"What are the responsibilities of a Delivery Support Analyst in PMO?",
|
149 |
-
"How do Delivery Directors contribute to Made Tech's commercial growth?",
|
150 |
-
"What are some key outcomes expected from a Delivery Director?",
|
151 |
-
],
|
152 |
-
"communities-of-practice": [
|
153 |
-
"How can I join a community of practice?",
|
154 |
-
"What is the purpose of the Book Club at Made Tech?",
|
155 |
-
"How often does the Book Club meet?",
|
156 |
-
"What is the EDGE approach to digital transformation?",
|
157 |
-
"How can I join the Book Club meetings?",
|
158 |
-
"When do CoPs meet?",
|
159 |
-
],
|
160 |
-
}
|
161 |
-
|
162 |
with gr.Blocks() as demo:
|
163 |
-
with gr.Row():
|
164 |
-
logo_path = Path(__file__).resolve().parent / "logo.jpeg"
|
165 |
-
logo_value = str(logo_path) if logo_path.exists() else None
|
166 |
-
gr.Image(value=logo_value, width=170, height=170, show_label=False)
|
167 |
-
gr.Markdown("<h1 style='text-align: center; width:100%'>HR Chatbot</h1>")
|
168 |
selected_category = gr.State("all")
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
with gr.Row():
|
171 |
category_buttons = []
|
|
|
1 |
+
import os
|
2 |
import glob
|
3 |
from pathlib import Path
|
4 |
from typing import List
|
|
|
24 |
# Initialize OpenAI client
|
25 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
26 |
|
27 |
+
# ✅ Define recommended questions before using them
|
28 |
+
recommended = {
|
29 |
+
"all": [
|
30 |
+
"Where can I find benefits information?",
|
31 |
+
"How do I request time off?",
|
32 |
+
"What is TechScheme and how does it work?",
|
33 |
+
"What is chalet time?",
|
34 |
+
],
|
35 |
+
"benefits": [
|
36 |
+
"What does private medical insurance cover?",
|
37 |
+
"How do I join the pension scheme?",
|
38 |
+
"What is TechScheme and how does it work?",
|
39 |
+
"What is the maximum amount I can apply for under the Cycle to Work scheme?",
|
40 |
+
"How do I request a flexible working pattern?",
|
41 |
+
"How do I apply for Help to Buy Tech through TechScheme?",
|
42 |
+
"Can I increase or decrease my pension contributions?",
|
43 |
+
"When are Winter and Summer company parties held?",
|
44 |
+
],
|
45 |
+
"company": [
|
46 |
+
"What is the company's mission?",
|
47 |
+
"What values guide the work and culture at Made Tech?",
|
48 |
+
"What is Made Tech's purpose?",
|
49 |
+
"What is the role of a peer buddy in the onboarding process?",
|
50 |
+
"What policies should I read as a new employee?",
|
51 |
+
],
|
52 |
+
"guides": [
|
53 |
+
"How do I submit an expense?",
|
54 |
+
"Where is the hiring policy?",
|
55 |
+
"What is chalet time?",
|
56 |
+
"What accounts and tools are introduced during onboarding?",
|
57 |
+
"Will I receive a laptop before my first day?",
|
58 |
+
"What is Chalet Time? What are the priorities for using Chalet Time?",
|
59 |
+
"What should I do if I am planning to relocate?",
|
60 |
+
"How can I contribute to the handbook?",
|
61 |
+
],
|
62 |
+
"roles": [
|
63 |
+
"What does a data scientist do?",
|
64 |
+
"What is the duration of the Software Engineering Academy at Made Tech?",
|
65 |
+
"How do career levels work?",
|
66 |
+
"What types of needs does an Associate Product Manager explore in their role?",
|
67 |
+
"How are success criteria and measurable outcomes defined?",
|
68 |
+
"What are the responsibilities of a Delivery Support Analyst in PMO?",
|
69 |
+
"How do Delivery Directors contribute to Made Tech's commercial growth?",
|
70 |
+
"What are some key outcomes expected from a Delivery Director?",
|
71 |
+
],
|
72 |
+
"communities-of-practice": [
|
73 |
+
"How can I join a community of practice?",
|
74 |
+
"What is the purpose of the Book Club at Made Tech?",
|
75 |
+
"How often does the Book Club meet?",
|
76 |
+
"What is the EDGE approach to digital transformation?",
|
77 |
+
"How can I join the Book Club meetings?",
|
78 |
+
"When do CoPs meet?",
|
79 |
+
],
|
80 |
+
}
|
81 |
+
|
82 |
# Initialize Pinecone (us-east-1)
|
83 |
def init_pinecone(index_name: str):
|
84 |
pc = Pinecone(api_key=PINECONE_API_KEY)
|
|
|
89 |
metric="cosine",
|
90 |
spec=ServerlessSpec(
|
91 |
cloud="aws",
|
92 |
+
region="us-east-1"
|
93 |
)
|
94 |
)
|
95 |
return pc.Index(index_name)
|
|
|
155 |
|
156 |
categories = sorted(set(Path(p).parts[0] for p in glob.glob('*/*.txt')) | set(recommended.keys()) - {"all"})
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
159 |
selected_category = gr.State("all")
|
160 |
+
with gr.Row():
|
161 |
+
banner_path = Path(__file__).resolve().parent / "bannerhr.png"
|
162 |
+
banner_value = str(banner_path) if banner_path.exists() else None
|
163 |
+
gr.Image(value=banner_value, show_label=False, show_download_button=False)
|
164 |
+
|
165 |
|
166 |
with gr.Row():
|
167 |
category_buttons = []
|