test client:

This commit is contained in:
Xi Yan 2024-10-23 13:55:55 -07:00
parent bb43369521
commit 51d5ad67c4

View file

@ -5,9 +5,7 @@
# the root directory of this source tree.
import asyncio
import base64
import json
import mimetypes
import os
from pathlib import Path
from typing import Optional
@ -19,21 +17,7 @@ from termcolor import cprint
from .datasets import * # noqa: F403
from llama_stack.apis.datasets import * # noqa: F403
from llama_stack.apis.common.type_system import * # noqa: F403
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
from llama_stack.providers.tests.datasetio.test_datasetio import data_url_from_file
class DatasetsClient(Datasets):