llama-stack-mirror/tests/unit/providers/prompts/conftest.py
Francisco Javier Arceo 8b00883abd feat: Adding OpenAI Compatible Prompts API
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
2025-09-04 12:56:32 -04:00

45 lines
1.3 KiB
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
import os
import tempfile
import pytest
from llama_stack.core.prompts.prompts import PromptServiceConfig, PromptServiceImpl
from llama_stack.providers.utils.kvstore.config import SqliteKVStoreConfig
@pytest.fixture
async def temp_prompt_store():
with tempfile.NamedTemporaryFile(delete=False, suffix=".db") as tmp_file:
db_path = tmp_file.name
try:
config = PromptServiceConfig(kvstore=SqliteKVStoreConfig(db_path=db_path))
store = PromptServiceImpl(config, deps={})
await store.initialize()
yield store
finally:
if os.path.exists(db_path):
os.unlink(db_path)
@pytest.fixture
def sample_prompt_data():
return {
"prompt": "Hello {{name}}, welcome to {{platform}}!",
"variables": {"name": "John", "platform": "LlamaStack"},
}
@pytest.fixture
def sample_prompts_data():
return [
{"prompt": "Hello {{name}}!", "variables": {"name": "Alice"}},
{"prompt": "Welcome to {{platform}}, {{user}}!", "variables": {"platform": "LlamaStack", "user": "Bob"}},
{"prompt": "Your order {{order_id}} is ready for pickup.", "variables": {"order_id": "12345"}},
]