mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-23 19:23:59 +00:00
chore: Enabling teste for Weaviate and some minor changes
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
266e2afb9c
commit
01d90eb8ab
17 changed files with 216 additions and 103 deletions
|
|
@ -30,7 +30,7 @@ from llama_stack.providers.datatypes import Api
|
|||
from llama_stack.providers.utils.inference.prompt_adapter import (
|
||||
interleaved_content_as_str,
|
||||
)
|
||||
from llama_stack.providers.utils.vector_io.chunk_utils import generate_chunk_id
|
||||
from llama_stack.providers.utils.vector_io.vector_utils import generate_chunk_id
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
# the root directory of this source tree.
|
||||
|
||||
import hashlib
|
||||
import re
|
||||
import uuid
|
||||
|
||||
|
||||
|
|
@ -19,3 +20,20 @@ def generate_chunk_id(document_id: str, chunk_text: str, chunk_window: str | Non
|
|||
if chunk_window:
|
||||
hash_input += f":{chunk_window}".encode()
|
||||
return str(uuid.UUID(hashlib.md5(hash_input, usedforsecurity=False).hexdigest()))
|
||||
|
||||
|
||||
def proper_case(s: str) -> str:
|
||||
"""Convert a string to proper case (first letter uppercase, rest lowercase)."""
|
||||
return s[0].upper() + s[1:].lower() if s else s
|
||||
|
||||
|
||||
def sanitize_collection_name(name: str, weaviate_format=False) -> str:
|
||||
"""
|
||||
Sanitize collection name to ensure it only contains numbers, letters, and underscores.
|
||||
Any other characters are replaced with underscores.
|
||||
"""
|
||||
if not weaviate_format:
|
||||
s = re.sub(r"[^a-zA-Z0-9_]", "_", name)
|
||||
else:
|
||||
s = proper_case(re.sub(r"[^a-zA-Z0-9]", "", name))
|
||||
return s
|
||||
Loading…
Add table
Add a link
Reference in a new issue