diff --git a/README.md b/README.md index aa337c7..d8c9cad 100644 --- a/README.md +++ b/README.md @@ -119,13 +119,13 @@ This is the core of SurfSense. Before we begin let's look at `.env` variables' t | EMBEDDING_MODEL| Name of the embedding model to use for vector embeddings. Currently works with Sentence Transformers only. Expect other embeddings soon. Eg. `mixedbread-ai/mxbai-embed-large-v1`| | RERANKERS_MODEL_NAME| Name of the reranker model for search result reranking. Eg. `ms-marco-MiniLM-L-12-v2`| | RERANKERS_MODEL_TYPE| Type of reranker model being used. Eg. `flashrank`| -| FAST_LLM| LiteLLM routed Smaller, faster LLM for quick responses. Eg. `litellm:openai/gpt-4o`| -| STRATEGIC_LLM| LiteLLM routed Advanced LLM for complex reasoning tasks. Eg. `litellm:openai/gpt-4o`| -| LONG_CONTEXT_LLM| LiteLLM routed LLM capable of handling longer context windows. Eg. `litellm:gemini/gemini-2.0-flash`| +| FAST_LLM| LiteLLM routed Smaller, faster LLM for quick responses. Eg. `openai/gpt-4o-mini`, `ollama/deepseek-r1:8b`| +| STRATEGIC_LLM| LiteLLM routed Advanced LLM for complex reasoning tasks. Eg. `openai/gpt-4o`, `ollama/gemma3:12b`| +| LONG_CONTEXT_LLM| LiteLLM routed LLM capable of handling longer context windows. Eg. `gemini/gemini-2.0-flash`, `ollama/deepseek-r1:8b`| | UNSTRUCTURED_API_KEY| API key for Unstructured.io service for document parsing| | FIRECRAWL_API_KEY| API key for Firecrawl service for web crawling and data extraction| -IMPORTANT: Since LLM calls are routed through LiteLLM make sure to include API keys of LLM models you are using. For example if you used `litellm:openai/gpt-4o` make sure to include OpenAI API Key `OPENAI_API_KEY` or if you use `litellm:gemini/gemini-2.0-flash` then you include `GEMINI_API_KEY`. +IMPORTANT: Since LLM calls are routed through LiteLLM make sure to include API keys of LLM models you are using. For example if you used `openai/gpt-4o` make sure to include OpenAI API Key `OPENAI_API_KEY` or if you use `gemini/gemini-2.0-flash` then you include `GEMINI_API_KEY`. You can also integrate any LLM just follow this https://docs.litellm.ai/docs/providers diff --git a/surfsense_backend/.env.example b/surfsense_backend/.env.example index bc3f5ce..2eee50d 100644 --- a/surfsense_backend/.env.example +++ b/surfsense_backend/.env.example @@ -4,15 +4,18 @@ SECRET_KEY="SECRET" GOOGLE_OAUTH_CLIENT_ID="924507538m" GOOGLE_OAUTH_CLIENT_SECRET="GOCSV" NEXT_FRONTEND_URL="http://localhost:3000" + EMBEDDING_MODEL="mixedbread-ai/mxbai-embed-large-v1" RERANKERS_MODEL_NAME="ms-marco-MiniLM-L-12-v2" RERANKERS_MODEL_TYPE="flashrank" -FAST_LLM="litellm:openai/gpt-4o-mini" -STRATEGIC_LLM="litellm:openai/gpt-4o" -LONG_CONTEXT_LLM="litellm:gemini/gemini-2.0-flash" +# https://docs.litellm.ai/docs/providers +FAST_LLM="openai/gpt-4o-mini" +STRATEGIC_LLM="openai/gpt-4o" +LONG_CONTEXT_LLM="gemini/gemini-2.0-flash" +# Chosen LiteLLM Providers Keys OPENAI_API_KEY="sk-proj-iA" GEMINI_API_KEY="AIzaSyB6-1641124124124124124124124124124" diff --git a/surfsense_backend/app/agents/researcher/sub_section_writer/nodes.py b/surfsense_backend/app/agents/researcher/sub_section_writer/nodes.py index 5b11141..0bec461 100644 --- a/surfsense_backend/app/agents/researcher/sub_section_writer/nodes.py +++ b/surfsense_backend/app/agents/researcher/sub_section_writer/nodes.py @@ -37,8 +37,9 @@ async def rerank_documents(state: State, config: RunnableConfig) -> Dict[str, An if reranker_service: try: # Use the sub-section questions for reranking context - rerank_query = "\n".join(sub_section_questions) - + # rerank_query = "\n".join(sub_section_questions) + rerank_query = configuration.user_query + # Convert documents to format expected by reranker if needed reranker_input_docs = [ { diff --git a/surfsense_backend/app/config/__init__.py b/surfsense_backend/app/config/__init__.py index 82517a8..c7f842b 100644 --- a/surfsense_backend/app/config/__init__.py +++ b/surfsense_backend/app/config/__init__.py @@ -15,17 +15,6 @@ env_file = BASE_DIR / ".env" load_dotenv(env_file) -def extract_model_name(llm_string: str) -> str: - """Extract the model name from an LLM string. - Example: "litellm:openai/gpt-4o-mini" -> "openai/gpt-4o-mini" - - Args: - llm_string: The LLM string with optional prefix - - Returns: - str: The extracted model name - """ - return llm_string.split(":", 1)[1] if ":" in llm_string else llm_string class Config: # Database @@ -38,13 +27,13 @@ class Config: # LONG-CONTEXT LLMS LONG_CONTEXT_LLM = os.getenv("LONG_CONTEXT_LLM") - long_context_llm_instance = ChatLiteLLM(model=extract_model_name(LONG_CONTEXT_LLM)) + long_context_llm_instance = ChatLiteLLM(model=LONG_CONTEXT_LLM) # GPT Researcher FAST_LLM = os.getenv("FAST_LLM") STRATEGIC_LLM = os.getenv("STRATEGIC_LLM") - fast_llm_instance = ChatLiteLLM(model=extract_model_name(FAST_LLM)) - strategic_llm_instance = ChatLiteLLM(model=extract_model_name(STRATEGIC_LLM)) + fast_llm_instance = ChatLiteLLM(model=FAST_LLM) + strategic_llm_instance = ChatLiteLLM(model=STRATEGIC_LLM) # Chonkie Configuration | Edit this to your needs