mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-19 00:00:37 +02:00
* Add basic passthrough auth * Add server-side validation * Disallow for non-oauth * Fix npm build
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from typing import Any
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from onyx.db.models import Tool
|
|
|
|
|
|
class ToolSnapshot(BaseModel):
|
|
id: int
|
|
name: str
|
|
description: str
|
|
definition: dict[str, Any] | None
|
|
display_name: str
|
|
in_code_tool_id: str | None
|
|
custom_headers: list[Any] | None
|
|
passthrough_auth: bool
|
|
|
|
@classmethod
|
|
def from_model(cls, tool: Tool) -> "ToolSnapshot":
|
|
return cls(
|
|
id=tool.id,
|
|
name=tool.name,
|
|
description=tool.description,
|
|
definition=tool.openapi_schema,
|
|
display_name=tool.display_name or tool.name,
|
|
in_code_tool_id=tool.in_code_tool_id,
|
|
custom_headers=tool.custom_headers,
|
|
passthrough_auth=tool.passthrough_auth,
|
|
)
|
|
|
|
|
|
class Header(BaseModel):
|
|
key: str
|
|
value: str
|
|
|
|
|
|
class CustomToolCreate(BaseModel):
|
|
name: str
|
|
description: str | None = None
|
|
definition: dict[str, Any]
|
|
custom_headers: list[Header] | None = None
|
|
passthrough_auth: bool
|
|
|
|
|
|
class CustomToolUpdate(BaseModel):
|
|
name: str | None = None
|
|
description: str | None = None
|
|
definition: dict[str, Any] | None = None
|
|
custom_headers: list[Header] | None = None
|
|
passthrough_auth: bool | None = None
|