| class LCHumanMessageWithFiles(HumanMessage): | class LCHumanMessageWithFiles(HumanMessage): | ||||
| # content: Union[str, List[Union[str, Dict]]] | |||||
| # content: Union[str, list[Union[str, Dict]]] | |||||
| content: str | content: str | ||||
| files: list[PromptMessageFile] | files: list[PromptMessageFile] | ||||
| ```python | ```python | ||||
| def _invoke(self, model: str, credentials: dict, | def _invoke(self, model: str, credentials: dict, | ||||
| prompt_messages: list[PromptMessage], model_parameters: dict, | prompt_messages: list[PromptMessage], model_parameters: dict, | ||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[List[str]] = None, | |||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[list[str]] = None, | |||||
| stream: bool = True, user: Optional[str] = None) \ | stream: bool = True, user: Optional[str] = None) \ | ||||
| -> Union[LLMResult, Generator]: | -> Union[LLMResult, Generator]: | ||||
| """ | """ |
| ```python | ```python | ||||
| def _invoke(self, model: str, credentials: dict, | def _invoke(self, model: str, credentials: dict, | ||||
| prompt_messages: list[PromptMessage], model_parameters: dict, | prompt_messages: list[PromptMessage], model_parameters: dict, | ||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[List[str]] = None, | |||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[list[str]] = None, | |||||
| stream: bool = True, user: Optional[str] = None) \ | stream: bool = True, user: Optional[str] = None) \ | ||||
| -> Union[LLMResult, Generator]: | -> Union[LLMResult, Generator]: | ||||
| """ | """ |
| ```python | ```python | ||||
| def _invoke(self, model: str, credentials: dict, | def _invoke(self, model: str, credentials: dict, | ||||
| prompt_messages: list[PromptMessage], model_parameters: dict, | prompt_messages: list[PromptMessage], model_parameters: dict, | ||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[List[str]] = None, | |||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[list[str]] = None, | |||||
| stream: bool = True, user: Optional[str] = None) \ | stream: bool = True, user: Optional[str] = None) \ | ||||
| -> Union[LLMResult, Generator]: | -> Union[LLMResult, Generator]: | ||||
| """ | """ |
| ```python | ```python | ||||
| def _invoke(self, model: str, credentials: dict, | def _invoke(self, model: str, credentials: dict, | ||||
| prompt_messages: list[PromptMessage], model_parameters: dict, | prompt_messages: list[PromptMessage], model_parameters: dict, | ||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[List[str]] = None, | |||||
| tools: Optional[list[PromptMessageTool]] = None, stop: Optional[list[str]] = None, | |||||
| stream: bool = True, user: Optional[str] = None) \ | stream: bool = True, user: Optional[str] = None) \ | ||||
| -> Union[LLMResult, Generator]: | -> Union[LLMResult, Generator]: | ||||
| """ | """ |
| return ta | return ta | ||||
| @staticmethod | @staticmethod | ||||
| def get_join_tenants(account: Account) -> List[Tenant]: | |||||
| def get_join_tenants(account: Account) -> list[Tenant]: | |||||
| """Get account join tenants""" | """Get account join tenants""" | ||||
| return db.session.query(Tenant).join( | return db.session.query(Tenant).join( | ||||
| TenantAccountJoin, Tenant.id == TenantAccountJoin.tenant_id | TenantAccountJoin, Tenant.id == TenantAccountJoin.tenant_id | ||||
| account.current_tenant_id = tenant_account_join.tenant_id | account.current_tenant_id = tenant_account_join.tenant_id | ||||
| @staticmethod | @staticmethod | ||||
| def get_tenant_members(tenant: Tenant) -> List[Account]: | |||||
| def get_tenant_members(tenant: Tenant) -> list[Account]: | |||||
| """Get tenant members""" | """Get tenant members""" | ||||
| query = ( | query = ( | ||||
| db.session.query(Account, TenantAccountJoin.role) | db.session.query(Account, TenantAccountJoin.role) | ||||
| return updated_accounts | return updated_accounts | ||||
| @staticmethod | @staticmethod | ||||
| def has_roles(tenant: Tenant, roles: List[TenantAccountJoinRole]) -> bool: | |||||
| def has_roles(tenant: Tenant, roles: list[TenantAccountJoinRole]) -> bool: | |||||
| """Check if user has any of the given roles for a tenant""" | """Check if user has any of the given roles for a tenant""" | ||||
| if not all(isinstance(role, TenantAccountJoinRole) for role in roles): | if not all(isinstance(role, TenantAccountJoinRole) for role in roles): | ||||
| raise ValueError('all roles must be TenantAccountJoinRole') | raise ValueError('all roles must be TenantAccountJoinRole') |