feat: Adding OpenAI Compatible Prompts API

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-09-03 14:14:54 -04:00
parent 30117dea22
commit 8b00883abd
181 changed files with 21356 additions and 10332 deletions

View file

@ -0,0 +1,45 @@
# 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"}},
]