feat: add language support across configurations and prompts

This commit is contained in:
Tarun 2025-10-12 13:13:42 +05:30
parent 402039f02f
commit 045537aa79
16 changed files with 242 additions and 18 deletions

View file

@ -1,7 +1,7 @@
import datetime
def get_citation_system_prompt(chat_history: str | None = None):
def get_citation_system_prompt(chat_history: str | None = None, language: str | None = None):
chat_history_section = (
f"""
<chat_history>
@ -15,10 +15,15 @@ NO CHAT HISTORY PROVIDED
</chat_history>
"""
)
# Add language instruction if specified
language_instruction = ""
if language:
language_instruction = f"\n\nIMPORTANT: Please respond in {language} language. All your responses, explanations, and analysis should be written in {language}."
return f"""
Today's date: {datetime.datetime.now().strftime("%Y-%m-%d")}
You are SurfSense, an advanced AI research assistant that synthesizes information from multiple knowledge sources to provide comprehensive, well-cited answers to user queries.
You are SurfSense, an advanced AI research assistant that synthesizes information from multiple knowledge sources to provide comprehensive, well-cited answers to user queries.{language_instruction}
{chat_history_section}
<knowledge_sources>
- EXTENSION: "Web content saved via SurfSense browser extension" (personal browsing history)
@ -156,7 +161,7 @@ Make sure your response:
"""
def get_no_documents_system_prompt(chat_history: str | None = None):
def get_no_documents_system_prompt(chat_history: str | None = None, language: str | None = None):
chat_history_section = (
f"""
<chat_history>
@ -170,10 +175,15 @@ NO CHAT HISTORY PROVIDED
</chat_history>
"""
)
# Add language instruction if specified
language_instruction = ""
if language:
language_instruction = f"\n\nIMPORTANT: Please respond in {language} language. All your responses, explanations, and analysis should be written in {language}."
return f"""
Today's date: {datetime.datetime.now().strftime("%Y-%m-%d")}
You are SurfSense, an advanced AI research assistant that helps users create well-structured content for their documents and research.
You are SurfSense, an advanced AI research assistant that helps users create well-structured content for their documents and research.{language_instruction}
{chat_history_section}
<context>
You are writing content for a specific sub-section of a document. No specific documents from the user's personal knowledge base are available, so you should create content based on: