Skip to content

Commit

Permalink
Update version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kooyunmo committed Dec 28, 2023
1 parent e244c89 commit 8dac6f6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 248 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Copyright (c) 2022-present, FriendliAI Inc. All rights reserved.
-->

<p align="center">
<img src="https://docs.friendli.ai/img/logo.svg" width="80%" alt="system">
<img src="https://docs.friendli.ai/img/favicon.svg" width="30%" alt="Friendli Logo">
</p>

<h2><p align="center">Supercharge Generative AI Serving 🚀</p></h2>
<h2><p align="center">Supercharge Generative AI Serving with Friendli 🚀</p></h2>

<p align="center">
<a href="https://github.com/friendliai/friendli-client/actions/workflows/ci.yaml">
Expand Down Expand Up @@ -57,12 +57,13 @@ Check out [Friendli Client Docs](https://docs.friendli.ai/) to learn more.
pip install friendli-client
```

If you have a Hugging Face checkpoint and want to convert it to a Friendli-compatible format with applying quantization, you need to install the package with the necessary machine learing library (`mllib`) dependencies.
In this case, install the package with the following command:

```sh
pip install "friendli-client[mllib]"
```
> [!NOTE]
> If you have a Hugging Face checkpoint and want to convert it to a Friendli-compatible format with applying quantization, you need to install the package with the necessary machine learing library (`mllib`) dependencies.
> In this case, install the package with the following command:
>
> ```sh
> pip install "friendli-client[mllib]"
> ```
## Examples

Expand Down
8 changes: 7 additions & 1 deletion friendli/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ def login(
json={"username": email, "password": password},
timeout=DEFAULT_REQ_TIMEOUT,
)
resp = r.json()
try:
resp = r.json()
except requests.exceptions.JSONDecodeError:
if r.status_code != 200:
secho_error_and_exit(r.content.decode())
secho_error_and_exit("Invalid response format.")

if "code" in resp and resp["code"] == "mfa_required":
mfa_token = resp["mfaToken"]
client = UserMFAClient()
Expand Down
13 changes: 7 additions & 6 deletions friendli/sdk/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from friendli.schema.api.v1.codegen.chat_completions_pb2 import V1ChatCompletionsRequest
from friendli.schema.api.v1.codegen.completions_pb2 import V1CompletionsRequest
from friendli.utils.request import DEFAULT_REQ_TIMEOUT
from friendli.utils.url import get_baseurl
from friendli.utils.url import get_host

_GenerationLine = TypeVar("_GenerationLine", bound=BaseModel)

Expand Down Expand Up @@ -95,9 +95,9 @@ def __init__(
endpoint = deployment["endpoint"]
if not endpoint:
raise NotFoundError("Active endpoint for the deployment is not found.")
self._endpoint = httpx.URL(get_baseurl(endpoint)).join(deployment_id)
self._host = httpx.URL(get_host(endpoint))
elif endpoint is not None:
self._endpoint = httpx.URL(endpoint)
self._host = httpx.URL(endpoint)

def _get_headers(self) -> Dict[str, Any]:
content_type = (
Expand Down Expand Up @@ -147,9 +147,9 @@ def _build_url(self, model: Optional[str] = None) -> httpx.URL:
if model is not None:
path = model
if self._deployment_id is not None:
path = os.path.join(path, self._deployment_id)
path = self._deployment_id
path = os.path.join(path, self._api_path)
return self._endpoint.join(path)
return self._host.join(path)

def _build_data(self, data: dict[str, Any]) -> bytes:
if self._deployment_id is None:
Expand Down Expand Up @@ -183,7 +183,8 @@ def _request(
response = self._client.send(request=request, stream=stream)
response.raise_for_status()
except httpx.HTTPStatusError as exc:
raise APIError(repr(response)) from exc
resp_content = response.read()
raise APIError(resp_content.decode()) from exc

return response

Expand Down
8 changes: 4 additions & 4 deletions friendli/utils/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
discuss_url = "https://discuss.friendli.ai/"


def get_baseurl(url: str) -> str:
"""Get a base of a URL."""
def get_host(url: str) -> str:
"""Get a host part of a URL."""
parsed_url = urlparse(url)
scheme = parsed_url.scheme
base = parsed_url.netloc
return f"{scheme}://{base}/"
netloc = parsed_url.netloc
return f"{scheme}://{netloc}/"


class URLProvider:
Expand Down
Loading

0 comments on commit 8dac6f6

Please sign in to comment.