Skip to content

Commit

Permalink
Fix startup exception + mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Weves committed Aug 28, 2023
1 parent 6f0068b commit d37e8ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/danswer/background/connector_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _update_multi_indexed_docs() -> None:
def _get_user(
credential: Credential,
) -> str:
if credential.public_doc:
if credential.public_doc or not credential.user:
return PUBLIC_DOC_PAT

return str(credential.user.id)
Expand Down
6 changes: 6 additions & 0 deletions backend/danswer/llm/azure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any

from langchain.chat_models.azure_openai import AzureChatOpenAI
Expand All @@ -22,6 +23,11 @@ def __init__(
*args: list[Any],
**kwargs: dict[str, Any]
):
# set a dummy API key if not specified so that LangChain doesn't throw an
# exception when trying to initialize the LLM which would prevent the API
# server from starting up
if not api_key:
api_key = os.environ.get("OPENAI_API_KEY") or "dummy_api_key"
self._llm = AzureChatOpenAI(
model=model_version,
openai_api_type="azure",
Expand Down
6 changes: 6 additions & 0 deletions backend/danswer/llm/openai.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any

from langchain.chat_models.openai import ChatOpenAI
Expand All @@ -16,6 +17,11 @@ def __init__(
*args: list[Any],
**kwargs: dict[str, Any]
):
# set a dummy API key if not specified so that LangChain doesn't throw an
# exception when trying to initialize the LLM which would prevent the API
# server from starting up
if not api_key:
api_key = os.environ.get("OPENAI_API_KEY") or "dummy_api_key"
self._llm = ChatOpenAI(
model=model_version,
openai_api_key=api_key,
Expand Down

0 comments on commit d37e8ce

Please sign in to comment.