decodingdatascience commited on
Commit
04cc8e2
·
verified ·
1 Parent(s): 64d1ae0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -17
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # DDS Enterprise HR Chatbot
2
  # Hugging Face Spaces app.py
3
 
4
  import logging
@@ -33,7 +33,6 @@ logger = logging.getLogger("dds-hr-enterprise")
33
  # ---------------------------------------------------------
34
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
35
  PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
36
-
37
  if not OPENAI_API_KEY:
38
  raise ValueError("OPENAI_API_KEY is missing from Hugging Face Secrets.")
39
 
@@ -150,7 +149,7 @@ else:
150
 
151
 
152
  # ---------------------------------------------------------
153
- # 7. Shared HR query engine
154
  # ---------------------------------------------------------
155
  query_engine = index.as_query_engine(
156
  system_prompt=SYSTEM_PROMPT,
@@ -159,7 +158,7 @@ query_engine = index.as_query_engine(
159
 
160
 
161
  def query_doc(prompt: str) -> str:
162
- """Single HR answering function used by the web UI and API clients."""
163
  if not prompt or not prompt.strip():
164
  return "Please enter an HR policy question."
165
 
@@ -173,18 +172,8 @@ def query_doc(prompt: str) -> str:
173
 
174
 
175
  # ---------------------------------------------------------
176
- # 8. Gradio web app + API
177
  # ---------------------------------------------------------
178
- # IMPORTANT:
179
- # - The browser UI still uses query_doc directly.
180
- # - External clients (Make, Telegram, etc.) can call api_name="/query_doc".
181
- # - query_doc returns ONLY the answer string. There is no Telegram polling,
182
- # webhook handling, token, or Telegram network call in this Space.
183
- #
184
- # Gradio's low-level /call endpoint uses an event stream internally.
185
- # For the simplest external integration, use a Gradio client/API action that
186
- # returns the prediction value rather than manually parsing the SSE wrapper.
187
-
188
  demo = gr.Interface(
189
  fn=query_doc,
190
  inputs=gr.Textbox(
@@ -193,8 +182,7 @@ demo = gr.Interface(
193
  ),
194
  outputs=gr.Textbox(label="Answer"),
195
  title="DDS Enterprise HR Chatbot",
196
- description="Ask questions based on the latest DDS HR Handbook."
197
-
198
  )
199
 
200
 
 
1
+ # DDS Enterprise HR Chatbot + Telegram Bot
2
  # Hugging Face Spaces app.py
3
 
4
  import logging
 
33
  # ---------------------------------------------------------
34
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
35
  PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
 
36
  if not OPENAI_API_KEY:
37
  raise ValueError("OPENAI_API_KEY is missing from Hugging Face Secrets.")
38
 
 
149
 
150
 
151
  # ---------------------------------------------------------
152
+ # 7. Query engine shared by BOTH Gradio and Telegram
153
  # ---------------------------------------------------------
154
  query_engine = index.as_query_engine(
155
  system_prompt=SYSTEM_PROMPT,
 
158
 
159
 
160
  def query_doc(prompt: str) -> str:
161
+ """Single HR answering function used by web app and Telegram."""
162
  if not prompt or not prompt.strip():
163
  return "Please enter an HR policy question."
164
 
 
172
 
173
 
174
  # ---------------------------------------------------------
175
+ # 8. Gradio web app
176
  # ---------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
177
  demo = gr.Interface(
178
  fn=query_doc,
179
  inputs=gr.Textbox(
 
182
  ),
183
  outputs=gr.Textbox(label="Answer"),
184
  title="DDS Enterprise HR Chatbot",
185
+ description="Ask questions based on the latest DDS HR Handbook.",
 
186
  )
187
 
188