assistant-runtime-sdk 1.11.0__tar.gz → 1.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: assistant_runtime_sdk
3
- Version: 1.11.0
3
+ Version: 1.12.0
4
4
  Summary: Python SDK for FAC Cloud - the Assistant Runtime AI assistant backend
5
5
  Keywords: frappe,ai,assistant,llm,mcp,anthropic,openai,streaming
6
6
  Author: Paul Clinton
@@ -53,7 +53,7 @@ Standalone Functions:
53
53
 
54
54
  """
55
55
 
56
- __version__ = "1.11.0"
56
+ __version__ = "1.12.0"
57
57
  __author__ = "Paul Clinton"
58
58
  __license__ = "AGPL-3.0"
59
59
 
@@ -608,11 +608,13 @@ class AsyncAssistantRuntimeClient(BaseAssistantRuntimeClient):
608
608
  user_id: Optional[str] = None,
609
609
  visibility: Optional[str] = None,
610
610
  shared_with: Optional[List[str]] = None,
611
+ project_id: Optional[str] = None,
611
612
  ) -> Optional[Dict[str, Any]]:
612
613
  """Async version of AssistantRuntimeClient.upload_document."""
613
614
  endpoint, params, f_field, f_name, f_data, c_type = self._prepare_upload_document(
614
615
  file_path, file_data, file_name, content_type,
615
616
  user_id=user_id, visibility=visibility, shared_with=shared_with,
617
+ project_id=project_id,
616
618
  )
617
619
  return await self._request_post_multipart(
618
620
  endpoint, params=params, file_field=f_field,
@@ -621,12 +623,27 @@ class AsyncAssistantRuntimeClient(BaseAssistantRuntimeClient):
621
623
  )
622
624
 
623
625
  async def list_documents(
624
- self, limit: int = 50, offset: int = 0, user_id: Optional[str] = None
626
+ self,
627
+ limit: int = 50,
628
+ offset: int = 0,
629
+ user_id: Optional[str] = None,
630
+ project_id: Optional[str] = None,
631
+ include_project_docs: bool = False,
625
632
  ) -> Optional[Dict[str, Any]]:
626
633
  """Async version of AssistantRuntimeClient.list_documents."""
627
- endpoint, params = self._prepare_list_documents(limit, offset, user_id=user_id)
634
+ endpoint, params = self._prepare_list_documents(
635
+ limit, offset, user_id=user_id,
636
+ project_id=project_id, include_project_docs=include_project_docs,
637
+ )
628
638
  return await self._request_get(endpoint, params, api_base=self.memory_api_base)
629
639
 
640
+ async def unlink_project_documents(
641
+ self, user_id: str, project_id: str
642
+ ) -> Optional[Dict[str, Any]]:
643
+ """Async version of AssistantRuntimeClient.unlink_project_documents."""
644
+ endpoint, payload = self._prepare_unlink_project_documents(user_id, project_id)
645
+ return await self._request_post_json(endpoint, payload, api_base=self.memory_api_base)
646
+
630
647
  async def get_document(self, document_id: str) -> Optional[Dict[str, Any]]:
631
648
  """Async version of AssistantRuntimeClient.get_document."""
632
649
  endpoint, params = self._prepare_get_document(document_id)
@@ -609,11 +609,14 @@ class BaseAssistantRuntimeClient:
609
609
  user_id: Optional[str] = None,
610
610
  visibility: Optional[str] = None,
611
611
  shared_with: Optional[List[str]] = None,
612
+ project_id: Optional[str] = None,
612
613
  ) -> tuple:
613
614
  """Returns (endpoint, params, file_field, file_name, file_data, content_type)."""
614
615
  import mimetypes as _mt
615
616
  import os as _os
616
617
 
618
+ if project_id and not user_id:
619
+ raise ARConfigurationError("user_id is required with project_id")
617
620
  if file_path and file_data:
618
621
  raise ARConfigurationError("Provide either file_path or file_data, not both")
619
622
  if not file_path and not file_data:
@@ -625,7 +628,7 @@ class BaseAssistantRuntimeClient:
625
628
  raise ARConfigurationError(
626
629
  f"Invalid visibility: {visibility}. Must be public, private, or shared."
627
630
  )
628
- if visibility == "shared" and not shared_with:
631
+ if not project_id and visibility == "shared" and not shared_with:
629
632
  raise ARConfigurationError(
630
633
  "shared_with is required when visibility is 'shared'"
631
634
  )
@@ -645,10 +648,15 @@ class BaseAssistantRuntimeClient:
645
648
  params: Dict[str, Any] = {"tenant_id": self.tenant_id}
646
649
  if user_id:
647
650
  params["user_id"] = user_id
648
- if visibility:
649
- params["visibility"] = visibility
650
- if shared_with:
651
- params["shared_with"] = json.dumps(shared_with)
651
+ if project_id:
652
+ # The server forces project documents to private, so no visibility
653
+ # or sharing is sent alongside a project_id.
654
+ params["project_id"] = project_id
655
+ else:
656
+ if visibility:
657
+ params["visibility"] = visibility
658
+ if shared_with:
659
+ params["shared_with"] = json.dumps(shared_with)
652
660
 
653
661
  return (
654
662
  "documents.upload_document",
@@ -660,8 +668,15 @@ class BaseAssistantRuntimeClient:
660
668
  )
661
669
 
662
670
  def _prepare_list_documents(
663
- self, limit: int = 50, offset: int = 0, user_id: Optional[str] = None
671
+ self,
672
+ limit: int = 50,
673
+ offset: int = 0,
674
+ user_id: Optional[str] = None,
675
+ project_id: Optional[str] = None,
676
+ include_project_docs: bool = False,
664
677
  ) -> tuple:
678
+ if project_id and not user_id:
679
+ raise ARConfigurationError("user_id is required with project_id")
665
680
  params: Dict[str, Any] = {
666
681
  "tenant_id": self.tenant_id,
667
682
  "limit": str(limit),
@@ -669,8 +684,20 @@ class BaseAssistantRuntimeClient:
669
684
  }
670
685
  if user_id:
671
686
  params["user_id"] = user_id
687
+ if project_id:
688
+ params["project_id"] = project_id
689
+ if include_project_docs:
690
+ params["include_project_docs"] = "1"
672
691
  return "documents.list_documents", params
673
692
 
693
+ def _prepare_unlink_project_documents(self, user_id: str, project_id: str) -> tuple:
694
+ """Returns (endpoint, payload) for unlinking a project's documents."""
695
+ return "documents.unlink_project_documents", {
696
+ "tenant_id": self.tenant_id,
697
+ "user_id": user_id,
698
+ "project_id": project_id,
699
+ }
700
+
674
701
  def _prepare_get_document(self, document_id: str) -> tuple:
