mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-29 23:29:43 +00:00
test client:
This commit is contained in:
parent
bb43369521
commit
51d5ad67c4
1 changed files with 1 additions and 17 deletions
|
@ -5,9 +5,7 @@
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -19,21 +17,7 @@ from termcolor import cprint
|
||||||
from .datasets import * # noqa: F403
|
from .datasets import * # noqa: F403
|
||||||
from llama_stack.apis.datasets import * # noqa: F403
|
from llama_stack.apis.datasets import * # noqa: F403
|
||||||
from llama_stack.apis.common.type_system import * # noqa: F403
|
from llama_stack.apis.common.type_system import * # noqa: F403
|
||||||
|
from llama_stack.providers.tests.datasetio.test_datasetio import data_url_from_file
|
||||||
|
|
||||||
def data_url_from_file(file_path: str) -> str:
|
|
||||||
if not os.path.exists(file_path):
|
|
||||||
raise FileNotFoundError(f"File not found: {file_path}")
|
|
||||||
|
|
||||||
with open(file_path, "rb") as file:
|
|
||||||
file_content = file.read()
|
|
||||||
|
|
||||||
base64_content = base64.b64encode(file_content).decode("utf-8")
|
|
||||||
mime_type, _ = mimetypes.guess_type(file_path)
|
|
||||||
|
|
||||||
data_url = f"data:{mime_type};base64,{base64_content}"
|
|
||||||
|
|
||||||
return data_url
|
|
||||||
|
|
||||||
|
|
||||||
class DatasetsClient(Datasets):
|
class DatasetsClient(Datasets):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue