def create( client: Client, handle: str = None, name: str = None, plugin_instance: str = None, upsert: bool = True, external_id: str = None, external_type: str = None, metadata: Any = None, space_id: str = None, space_handle: str = None, space: Any = None, ) -> Response[EmbeddingIndex]: req = IndexCreateRequest( handle=handle, name=name, plugin_instance=plugin_instance, upsert=upsert, external_id=external_id, external_type=external_type, metadata=metadata, ) return client.post( "embedding-index/create", req, space_id=space_id, space_handle=space_handle, space=space, expect=EmbeddingIndex, )
def create( client: Client, file_id: str = None, block_id: str = None, kind: str = None, name: str = None, start_idx: int = None, end_idx: int = None, value: Any = None, upsert: bool = None, space_id: str = None, space_handle: str = None, ) -> Response[Tag]: if isinstance(value, dict) or isinstance(value, list): value = json.dumps(value) req = Tag.CreateRequest( file_id=file_id, block_id=block_id, kind=kind, name=name, start_idx=start_idx, end_idx=end_idx, value=value, upsert=upsert, ) return client.post("tag/create", req, expect=Tag, space_id=space_id, space_handle=space_handle)
def create( client: Client, app_id: str = None, handle: str = None, filename: str = None, filebytes: bytes = None, upsert: bool = None, config_template: Dict[str, Any] = None, ) -> Response[AppVersion]: if filename is None and filebytes is None: raise Exception("Either filename or filebytes must be provided.") if filename is not None and filebytes is not None: raise Exception("Only either filename or filebytes should be provided.") if filename is not None: with open(filename, "rb") as f: filebytes = f.read() req = CreateAppVersionRequest( handle=handle, app_id=app_id, upsert=upsert, config_template=config_template ) return client.post( "app/version/create", payload=req, file=("app.zip", filebytes, "multipart/form-data"), expect=AppVersion, )
def create( client: Client, space_id: str = None, plugin_id: str = None, plugin_handle: str = None, plugin_version_id: str = None, plugin_version_handle: str = None, handle: str = None, upsert: bool = None, config: Dict[str, Any] = None, ) -> Response[PluginInstance]: req = CreatePluginInstanceRequest( handle=handle, plugin_id=plugin_id, plugin_handle=plugin_handle, plugin_version_id=plugin_version_id, plugin_version_handle=plugin_version_handle, upsert=upsert, config=config, ) return client.post( "plugin/instance/create", payload=req, expect=PluginInstance, space_id=space_id, )
def list_public( client: Client, plugin_id: str = None, handle: str = None) -> Response[ListPluginVersionsResponse]: return client.post( "plugin/version/public", ListPublicPluginVersionsRequest(handle=handle, plugin_id=plugin_id), expect=ListPluginVersionsResponse, )
def list_private( client: Client, _=None, plugin_id: str = None, handle: str = None) -> Response[ListPluginVersionsResponse]: return client.post( "plugin/version/private", ListPrivatePluginVersionsRequest(handle=handle, plugin_id=plugin_id), expect=ListPluginVersionsResponse, )
def list_public( client: Client, file_id: str = None, space_id: str = None, space_handle: str = None, ) -> Response[Block.ListResponse]: return client.post( "block/list", Block.ListRequest(file_id=file_id), expect=Block.ListResponse, space_id=space_id, space_handle=space_handle, )
def list_public( client: Client, file_id: str = None, block_id: str = None, space_id: str = None, space_handle: str = None, ) -> Response[Tag.ListResponse]: return client.post( "tag/list", Tag.ListRequest(file_id=file_id, block_id=block_id), expect=Tag.ListResponse, space_id=space_id, space_handle=space_handle, )
def get( client: Client, _id: str = None, space_id: str = None, space_handle: str = None, space: Any = None, ) -> Response[Block]: return client.post( "block/get", IdentifierRequest(id=_id), expect=Block, space_id=space_id, space_handle=space_handle, space=space, )
def get( client: Client, _id: str = None, handle: str = None, space_id: str = None, space_handle: str = None, space: Any = None, ) -> Response[File]: # TODO (Enias): Why is this a staticmethod? return client.post( "file/get", IdentifierRequest(id=_id, handle=handle), expect=File, space_id=space_id, space_handle=space_handle, space=space, )
def create( client: Client, handle: Optional[str] = None, external_id: Optional[str] = None, external_type: Optional[str] = None, metadata: Any = None, upsert: bool = True, ) -> SteamshipResponse[Space]: req = Space.CreateRequest( handle=handle, upsert=upsert, external_id=external_id, external_type=external_type, metadata=metadata, ) return client.post("space/create", req, expect=Space)
def list( client: Client, corpus_id: str = None, space_id: str = None, space_handle: str = None, space: Any = None, ): req = File.ListRequest(corpusId=corpus_id) res = client.post( "file/list", payload=req, expect=File.ListResponse, space_id=space_id, space_handle=space_handle, space=space, ) return res
def query( client: Client, tag_filter_query: str, space_id: str = None, space_handle: str = None, space: Any = None, ) -> Response[TagQueryResponse]: req = TagQueryRequest(tag_filter_query=tag_filter_query) res = client.post( "tag/query", payload=req, expect=TagQueryResponse, space_id=space_id, space_handle=space_handle, space=space, ) return res
def get( client: Client, id_: str = None, handle: str = None, upsert: bool = None, space_id: str = None, space_handle: str = None, space: Space = None, ) -> SteamshipResponse[Space]: req = GetRequest(id=id_, handle=handle, upsert=upsert) return client.post( "space/get", req, expect=Space, space_id=space_id, space_handle=space_handle, space=space, )
def query( client: Client, tag_filter_query: str, space_id: str = None, space_handle: str = None, space: Any = None, ) -> Response[BlockQueryResponse]: # TODO: Is this a static method? req = BlockQueryRequest(tag_filter_query=tag_filter_query) res = client.post( "block/query", payload=req, expect=BlockQueryResponse, space_id=space_id, space_handle=space_handle, space=space, ) return res
def create( client: Client, handle: str, plugin_id: str = None, filename: str = None, filebytes: bytes = None, upsert: bool = None, hosting_memory: Optional[HostingMemory] = None, hosting_timeout: Optional[HostingTimeout] = None, hosting_handler: str = None, is_public: bool = None, is_default: bool = None, config_template: Dict[str, Any] = None, ) -> Response[PluginVersion]: if filename is None and filebytes is None: raise Exception("Either filename or filebytes must be provided.") if filename is not None and filebytes is not None: raise Exception( "Only either filename or filebytes should be provided.") if filename is not None: with open(filename, "rb") as f: filebytes = f.read() req = CreatePluginVersionRequest( handle=handle, plugin_id=plugin_id, upsert=upsert, hosting_memory=hosting_memory, hosting_timeout=hosting_timeout, hosting_handler=hosting_handler, is_public=is_public, is_default=is_default, config_template=config_template, ) return client.post( "plugin/version/create", payload=req, file=("plugin.zip", filebytes, "multipart/form-data"), expect=PluginVersion, )
def create( client: Client, file_id: str = None, text: str = None, tags: List[Tag.CreateRequest] = None, upsert: bool = None, space_id: str = None, space_handle: str = None, ) -> Response[Block]: req = Block.CreateRequest(file_id=file_id, text=text, tags=tags, upsert=upsert) return client.post( "block/create", req, expect=Block, space_id=space_id, space_handle=space_handle, )
def create( client: Client, space_id: str = None, app_id: str = None, app_version_id: str = None, handle: str = None, upsert: bool = None, config: Dict[str, Any] = None, ) -> Response[AppInstance]: req = CreateAppInstanceRequest( handle=handle, app_id=app_id, appVersionId=app_version_id, upsert=upsert, config=config, spaceId=space_id, ) return client.post("app/instance/create", payload=req, expect=AppInstance)
def create( client: Client, filename: str = None, url: str = None, content: str = None, plugin_instance: str = None, mime_type: str = None, blocks: List[Block.CreateRequest] = None, tags: List[Tag.CreateRequest] = None, corpus_id: str = None, space_id: str = None, space_handle: str = None, space: Any = None, ) -> Response[File]: if (filename is None and content is None and url is None and plugin_instance is None and blocks is None): raise Exception( "Either filename, content, url, or plugin Instance must be provided." ) if blocks is not None: upload_type = FileUploadType.BLOCKS elif plugin_instance is not None: upload_type = FileUploadType.FILE_IMPORTER elif content is not None: # We're still going to use the file upload method for file uploads upload_type = FileUploadType.FILE elif filename is not None: with open(filename, "rb") as f: content = f.read() upload_type = FileUploadType.FILE else: if url is not None: raise Exception( "Unable to determine upload type. For scraping a URL, use the File.scrape method." ) else: raise Exception("Unable to determine upload type.") req = File.CreateRequest( type=upload_type, corpusId=corpus_id, url=url, mime_type=mime_type, plugin_instance=plugin_instance, blocks=blocks, tags=tags, filename=filename, ) # Defaulting this here, as opposed to in the Engine, because it is processed by Vapor file_part_name = filename if filename else "unnamed" return client.post( "file/create", payload=req, file=(file_part_name, content, "multipart/form-data") if upload_type != FileUploadType.BLOCKS else None, expect=File, space_id=space_id, space_handle=space_handle, space=space, )
def get(client: Client, handle: str): return client.post("app/get", GetAppRequest(handle=handle), expect=App)
def get(client: Client, handle: str): return client.post("plugin/instance/get", GetPluginInstanceRequest(handle=handle), expect=PluginInstance)
def current(client: Client) -> Response[User]: return client.get("account/current", expect=User)
def create(client: Client, handle: str = None, upsert: bool = None) -> Response[App]: req = CreateAppRequest(handle=handle, upsert=upsert) return client.post("app/create", payload=req, expect=App)