Skip to content

Commit

Permalink
k
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Oct 12, 2024
1 parent 0d5854f commit e04acf0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions backend/danswer/configs/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
)


# List of headers to pass through to tool calls (e.g., API requests made by tools)
# This allows for dynamic configuration of tool behavior based on incoming request headers
TOOL_PASS_THROUGH_HEADERS: list[str] | None = None
_TOOL_PASS_THROUGH_HEADERS_RAW = os.environ.get("TOOL_PASS_THROUGH_HEADERS")
if _TOOL_PASS_THROUGH_HEADERS_RAW:
Expand Down
6 changes: 2 additions & 4 deletions backend/danswer/server/query_and_chat/chat_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
from danswer.server.query_and_chat.models import SearchFeedbackRequest
from danswer.server.query_and_chat.models import UpdateChatSessionThreadRequest
from danswer.server.query_and_chat.token_limit import check_token_rate_limits
from danswer.tools.headers import get_tool_additional_request_headers
from danswer.tools.headers import get_tool_headers
from danswer.utils.logger import setup_logger


Expand Down Expand Up @@ -334,9 +334,7 @@ def stream_generator() -> Generator[str, None, None]:
litellm_additional_headers=get_litellm_additional_request_headers(
request.headers
),
tool_additional_headers=get_tool_additional_request_headers(
request.headers
),
tool_additional_headers=get_tool_headers(request.headers),
is_connected=is_disconnected_func,
):
yield json.dumps(packet) if isinstance(packet, dict) else packet
Expand Down
9 changes: 3 additions & 6 deletions backend/danswer/tools/custom/custom_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ def __init__(

self._name = self._method_spec.name
self._description = self._method_spec.summary
self.headers = (
{header["key"]: header["value"] for header in custom_headers}
if custom_headers
else {}
)
self.headers.update(tool_additional_headers or {})
self.headers = {
header["key"]: header["value"] for header in (custom_headers or [])
} | (tool_additional_headers or {})

@property
def name(self) -> str:
Expand Down

0 comments on commit e04acf0

Please sign in to comment.