-
Notifications
You must be signed in to change notification settings - Fork 1
feat: initial release #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
fadf2ae
initial release, with chat completions, files, and limited apps API …
5a24d97
update lockfile, try to fix pipeline
67bb3ae
fix makefile, one more attempt to fix pipeline
c67a419
fix ort pipeline
37586e5
add new account to code owners
c646f81
fix ort one more time
1fcc22b
fixes due to pr comments
863adb3
remove examples from ort
4e6d38d
Fix typing of FileContent
398caf2
remove typing ignore for files
8a26c63
add aiofiles parametrization for tests
7d50314
refactor auth function/naming, use assert never for unreachable
ecb5f4c
One more minor refactor of auth
d5c2bd0
refactor auth one more time, refactor client interface
82d83eb
refactor my_bucket for clients
293c116
Remove redundant cast
cedac60
fix for appdata return type
374ebb5
Another bunch of refactor for helpers
7de45fe
Bunch of refactoring, fix unit tests
1a7edd7
More refactoring
199b8ad
remove dead code
5e261c2
another naming refactor
6b146bc
Remove formatting error as chunk during streaming
878184e
Remove formatting error as chunk during streaming (forgotten part)
1f18bb8
Minor refactor
8f7f911
Refactor, rename exceptions with `error` postfix
41b225c
Minor linter fix
5d6df56
Refactoring for metadata type, avoid pydantic warnings
b7406e3
Fix compatibility with pydantic v2
58d0757
Minor fix
6f46d09
rework storage resource parser
86e68e4
Fix test case, when url is like `/files...`, add unit test for that
3aa5b6a
Minor refactor
3c54eb3
Minor refactor
646abf3
naming refactor
6b74f0c
refactor of deployments, test fix
fe8218a
One more interface change for deployments - remove `get_raw`
a082db2
Minor comment fix
b2a03ec
fix integration tests (`deployment.get()`)
c63070e
Bump github workflow
945a360
Fix linter
bd3b409
forgotten commit - relax aiofiles dependency
ef57a54
update poetry lock
b437cd1
add test for attachments
88a200a
relax aiofiles dependency even more
fbeb565
update noxfile to test lower version of aiofiles
ae84bb0
update noxfile one more time, remove few typing ignores
436e07e
refactor appdata for client
d38844e
narrow down allowed link in storage resource parser
b49005b
naming refactor
0b22a77
add test for metadata
bc127ca
Fix metadata, improve tests
d2d1e95
Fix naming of internal http client
71822a1
Replace docstring with just comment
64deba4
Refactor _my_appdata property, use NOT_GIVEN for it
21acd43
Fix client pool test
1457f55
Refine storage resource helpers, introduce new exception `NotDialURLE…
3d35f36
More refactoring, fix minor bug with storage resource
65da79b
fix ort ignore rule
90867df
Minor refactor
ca193a0
Refactor error naming
b2da8a6
refactor - make is_directory private
3839de3
Refactor docstring
6d3ad48
Refactor: capitalize `url` to `URL` in error message
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| * @adubovik | ||
| * @adubovik @roman-romanov-o | ||
| /.github/ @nepalevov @alexey-ban |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from aidial_client._auth import AsyncAuthValue, AuthType, SyncAuthValue | ||
| from aidial_client._client import AsyncDial, Dial | ||
| from aidial_client._client_pool import AsyncDialClientPool, DialClientPool | ||
| from aidial_client._exception import ( | ||
| DialException, | ||
| InvalidDialURLError, | ||
| InvalidRequestError, | ||
| ParsingDataError, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "Dial", | ||
| "AsyncDial", | ||
| "DialClientPool", | ||
| "AsyncDialClientPool", | ||
| "AuthType", | ||
| "SyncAuthValue", | ||
| "AsyncAuthValue", | ||
| # Exceptions | ||
| "DialException", | ||
| "InvalidDialURLError", | ||
| "InvalidRequestError", | ||
| "ParsingDataError", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| from enum import Enum | ||
| from inspect import isawaitable | ||
| from typing import ( | ||
| Awaitable, | ||
| Callable, | ||
| Dict, | ||
| Optional, | ||
| Tuple, | ||
| TypeVar, | ||
| Union, | ||
| overload, | ||
| ) | ||
|
|
||
| from typing_extensions import assert_never | ||
|
|
||
|
|
||
| class AuthType(Enum): | ||
| API_KEY = "API_KEY" | ||
| BEARER = "BEARER" | ||
|
|
||
|
|
||
| SyncAuthValue = Union[str, Callable[[], str]] | ||
| AsyncAuthValue = Union[SyncAuthValue, Callable[[], Awaitable[str]]] | ||
|
|
||
| AuthValueT = TypeVar( | ||
| "AuthValueT", | ||
| bound=Union[SyncAuthValue, AsyncAuthValue], | ||
|
adubovik marked this conversation as resolved.
|
||
| ) | ||
|
|
||
|
|
||
| @overload | ||
| def get_auth_value(auth_value: SyncAuthValue) -> str: ... | ||
|
|
||
|
|
||
| @overload | ||
| def get_auth_value( | ||
| auth_value: AsyncAuthValue, | ||
| ) -> Union[str, Awaitable[str]]: ... | ||
|
|
||
|
|
||
| def get_auth_value( | ||
| auth_value: Union[SyncAuthValue, AsyncAuthValue] | ||
| ) -> Union[str, Awaitable[str]]: | ||
| if isinstance(auth_value, str): | ||
| return auth_value | ||
| elif callable(auth_value): | ||
| return auth_value() | ||
| else: | ||
| assert_never(auth_value) | ||
|
|
||
|
|
||
| async def aget_auth_value(auth_value: AsyncAuthValue) -> str: | ||
| processed_auth_value = get_auth_value(auth_value) | ||
| if isawaitable(processed_auth_value): | ||
| return await processed_auth_value | ||
| return processed_auth_value | ||
|
|
||
|
|
||
| def _get_auth_headers(auth_type: AuthType, auth_value: str) -> Dict[str, str]: | ||
| if auth_type == AuthType.API_KEY: | ||
| return {"api-key": auth_value} | ||
| elif auth_type == AuthType.BEARER: | ||
| return {"Authorization": f"Bearer {auth_value}"} | ||
| else: | ||
| assert_never(auth_type) | ||
|
|
||
|
|
||
| def get_auth_headers( | ||
| *, | ||
| auth_value: SyncAuthValue, | ||
| auth_type: AuthType, | ||
| ) -> Dict[str, str]: | ||
| processed_auth_value = get_auth_value(auth_value) | ||
| return _get_auth_headers(auth_type, processed_auth_value) | ||
|
|
||
|
|
||
| async def aget_auth_headers( | ||
| auth_value: AsyncAuthValue, | ||
| auth_type: AuthType, | ||
| ) -> Dict[str, str]: | ||
| processed_auth_value = await aget_auth_value(auth_value) | ||
| return _get_auth_headers(auth_type, processed_auth_value) | ||
|
|
||
|
|
||
| def process_auth( | ||
| *, | ||
| api_key: Optional[AuthValueT] = None, | ||
| bearer_token: Optional[AuthValueT] = None, | ||
| ) -> Tuple[AuthType, AuthValueT]: | ||
| if api_key and bearer_token: | ||
| raise ValueError( | ||
| "Either api_key or bearer_token must be provided, but not both" | ||
| ) | ||
| elif api_key: | ||
| return AuthType.API_KEY, api_key | ||
| elif bearer_token: | ||
| return AuthType.BEARER, bearer_token | ||
| else: | ||
| raise ValueError("Either api_key or bearer_token must be provided") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.