Skip to content

Commit

Permalink
Docs: Move tupload_texts() example from guides to reference (#196)
Browse files Browse the repository at this point in the history
* Move example from the docs

* Update deepset_cloud_sdk/workflows/async_client/files.py

Co-authored-by: Florian Hardow <[email protected]>

* Update deepset_cloud_sdk/workflows/sync_client/files.py

Co-authored-by: Florian Hardow <[email protected]>

* Fix formatting

---------

Co-authored-by: Florian Hardow <[email protected]>
Co-authored-by: Sebastian Husch Lee <[email protected]>
  • Loading branch information
3 people committed Jun 7, 2024
1 parent 7a2021e commit 066f14c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
25 changes: 25 additions & 0 deletions deepset_cloud_sdk/workflows/async_client/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,31 @@ async def upload_texts(
This may take a couple of minutes.
:param timeout_s: Timeout in seconds for the `blocking` parameter.
:param show_progress: Shows the upload progress.
Example:
```python
import asyncio
from deepset_cloud_sdk.workflows.async_client.files import upload_texts, DeepsetCloudFile
async def my_async_context() -> None:
await upload_texts(
api_key="<deepsetCloud_API_key>",
workspace_name="<default_workspace>", # optional, by default the environment variable "DEFAULT_WORKSPACE_NAME" is used
files=[
DeepsetCloudFile(
name="example.txt",
text="this is text",
meta={"key": "value"}, # optional
)
],
blocking=True, # optional, by default True
timeout_s=300, # optional, by default 300
)
# Run the async function
if __name__ == "__main__":
asyncio.run(my_async_context())
```
"""
async with FilesService.factory(_get_config(api_key=api_key, api_url=api_url)) as file_service:
return await file_service.upload_in_memory(
Expand Down
19 changes: 19 additions & 0 deletions deepset_cloud_sdk/workflows/sync_client/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ def upload_texts(
:param blocking: Whether to wait for the files to be uploaded and listed in deepset Cloud.
:param timeout_s: Timeout in seconds for the `blocking` parameter.
:param show_progress: Shows the upload progress.
Example:
```python
from deepset_cloud_sdk.workflows.sync_client.files import upload_texts, DeepsetCloudFile
upload_texts(
api_key="<deepsetCloud_API_key>",
workspace_name="<default_workspace>", # optional, by default the environment variable "DEFAULT_WORKSPACE_NAME" is used
files=[
DeepsetCloudFile(
name="example.txt",
text="this is text",
meta={"key": "value"}, # optional
)
],
blocking=True, # optional, by default True
timeout_s=300, # optional, by default 300
)
```
"""
return asyncio.run(
async_upload_texts(
Expand Down

0 comments on commit 066f14c

Please sign in to comment.