|
4 | 4 |
|
5 | 5 | import redis |
6 | 6 | from danswer.chat.models import LlmDoc |
7 | | -from danswer.configs.app_configs import AIRTABLE_API_TOKEN |
8 | | -from danswer.configs.app_configs import AIRTABLE_EMPLOYEE_BASE_ID |
9 | | -from danswer.configs.app_configs import AIRTABLE_EMPLOYEE_TABLE_NAME_OR_ID |
10 | | -from danswer.configs.app_configs import REDIS_DB_NUMBER |
11 | | -from danswer.configs.app_configs import REDIS_HOST |
12 | | -from danswer.configs.app_configs import REDIS_PORT |
| 7 | +from danswer.configs.app_configs import ( |
| 8 | + AIRTABLE_API_TOKEN, |
| 9 | + AIRTABLE_EMPLOYEE_BASE_ID, |
| 10 | + AIRTABLE_EMPLOYEE_TABLE_NAME_OR_ID, |
| 11 | + REDIS_DB_NUMBER, |
| 12 | + REDIS_HOST, |
| 13 | + REDIS_PORT, |
| 14 | +) |
13 | 15 | from danswer.configs.chat_configs import LANGUAGE_HINT |
14 | 16 | from danswer.configs.constants import DocumentSource |
15 | 17 | from danswer.db.models import Prompt |
16 | 18 | from danswer.llm.answering.models import PromptConfig |
17 | | -from danswer.prompts.chat_prompts import ADDITIONAL_INFO |
18 | | -from danswer.prompts.chat_prompts import CITATION_REMINDER |
| 19 | +from danswer.prompts.chat_prompts import ADDITIONAL_INFO, CITATION_REMINDER |
19 | 20 | from danswer.prompts.constants import CODE_BLOCK_PAT |
20 | 21 | from danswer.search.models import InferenceChunk |
21 | 22 | from danswer.utils.logger import setup_logger |
@@ -85,7 +86,15 @@ def add_employee_context_to_prompt(prompt_str: str, user_email: str) -> str: |
85 | 86 | if "fields" in employee and "MV Email" in employee["fields"]: |
86 | 87 | if employee["fields"]["MV Email"] == user_email: |
87 | 88 | logger.info(f"Employee found: {employee['fields']['Preferred Name']}") |
88 | | - employee_context = f"My Name: {employee['fields']['Preferred Name']}\nMy Title: {employee['fields']['Job Role']}\nMy City Office: {employee['fields']['City Office']}\nMy Division: {employee['fields']['Import: Division']}\nMy Manager: {employee['fields']['Reports To']}\nMy Department: {employee['fields']['Import: Department']}\nMy Employment Status: {employee['fields']['Employment Status']}" |
| 89 | + employee_context = ( |
| 90 | + f"My Name: {employee['fields'].get('Preferred Name', None)}\n" |
| 91 | + f"My Title: {employee['fields'].get('Job Role', None)}\n" |
| 92 | + f"My City Office: {employee['fields'].get('City Office', None)}\n" |
| 93 | + f"My Division: {employee['fields'].get('Import: Division', None)}\n" |
| 94 | + f"My Manager: {employee['fields'].get('Reports To', None)}\n" |
| 95 | + f"My Department: {employee['fields'].get('Import: Department', None)}\n" |
| 96 | + f"My Employment Status: {employee['fields'].get('Employment Status', None)}" |
| 97 | + ) |
89 | 98 |
|
90 | 99 | # Store the employee context in Redis with a TTL of 30 days |
91 | 100 | redis_client.setex(user_email, 7 * 24 * 60 * 60, employee_context) |
|
0 commit comments