Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get_download_file_token method to client #997

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/python-beta/src/bailo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

# SEMANTIC VERSION
__version__ = "0.3.0"
__version__ = "0.4.0"

from bailo.core.agent import Agent, PkiAgent, TokenAgent
from bailo.core.client import Client
Expand Down
10 changes: 8 additions & 2 deletions lib/python-beta/src/bailo/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from io import BytesIO
from typing import Any

from bailo.core.agent import Agent
from bailo.core.agent import Agent, TokenAgent
from bailo.core.enums import ModelVisibility, SchemaKind
from bailo.core.utils import filter_none

Expand Down Expand Up @@ -311,7 +311,13 @@ def get_download_file(
:param buffer: BytesIO object for bailo to write to
:return: The unique file ID
"""
req = self.agent.get(f"{self.url}/v2/model/{model_id}/file/{file_id}/download", stream=True, timeout=10_000)
if isinstance(self.agent, TokenAgent):
req = self.agent.get(
f"{self.url}/v2/token/model/{model_id}/file/{file_id}/download", stream=True, timeout=10_000
)
else:
req = self.agent.get(f"{self.url}/v2/model/{model_id}/file/{file_id}/download", stream=True, timeout=10_000)

shutil.copyfileobj(req.raw, buffer)
return file_id

Expand Down
Loading