675
702
  return "documents.get_document", {
676
703
  "tenant_id": self.tenant_id,
@@ -682,6 +682,7 @@ class AssistantRuntimeClient(BaseAssistantRuntimeClient):
682
682
  user_id: Optional[str] = None,
683
683
  visibility: Optional[str] = None,
684
684
  shared_with: Optional[List[str]] = None,
685
+ project_id: Optional[str] = None,
685
686
  ) -> Optional[Dict[str, Any]]:
686
687
  """
687
688
  Upload a document for RAG processing.
@@ -699,6 +700,9 @@ class AssistantRuntimeClient(BaseAssistantRuntimeClient):
699
700
  tenant configuration if omitted.
700
701
  shared_with: List of user IDs to share with. Required when
701
702
  visibility is "shared".
703
+ project_id: Attach the document to a project. Project documents are
704
+ always private to the uploader, so visibility and shared_with
705
+ are not sent.
702
706
 
703
707
  Returns:
704
708
  {"status": "queued", "document_id": str, "file_name": str,
@@ -707,6 +711,7 @@ class AssistantRuntimeClient(BaseAssistantRuntimeClient):
707
711
  endpoint, params, f_field, f_name, f_data, c_type = self._prepare_upload_document(
708
712
  file_path, file_data, file_name, content_type,
709
713
  user_id=user_id, visibility=visibility, shared_with=shared_with,
714
+ project_id=project_id,
710
715
  )
711
716
  return self._request_post_multipart(
712
717
  endpoint, params=params, file_field=f_field,
@@ -715,7 +720,12 @@ class AssistantRuntimeClient(BaseAssistantRuntimeClient):
715
720
  )
716
721
 
717
722
  def list_documents(
718
- self, limit: int = 50, offset: int = 0, user_id: Optional[str] = None
723
+ self,
724
+ limit: int = 50,
725
+ offset: int = 0,
726
+ user_id: Optional[str] = None,
727
+ project_id: Optional[str] = None,
728
+ include_project_docs: bool = False,
719
729
  ) -> Optional[Dict[str, Any]]:
720
730
  """
721
731
  List RAG documents for this tenant.
@@ -728,13 +738,38 @@ class AssistantRuntimeClient(BaseAssistantRuntimeClient):
728
738
  limit: Maximum number of documents to return (default 50).
729
739
  offset: Pagination offset (default 0).
730
740
  user_id: User performing the query. Enables visibility filtering.
741
+ project_id: Only list documents attached to this project.
742
+ include_project_docs: Also include documents attached to projects.
731
743
 
732
744
  Returns:
733
745
  {"documents": [...], "pagination": {...}, "storage": {...}}
734
746
  """
735
- endpoint, params = self._prepare_list_documents(limit, offset, user_id=user_id)
747
+ endpoint, params = self._prepare_list_documents(
748
+ limit, offset, user_id=user_id,
749
+ project_id=project_id, include_project_docs=include_project_docs,
750
+ )
736
751
  return self._request_get(endpoint, params, api_base=self.memory_api_base)
737
752
 
753
+ def unlink_project_documents(
754
+ self, user_id: str, project_id: str
755
+ ) -> Optional[Dict[str, Any]]:
756
+ """
757
+ Unlink a project's documents from the project.
758
+
759
+ Documents attached to a project are removed from that project only;
760
+ the documents themselves are kept.
761
+
762
+ Args:
763
+ user_id: User performing the unlink.
764
+ project_id: The project whose documents should be unlinked.
765
+
766
+ Returns:
767
+ ``{"status": "unlinked", "count": int}``, where count is the number of
768
+ documents released from the project.
769
+ """
770
+ endpoint, payload = self._prepare_unlink_project_documents(user_id, project_id)
771
+ return self._request_post_json(endpoint, payload, api_base=self.memory_api_base)
772
+
738
773
  def get_document(self, document_id: str) -> Optional[Dict[str, Any]]:
739
774
  """
740
775
  Get detailed information about a specific RAG document.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "assistant_runtime_sdk"
3
- version = "1.11.0"
3
+ version = "1.12.0"
4
4
  description = "Python SDK for FAC Cloud - the Assistant Runtime AI assistant backend"
5
5
  readme = "README.md"
6
6
  license = {text = "AGPL-3.0"}