From 9076380bbfa83249412cf50253723c5aea2fb8c6 Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Wed, 22 Jan 2025 21:54:56 -0800 Subject: [PATCH] Sync updates from stainless branch: ashwinb/dev --- src/llama_stack_client/resources/safety.py | 5 +- .../resources/tool_runtime/rag_tool.py | 14 ++-- src/llama_stack_client/types/__init__.py | 3 + .../types/agents/step_retrieve_response.py | 8 ++- src/llama_stack_client/types/agents/turn.py | 8 ++- .../types/agents/turn_create_response.py | 47 ++++++++------ .../types/eval_evaluate_rows_params.py | 65 +++++++++---------- .../types/eval_run_eval_params.py | 65 +++++++++---------- .../types/inference_chat_completion_params.py | 10 +-- .../types/inference_completion_params.py | 10 +-- ...st_training_supervised_fine_tune_params.py | 10 +-- src/llama_stack_client/types/scoring_fn.py | 21 +++--- .../types/scoring_function_register_params.py | 16 ++--- .../types/scoring_score_batch_params.py | 18 ++--- .../types/scoring_score_params.py | 18 ++--- .../types/shared/__init__.py | 3 + .../types/shared/content_delta.py | 19 +++--- .../types/shared/document.py | 41 ++++++++++++ .../types/shared/interleaved_content_item.py | 15 +++-- .../types/shared/message.py | 7 +- .../types/shared/param_type.py | 61 ++++++++--------- .../types/shared/query_config.py | 36 ++++++++++ .../types/shared/query_result.py | 12 ++++ .../types/shared/sampling_params.py | 19 ++---- .../types/shared_params/__init__.py | 2 + .../types/shared_params/document.py | 42 ++++++++++++ .../shared_params/interleaved_content_item.py | 12 ++-- .../types/shared_params/param_type.py | 55 +++++++--------- .../types/shared_params/query_config.py | 33 ++++++++++ .../types/shared_params/sampling_params.py | 16 ++--- .../types/telemetry_log_event_params.py | 30 ++++----- .../types/tool_runtime/__init__.py | 3 - .../tool_runtime/rag_tool_insert_params.py | 4 +- .../tool_runtime/rag_tool_query_params.py | 4 +- .../tool_runtime/test_rag_tool.py | 4 +- 35 files changed, 434 insertions(+), 302 deletions(-) create mode 100644 src/llama_stack_client/types/shared/document.py create mode 100644 src/llama_stack_client/types/shared/query_config.py create mode 100644 src/llama_stack_client/types/shared/query_result.py create mode 100644 src/llama_stack_client/types/shared_params/document.py create mode 100644 src/llama_stack_client/types/shared_params/query_config.py diff --git a/src/llama_stack_client/resources/safety.py b/src/llama_stack_client/resources/safety.py index a48d2a71..bc6333e4 100644 --- a/src/llama_stack_client/resources/safety.py +++ b/src/llama_stack_client/resources/safety.py @@ -23,6 +23,7 @@ ) from .._base_client import make_request_options from ..types.run_shield_response import RunShieldResponse +from ..types.shared_params.message import Message __all__ = ["SafetyResource", "AsyncSafetyResource"] @@ -50,7 +51,7 @@ def with_streaming_response(self) -> SafetyResourceWithStreamingResponse: def run_shield( self, *, - messages: Iterable[safety_run_shield_params.Message], + messages: Iterable[Message], params: Dict[str, Union[bool, float, str, Iterable[object], object, None]], shield_id: str, x_llama_stack_client_version: str | NotGiven = NOT_GIVEN, @@ -121,7 +122,7 @@ def with_streaming_response(self) -> AsyncSafetyResourceWithStreamingResponse: async def run_shield( self, *, - messages: Iterable[safety_run_shield_params.Message], + messages: Iterable[Message], params: Dict[str, Union[bool, float, str, Iterable[object], object, None]], shield_id: str, x_llama_stack_client_version: str | NotGiven = NOT_GIVEN, diff --git a/src/llama_stack_client/resources/tool_runtime/rag_tool.py b/src/llama_stack_client/resources/tool_runtime/rag_tool.py index c7f49758..49cf1f67 100644 --- a/src/llama_stack_client/resources/tool_runtime/rag_tool.py +++ b/src/llama_stack_client/resources/tool_runtime/rag_tool.py @@ -22,9 +22,9 @@ ) from ..._base_client import make_request_options from ...types.tool_runtime import rag_tool_query_params, rag_tool_insert_params -from ...types.tool_runtime.query_result import QueryResult -from ...types.tool_runtime.document_param import DocumentParam -from ...types.tool_runtime.query_config_param import QueryConfigParam +from ...types.shared.query_result import QueryResult +from ...types.shared_params.document import Document +from ...types.shared_params.query_config import QueryConfig from ...types.shared_params.interleaved_content import InterleavedContent __all__ = ["RagToolResource", "AsyncRagToolResource"] @@ -54,7 +54,7 @@ def insert( self, *, chunk_size_in_tokens: int, - documents: Iterable[DocumentParam], + documents: Iterable[Document], vector_db_id: str, x_llama_stack_client_version: str | NotGiven = NOT_GIVEN, x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN, @@ -108,7 +108,7 @@ def query( *, content: InterleavedContent, vector_db_ids: List[str], - query_config: QueryConfigParam | NotGiven = NOT_GIVEN, + query_config: QueryConfig | NotGiven = NOT_GIVEN, x_llama_stack_client_version: str | NotGiven = NOT_GIVEN, x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -180,7 +180,7 @@ async def insert( self, *, chunk_size_in_tokens: int, - documents: Iterable[DocumentParam], + documents: Iterable[Document], vector_db_id: str, x_llama_stack_client_version: str | NotGiven = NOT_GIVEN, x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN, @@ -234,7 +234,7 @@ async def query( *, content: InterleavedContent, vector_db_ids: List[str], - query_config: QueryConfigParam | NotGiven = NOT_GIVEN, + query_config: QueryConfig | NotGiven = NOT_GIVEN, x_llama_stack_client_version: str | NotGiven = NOT_GIVEN, x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. diff --git a/src/llama_stack_client/types/__init__.py b/src/llama_stack_client/types/__init__.py index c7200d37..015843c5 100644 --- a/src/llama_stack_client/types/__init__.py +++ b/src/llama_stack_client/types/__init__.py @@ -9,10 +9,13 @@ from .shared import ( URL as URL, Message as Message, + Document as Document, ToolCall as ToolCall, ParamType as ParamType, ReturnType as ReturnType, AgentConfig as AgentConfig, + QueryConfig as QueryConfig, + QueryResult as QueryResult, UserMessage as UserMessage, ContentDelta as ContentDelta, ScoringResult as ScoringResult, diff --git a/src/llama_stack_client/types/agents/step_retrieve_response.py b/src/llama_stack_client/types/agents/step_retrieve_response.py index 77376b4f..8102e105 100644 --- a/src/llama_stack_client/types/agents/step_retrieve_response.py +++ b/src/llama_stack_client/types/agents/step_retrieve_response.py @@ -1,8 +1,9 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union -from typing_extensions import TypeAlias +from typing_extensions import Annotated, TypeAlias +from ..._utils import PropertyInfo from ..._models import BaseModel from ..inference_step import InferenceStep from ..shield_call_step import ShieldCallStep @@ -11,7 +12,10 @@ __all__ = ["StepRetrieveResponse", "Step"] -Step: TypeAlias = Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep] +Step: TypeAlias = Annotated[ + Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep], + PropertyInfo(discriminator="step_type"), +] class StepRetrieveResponse(BaseModel): diff --git a/src/llama_stack_client/types/agents/turn.py b/src/llama_stack_client/types/agents/turn.py index 07f0218b..610da1a9 100644 --- a/src/llama_stack_client/types/agents/turn.py +++ b/src/llama_stack_client/types/agents/turn.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias +from ..._utils import PropertyInfo from ..._models import BaseModel from ..shared.url import URL from ..inference_step import InferenceStep @@ -62,7 +63,10 @@ class OutputAttachment(BaseModel): mime_type: str -Step: TypeAlias = Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep] +Step: TypeAlias = Annotated[ + Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep], + PropertyInfo(discriminator="step_type"), +] class Turn(BaseModel): diff --git a/src/llama_stack_client/types/agents/turn_create_response.py b/src/llama_stack_client/types/agents/turn_create_response.py index 055c1fe6..16f48abe 100644 --- a/src/llama_stack_client/types/agents/turn_create_response.py +++ b/src/llama_stack_client/types/agents/turn_create_response.py @@ -1,9 +1,10 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Dict, List, Union, Optional -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias from .turn import Turn +from ..._utils import PropertyInfo from ..._models import BaseModel from ..inference_step import InferenceStep from ..shield_call_step import ShieldCallStep @@ -16,16 +17,16 @@ "AgentTurnResponseStreamChunk", "AgentTurnResponseStreamChunkEvent", "AgentTurnResponseStreamChunkEventPayload", - "AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepStartPayload", - "AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepProgressPayload", - "AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepCompletePayload", - "AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepCompletePayloadStepDetails", - "AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseTurnStartPayload", - "AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseTurnCompletePayload", + "AgentTurnResponseStreamChunkEventPayloadStepStart", + "AgentTurnResponseStreamChunkEventPayloadStepProgress", + "AgentTurnResponseStreamChunkEventPayloadStepComplete", + "AgentTurnResponseStreamChunkEventPayloadStepCompleteStepDetails", + "AgentTurnResponseStreamChunkEventPayloadTurnStart", + "AgentTurnResponseStreamChunkEventPayloadTurnComplete", ] -class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepStartPayload(BaseModel): +class AgentTurnResponseStreamChunkEventPayloadStepStart(BaseModel): event_type: Literal["step_start"] step_id: str @@ -35,7 +36,7 @@ class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepStartPayload( metadata: Optional[Dict[str, Union[bool, float, str, List[object], object, None]]] = None -class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepProgressPayload(BaseModel): +class AgentTurnResponseStreamChunkEventPayloadStepProgress(BaseModel): delta: ContentDelta event_type: Literal["step_progress"] @@ -45,39 +46,43 @@ class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepProgressPaylo step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"] -AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepCompletePayloadStepDetails: TypeAlias = Union[ - InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep +AgentTurnResponseStreamChunkEventPayloadStepCompleteStepDetails: TypeAlias = Annotated[ + Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep], + PropertyInfo(discriminator="step_type"), ] -class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepCompletePayload(BaseModel): +class AgentTurnResponseStreamChunkEventPayloadStepComplete(BaseModel): event_type: Literal["step_complete"] - step_details: AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepCompletePayloadStepDetails + step_details: AgentTurnResponseStreamChunkEventPayloadStepCompleteStepDetails step_id: str step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"] -class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseTurnStartPayload(BaseModel): +class AgentTurnResponseStreamChunkEventPayloadTurnStart(BaseModel): event_type: Literal["turn_start"] turn_id: str -class AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseTurnCompletePayload(BaseModel): +class AgentTurnResponseStreamChunkEventPayloadTurnComplete(BaseModel): event_type: Literal["turn_complete"] turn: Turn -AgentTurnResponseStreamChunkEventPayload: TypeAlias = Union[ - AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepStartPayload, - AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepProgressPayload, - AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseStepCompletePayload, - AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseTurnStartPayload, - AgentTurnResponseStreamChunkEventPayloadAgentTurnResponseTurnCompletePayload, +AgentTurnResponseStreamChunkEventPayload: TypeAlias = Annotated[ + Union[ + AgentTurnResponseStreamChunkEventPayloadStepStart, + AgentTurnResponseStreamChunkEventPayloadStepProgress, + AgentTurnResponseStreamChunkEventPayloadStepComplete, + AgentTurnResponseStreamChunkEventPayloadTurnStart, + AgentTurnResponseStreamChunkEventPayloadTurnComplete, + ], + PropertyInfo(discriminator="event_type"), ] diff --git a/src/llama_stack_client/types/eval_evaluate_rows_params.py b/src/llama_stack_client/types/eval_evaluate_rows_params.py index 51271f8d..10e32ea7 100644 --- a/src/llama_stack_client/types/eval_evaluate_rows_params.py +++ b/src/llama_stack_client/types/eval_evaluate_rows_params.py @@ -13,18 +13,18 @@ __all__ = [ "EvalEvaluateRowsParams", "TaskConfig", - "TaskConfigBenchmarkEvalTaskConfig", - "TaskConfigBenchmarkEvalTaskConfigEvalCandidate", - "TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate", - "TaskConfigBenchmarkEvalTaskConfigEvalCandidateAgentCandidate", - "TaskConfigAppEvalTaskConfig", - "TaskConfigAppEvalTaskConfigEvalCandidate", - "TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate", - "TaskConfigAppEvalTaskConfigEvalCandidateAgentCandidate", - "TaskConfigAppEvalTaskConfigScoringParams", - "TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams", - "TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams", - "TaskConfigAppEvalTaskConfigScoringParamsBasicScoringFnParams", + "TaskConfigBenchmark", + "TaskConfigBenchmarkEvalCandidate", + "TaskConfigBenchmarkEvalCandidateModel", + "TaskConfigBenchmarkEvalCandidateAgent", + "TaskConfigApp", + "TaskConfigAppEvalCandidate", + "TaskConfigAppEvalCandidateModel", + "TaskConfigAppEvalCandidateAgent", + "TaskConfigAppScoringParams", + "TaskConfigAppScoringParamsLlmAsJudge", + "TaskConfigAppScoringParamsRegexParser", + "TaskConfigAppScoringParamsBasic", ] @@ -40,7 +40,7 @@ class EvalEvaluateRowsParams(TypedDict, total=False): x_llama_stack_provider_data: Annotated[str, PropertyInfo(alias="X-LlamaStack-Provider-Data")] -class TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate(TypedDict, total=False): +class TaskConfigBenchmarkEvalCandidateModel(TypedDict, total=False): model: Required[str] sampling_params: Required[SamplingParams] @@ -50,27 +50,26 @@ class TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate(TypedDict, to system_message: SystemMessage -class TaskConfigBenchmarkEvalTaskConfigEvalCandidateAgentCandidate(TypedDict, total=False): +class TaskConfigBenchmarkEvalCandidateAgent(TypedDict, total=False): config: Required[AgentConfig] type: Required[Literal["agent"]] -TaskConfigBenchmarkEvalTaskConfigEvalCandidate: TypeAlias = Union[ - TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate, - TaskConfigBenchmarkEvalTaskConfigEvalCandidateAgentCandidate, +TaskConfigBenchmarkEvalCandidate: TypeAlias = Union[ + TaskConfigBenchmarkEvalCandidateModel, TaskConfigBenchmarkEvalCandidateAgent ] -class TaskConfigBenchmarkEvalTaskConfig(TypedDict, total=False): - eval_candidate: Required[TaskConfigBenchmarkEvalTaskConfigEvalCandidate] +class TaskConfigBenchmark(TypedDict, total=False): + eval_candidate: Required[TaskConfigBenchmarkEvalCandidate] type: Required[Literal["benchmark"]] num_examples: int -class TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate(TypedDict, total=False): +class TaskConfigAppEvalCandidateModel(TypedDict, total=False): model: Required[str] sampling_params: Required[SamplingParams] @@ -80,18 +79,16 @@ class TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate(TypedDict, total=Fa system_message: SystemMessage -class TaskConfigAppEvalTaskConfigEvalCandidateAgentCandidate(TypedDict, total=False): +class TaskConfigAppEvalCandidateAgent(TypedDict, total=False): config: Required[AgentConfig] type: Required[Literal["agent"]] -TaskConfigAppEvalTaskConfigEvalCandidate: TypeAlias = Union[ - TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate, TaskConfigAppEvalTaskConfigEvalCandidateAgentCandidate -] +TaskConfigAppEvalCandidate: TypeAlias = Union[TaskConfigAppEvalCandidateModel, TaskConfigAppEvalCandidateAgent] -class TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams(TypedDict, total=False): +class TaskConfigAppScoringParamsLlmAsJudge(TypedDict, total=False): judge_model: Required[str] type: Required[Literal["llm_as_judge"]] @@ -103,7 +100,7 @@ class TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams(TypedDic prompt_template: str -class TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams(TypedDict, total=False): +class TaskConfigAppScoringParamsRegexParser(TypedDict, total=False): type: Required[Literal["regex_parser"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] @@ -111,27 +108,25 @@ class TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams(TypedDi parsing_regexes: List[str] -class TaskConfigAppEvalTaskConfigScoringParamsBasicScoringFnParams(TypedDict, total=False): +class TaskConfigAppScoringParamsBasic(TypedDict, total=False): type: Required[Literal["basic"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] -TaskConfigAppEvalTaskConfigScoringParams: TypeAlias = Union[ - TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams, - TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams, - TaskConfigAppEvalTaskConfigScoringParamsBasicScoringFnParams, +TaskConfigAppScoringParams: TypeAlias = Union[ + TaskConfigAppScoringParamsLlmAsJudge, TaskConfigAppScoringParamsRegexParser, TaskConfigAppScoringParamsBasic ] -class TaskConfigAppEvalTaskConfig(TypedDict, total=False): - eval_candidate: Required[TaskConfigAppEvalTaskConfigEvalCandidate] +class TaskConfigApp(TypedDict, total=False): + eval_candidate: Required[TaskConfigAppEvalCandidate] - scoring_params: Required[Dict[str, TaskConfigAppEvalTaskConfigScoringParams]] + scoring_params: Required[Dict[str, TaskConfigAppScoringParams]] type: Required[Literal["app"]] num_examples: int -TaskConfig: TypeAlias = Union[TaskConfigBenchmarkEvalTaskConfig, TaskConfigAppEvalTaskConfig] +TaskConfig: TypeAlias = Union[TaskConfigBenchmark, TaskConfigApp] diff --git a/src/llama_stack_client/types/eval_run_eval_params.py b/src/llama_stack_client/types/eval_run_eval_params.py index 0865a74a..87f4928b 100644 --- a/src/llama_stack_client/types/eval_run_eval_params.py +++ b/src/llama_stack_client/types/eval_run_eval_params.py @@ -13,18 +13,18 @@ __all__ = [ "EvalRunEvalParams", "TaskConfig", - "TaskConfigBenchmarkEvalTaskConfig", - "TaskConfigBenchmarkEvalTaskConfigEvalCandidate", - "TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate", - "TaskConfigBenchmarkEvalTaskConfigEvalCandidateAgentCandidate", - "TaskConfigAppEvalTaskConfig", - "TaskConfigAppEvalTaskConfigEvalCandidate", - "TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate", - "TaskConfigAppEvalTaskConfigEvalCandidateAgentCandidate", - "TaskConfigAppEvalTaskConfigScoringParams", - "TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams", - "TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams", - "TaskConfigAppEvalTaskConfigScoringParamsBasicScoringFnParams", + "TaskConfigBenchmark", + "TaskConfigBenchmarkEvalCandidate", + "TaskConfigBenchmarkEvalCandidateModel", + "TaskConfigBenchmarkEvalCandidateAgent", + "TaskConfigApp", + "TaskConfigAppEvalCandidate", + "TaskConfigAppEvalCandidateModel", + "TaskConfigAppEvalCandidateAgent", + "TaskConfigAppScoringParams", + "TaskConfigAppScoringParamsLlmAsJudge", + "TaskConfigAppScoringParamsRegexParser", + "TaskConfigAppScoringParamsBasic", ] @@ -36,7 +36,7 @@ class EvalRunEvalParams(TypedDict, total=False): x_llama_stack_provider_data: Annotated[str, PropertyInfo(alias="X-LlamaStack-Provider-Data")] -class TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate(TypedDict, total=False): +class TaskConfigBenchmarkEvalCandidateModel(TypedDict, total=False): model: Required[str] sampling_params: Required[SamplingParams] @@ -46,27 +46,26 @@ class TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate(TypedDict, to system_message: SystemMessage -class TaskConfigBenchmarkEvalTaskConfigEvalCandidateAgentCandidate(TypedDict, total=False): +class TaskConfigBenchmarkEvalCandidateAgent(TypedDict, total=False): config: Required[AgentConfig] type: Required[Literal["agent"]] -TaskConfigBenchmarkEvalTaskConfigEvalCandidate: TypeAlias = Union[ - TaskConfigBenchmarkEvalTaskConfigEvalCandidateModelCandidate, - TaskConfigBenchmarkEvalTaskConfigEvalCandidateAgentCandidate, +TaskConfigBenchmarkEvalCandidate: TypeAlias = Union[ + TaskConfigBenchmarkEvalCandidateModel, TaskConfigBenchmarkEvalCandidateAgent ] -class TaskConfigBenchmarkEvalTaskConfig(TypedDict, total=False): - eval_candidate: Required[TaskConfigBenchmarkEvalTaskConfigEvalCandidate] +class TaskConfigBenchmark(TypedDict, total=False): + eval_candidate: Required[TaskConfigBenchmarkEvalCandidate] type: Required[Literal["benchmark"]] num_examples: int -class TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate(TypedDict, total=False): +class TaskConfigAppEvalCandidateModel(TypedDict, total=False): model: Required[str] sampling_params: Required[SamplingParams] @@ -76,18 +75,16 @@ class TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate(TypedDict, total=Fa system_message: SystemMessage -class TaskConfigAppEvalTaskConfigEvalCandidateAgentCandidate(TypedDict, total=False): +class TaskConfigAppEvalCandidateAgent(TypedDict, total=False): config: Required[AgentConfig] type: Required[Literal["agent"]] -TaskConfigAppEvalTaskConfigEvalCandidate: TypeAlias = Union[ - TaskConfigAppEvalTaskConfigEvalCandidateModelCandidate, TaskConfigAppEvalTaskConfigEvalCandidateAgentCandidate -] +TaskConfigAppEvalCandidate: TypeAlias = Union[TaskConfigAppEvalCandidateModel, TaskConfigAppEvalCandidateAgent] -class TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams(TypedDict, total=False): +class TaskConfigAppScoringParamsLlmAsJudge(TypedDict, total=False): judge_model: Required[str] type: Required[Literal["llm_as_judge"]] @@ -99,7 +96,7 @@ class TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams(TypedDic prompt_template: str -class TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams(TypedDict, total=False): +class TaskConfigAppScoringParamsRegexParser(TypedDict, total=False): type: Required[Literal["regex_parser"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] @@ -107,27 +104,25 @@ class TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams(TypedDi parsing_regexes: List[str] -class TaskConfigAppEvalTaskConfigScoringParamsBasicScoringFnParams(TypedDict, total=False): +class TaskConfigAppScoringParamsBasic(TypedDict, total=False): type: Required[Literal["basic"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] -TaskConfigAppEvalTaskConfigScoringParams: TypeAlias = Union[ - TaskConfigAppEvalTaskConfigScoringParamsLlmAsJudgeScoringFnParams, - TaskConfigAppEvalTaskConfigScoringParamsRegexParserScoringFnParams, - TaskConfigAppEvalTaskConfigScoringParamsBasicScoringFnParams, +TaskConfigAppScoringParams: TypeAlias = Union[ + TaskConfigAppScoringParamsLlmAsJudge, TaskConfigAppScoringParamsRegexParser, TaskConfigAppScoringParamsBasic ] -class TaskConfigAppEvalTaskConfig(TypedDict, total=False): - eval_candidate: Required[TaskConfigAppEvalTaskConfigEvalCandidate] +class TaskConfigApp(TypedDict, total=False): + eval_candidate: Required[TaskConfigAppEvalCandidate] - scoring_params: Required[Dict[str, TaskConfigAppEvalTaskConfigScoringParams]] + scoring_params: Required[Dict[str, TaskConfigAppScoringParams]] type: Required[Literal["app"]] num_examples: int -TaskConfig: TypeAlias = Union[TaskConfigBenchmarkEvalTaskConfig, TaskConfigAppEvalTaskConfig] +TaskConfig: TypeAlias = Union[TaskConfigBenchmark, TaskConfigApp] diff --git a/src/llama_stack_client/types/inference_chat_completion_params.py b/src/llama_stack_client/types/inference_chat_completion_params.py index 3550eaa8..4d22a7d2 100644 --- a/src/llama_stack_client/types/inference_chat_completion_params.py +++ b/src/llama_stack_client/types/inference_chat_completion_params.py @@ -14,8 +14,8 @@ "InferenceChatCompletionParamsBase", "Logprobs", "ResponseFormat", - "ResponseFormatUnionMember0", - "ResponseFormatUnionMember1", + "ResponseFormatJsonSchema", + "ResponseFormatGrammar", "Tool", "InferenceChatCompletionParamsNonStreaming", "InferenceChatCompletionParamsStreaming", @@ -59,19 +59,19 @@ class Logprobs(TypedDict, total=False): top_k: int -class ResponseFormatUnionMember0(TypedDict, total=False): +class ResponseFormatJsonSchema(TypedDict, total=False): json_schema: Required[Dict[str, Union[bool, float, str, Iterable[object], object, None]]] type: Required[Literal["json_schema"]] -class ResponseFormatUnionMember1(TypedDict, total=False): +class ResponseFormatGrammar(TypedDict, total=False): bnf: Required[Dict[str, Union[bool, float, str, Iterable[object], object, None]]] type: Required[Literal["grammar"]] -ResponseFormat: TypeAlias = Union[ResponseFormatUnionMember0, ResponseFormatUnionMember1] +ResponseFormat: TypeAlias = Union[ResponseFormatJsonSchema, ResponseFormatGrammar] class Tool(TypedDict, total=False): diff --git a/src/llama_stack_client/types/inference_completion_params.py b/src/llama_stack_client/types/inference_completion_params.py index ade06929..efa3ace2 100644 --- a/src/llama_stack_client/types/inference_completion_params.py +++ b/src/llama_stack_client/types/inference_completion_params.py @@ -13,8 +13,8 @@ "InferenceCompletionParamsBase", "Logprobs", "ResponseFormat", - "ResponseFormatUnionMember0", - "ResponseFormatUnionMember1", + "ResponseFormatJsonSchema", + "ResponseFormatGrammar", "InferenceCompletionParamsNonStreaming", "InferenceCompletionParamsStreaming", ] @@ -40,19 +40,19 @@ class Logprobs(TypedDict, total=False): top_k: int -class ResponseFormatUnionMember0(TypedDict, total=False): +class ResponseFormatJsonSchema(TypedDict, total=False): json_schema: Required[Dict[str, Union[bool, float, str, Iterable[object], object, None]]] type: Required[Literal["json_schema"]] -class ResponseFormatUnionMember1(TypedDict, total=False): +class ResponseFormatGrammar(TypedDict, total=False): bnf: Required[Dict[str, Union[bool, float, str, Iterable[object], object, None]]] type: Required[Literal["grammar"]] -ResponseFormat: TypeAlias = Union[ResponseFormatUnionMember0, ResponseFormatUnionMember1] +ResponseFormat: TypeAlias = Union[ResponseFormatJsonSchema, ResponseFormatGrammar] class InferenceCompletionParamsNonStreaming(InferenceCompletionParamsBase, total=False): diff --git a/src/llama_stack_client/types/post_training_supervised_fine_tune_params.py b/src/llama_stack_client/types/post_training_supervised_fine_tune_params.py index d3c3437a..0e2a4212 100644 --- a/src/llama_stack_client/types/post_training_supervised_fine_tune_params.py +++ b/src/llama_stack_client/types/post_training_supervised_fine_tune_params.py @@ -14,8 +14,8 @@ "TrainingConfigOptimizerConfig", "TrainingConfigEfficiencyConfig", "AlgorithmConfig", - "AlgorithmConfigLoraFinetuningConfig", - "AlgorithmConfigQatFinetuningConfig", + "AlgorithmConfigLoRa", + "AlgorithmConfigQat", ] @@ -93,7 +93,7 @@ class TrainingConfig(TypedDict, total=False): efficiency_config: TrainingConfigEfficiencyConfig -class AlgorithmConfigLoraFinetuningConfig(TypedDict, total=False): +class AlgorithmConfigLoRa(TypedDict, total=False): alpha: Required[int] apply_lora_to_mlp: Required[bool] @@ -111,7 +111,7 @@ class AlgorithmConfigLoraFinetuningConfig(TypedDict, total=False): use_dora: bool -class AlgorithmConfigQatFinetuningConfig(TypedDict, total=False): +class AlgorithmConfigQat(TypedDict, total=False): group_size: Required[int] quantizer_name: Required[str] @@ -119,4 +119,4 @@ class AlgorithmConfigQatFinetuningConfig(TypedDict, total=False): type: Required[Literal["QAT"]] -AlgorithmConfig: TypeAlias = Union[AlgorithmConfigLoraFinetuningConfig, AlgorithmConfigQatFinetuningConfig] +AlgorithmConfig: TypeAlias = Union[AlgorithmConfigLoRa, AlgorithmConfigQat] diff --git a/src/llama_stack_client/types/scoring_fn.py b/src/llama_stack_client/types/scoring_fn.py index f867463a..0e29e956 100644 --- a/src/llama_stack_client/types/scoring_fn.py +++ b/src/llama_stack_client/types/scoring_fn.py @@ -1,21 +1,16 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Dict, List, Union, Optional -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias +from .._utils import PropertyInfo from .._models import BaseModel from .shared.return_type import ReturnType -__all__ = [ - "ScoringFn", - "Params", - "ParamsLlmAsJudgeScoringFnParams", - "ParamsRegexParserScoringFnParams", - "ParamsBasicScoringFnParams", -] +__all__ = ["ScoringFn", "Params", "ParamsLlmAsJudge", "ParamsRegexParser", "ParamsBasic"] -class ParamsLlmAsJudgeScoringFnParams(BaseModel): +class ParamsLlmAsJudge(BaseModel): judge_model: str type: Literal["llm_as_judge"] @@ -27,7 +22,7 @@ class ParamsLlmAsJudgeScoringFnParams(BaseModel): prompt_template: Optional[str] = None -class ParamsRegexParserScoringFnParams(BaseModel): +class ParamsRegexParser(BaseModel): type: Literal["regex_parser"] aggregation_functions: Optional[List[Literal["average", "median", "categorical_count", "accuracy"]]] = None @@ -35,13 +30,15 @@ class ParamsRegexParserScoringFnParams(BaseModel): parsing_regexes: Optional[List[str]] = None -class ParamsBasicScoringFnParams(BaseModel): +class ParamsBasic(BaseModel): type: Literal["basic"] aggregation_functions: Optional[List[Literal["average", "median", "categorical_count", "accuracy"]]] = None -Params: TypeAlias = Union[ParamsLlmAsJudgeScoringFnParams, ParamsRegexParserScoringFnParams, ParamsBasicScoringFnParams] +Params: TypeAlias = Annotated[ + Union[ParamsLlmAsJudge, ParamsRegexParser, ParamsBasic], PropertyInfo(discriminator="type") +] class ScoringFn(BaseModel): diff --git a/src/llama_stack_client/types/scoring_function_register_params.py b/src/llama_stack_client/types/scoring_function_register_params.py index 2efcfee5..1c7347cf 100644 --- a/src/llama_stack_client/types/scoring_function_register_params.py +++ b/src/llama_stack_client/types/scoring_function_register_params.py @@ -8,13 +8,7 @@ from .._utils import PropertyInfo from .shared_params.return_type import ReturnType -__all__ = [ - "ScoringFunctionRegisterParams", - "Params", - "ParamsLlmAsJudgeScoringFnParams", - "ParamsRegexParserScoringFnParams", - "ParamsBasicScoringFnParams", -] +__all__ = ["ScoringFunctionRegisterParams", "Params", "ParamsLlmAsJudge", "ParamsRegexParser", "ParamsBasic"] class ScoringFunctionRegisterParams(TypedDict, total=False): @@ -35,7 +29,7 @@ class ScoringFunctionRegisterParams(TypedDict, total=False): x_llama_stack_provider_data: Annotated[str, PropertyInfo(alias="X-LlamaStack-Provider-Data")] -class ParamsLlmAsJudgeScoringFnParams(TypedDict, total=False): +class ParamsLlmAsJudge(TypedDict, total=False): judge_model: Required[str] type: Required[Literal["llm_as_judge"]] @@ -47,7 +41,7 @@ class ParamsLlmAsJudgeScoringFnParams(TypedDict, total=False): prompt_template: str -class ParamsRegexParserScoringFnParams(TypedDict, total=False): +class ParamsRegexParser(TypedDict, total=False): type: Required[Literal["regex_parser"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] @@ -55,10 +49,10 @@ class ParamsRegexParserScoringFnParams(TypedDict, total=False): parsing_regexes: List[str] -class ParamsBasicScoringFnParams(TypedDict, total=False): +class ParamsBasic(TypedDict, total=False): type: Required[Literal["basic"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] -Params: TypeAlias = Union[ParamsLlmAsJudgeScoringFnParams, ParamsRegexParserScoringFnParams, ParamsBasicScoringFnParams] +Params: TypeAlias = Union[ParamsLlmAsJudge, ParamsRegexParser, ParamsBasic] diff --git a/src/llama_stack_client/types/scoring_score_batch_params.py b/src/llama_stack_client/types/scoring_score_batch_params.py index 6f536afa..affae33d 100644 --- a/src/llama_stack_client/types/scoring_score_batch_params.py +++ b/src/llama_stack_client/types/scoring_score_batch_params.py @@ -10,9 +10,9 @@ __all__ = [ "ScoringScoreBatchParams", "ScoringFunctions", - "ScoringFunctionsLlmAsJudgeScoringFnParams", - "ScoringFunctionsRegexParserScoringFnParams", - "ScoringFunctionsBasicScoringFnParams", + "ScoringFunctionsLlmAsJudge", + "ScoringFunctionsRegexParser", + "ScoringFunctionsBasic", ] @@ -28,7 +28,7 @@ class ScoringScoreBatchParams(TypedDict, total=False): x_llama_stack_provider_data: Annotated[str, PropertyInfo(alias="X-LlamaStack-Provider-Data")] -class ScoringFunctionsLlmAsJudgeScoringFnParams(TypedDict, total=False): +class ScoringFunctionsLlmAsJudge(TypedDict, total=False): judge_model: Required[str] type: Required[Literal["llm_as_judge"]] @@ -40,7 +40,7 @@ class ScoringFunctionsLlmAsJudgeScoringFnParams(TypedDict, total=False): prompt_template: str -class ScoringFunctionsRegexParserScoringFnParams(TypedDict, total=False): +class ScoringFunctionsRegexParser(TypedDict, total=False): type: Required[Literal["regex_parser"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] @@ -48,14 +48,10 @@ class ScoringFunctionsRegexParserScoringFnParams(TypedDict, total=False): parsing_regexes: List[str] -class ScoringFunctionsBasicScoringFnParams(TypedDict, total=False): +class ScoringFunctionsBasic(TypedDict, total=False): type: Required[Literal["basic"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] -ScoringFunctions: TypeAlias = Union[ - ScoringFunctionsLlmAsJudgeScoringFnParams, - ScoringFunctionsRegexParserScoringFnParams, - ScoringFunctionsBasicScoringFnParams, -] +ScoringFunctions: TypeAlias = Union[ScoringFunctionsLlmAsJudge, ScoringFunctionsRegexParser, ScoringFunctionsBasic] diff --git a/src/llama_stack_client/types/scoring_score_params.py b/src/llama_stack_client/types/scoring_score_params.py index 47ecc31d..561f2627 100644 --- a/src/llama_stack_client/types/scoring_score_params.py +++ b/src/llama_stack_client/types/scoring_score_params.py @@ -10,9 +10,9 @@ __all__ = [ "ScoringScoreParams", "ScoringFunctions", - "ScoringFunctionsLlmAsJudgeScoringFnParams", - "ScoringFunctionsRegexParserScoringFnParams", - "ScoringFunctionsBasicScoringFnParams", + "ScoringFunctionsLlmAsJudge", + "ScoringFunctionsRegexParser", + "ScoringFunctionsBasic", ] @@ -26,7 +26,7 @@ class ScoringScoreParams(TypedDict, total=False): x_llama_stack_provider_data: Annotated[str, PropertyInfo(alias="X-LlamaStack-Provider-Data")] -class ScoringFunctionsLlmAsJudgeScoringFnParams(TypedDict, total=False): +class ScoringFunctionsLlmAsJudge(TypedDict, total=False): judge_model: Required[str] type: Required[Literal["llm_as_judge"]] @@ -38,7 +38,7 @@ class ScoringFunctionsLlmAsJudgeScoringFnParams(TypedDict, total=False): prompt_template: str -class ScoringFunctionsRegexParserScoringFnParams(TypedDict, total=False): +class ScoringFunctionsRegexParser(TypedDict, total=False): type: Required[Literal["regex_parser"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] @@ -46,14 +46,10 @@ class ScoringFunctionsRegexParserScoringFnParams(TypedDict, total=False): parsing_regexes: List[str] -class ScoringFunctionsBasicScoringFnParams(TypedDict, total=False): +class ScoringFunctionsBasic(TypedDict, total=False): type: Required[Literal["basic"]] aggregation_functions: List[Literal["average", "median", "categorical_count", "accuracy"]] -ScoringFunctions: TypeAlias = Union[ - ScoringFunctionsLlmAsJudgeScoringFnParams, - ScoringFunctionsRegexParserScoringFnParams, - ScoringFunctionsBasicScoringFnParams, -] +ScoringFunctions: TypeAlias = Union[ScoringFunctionsLlmAsJudge, ScoringFunctionsRegexParser, ScoringFunctionsBasic] diff --git a/src/llama_stack_client/types/shared/__init__.py b/src/llama_stack_client/types/shared/__init__.py index 9307608e..761281ee 100644 --- a/src/llama_stack_client/types/shared/__init__.py +++ b/src/llama_stack_client/types/shared/__init__.py @@ -2,10 +2,13 @@ from .url import URL as URL from .message import Message as Message +from .document import Document as Document from .tool_call import ToolCall as ToolCall from .param_type import ParamType as ParamType from .return_type import ReturnType as ReturnType from .agent_config import AgentConfig as AgentConfig +from .query_config import QueryConfig as QueryConfig +from .query_result import QueryResult as QueryResult from .user_message import UserMessage as UserMessage from .content_delta import ContentDelta as ContentDelta from .scoring_result import ScoringResult as ScoringResult diff --git a/src/llama_stack_client/types/shared/content_delta.py b/src/llama_stack_client/types/shared/content_delta.py index 3ed73413..6af2cb70 100644 --- a/src/llama_stack_client/types/shared/content_delta.py +++ b/src/llama_stack_client/types/shared/content_delta.py @@ -1,35 +1,36 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias +from . import tool_call +from ..._utils import PropertyInfo from ..._models import BaseModel -from .tool_call import ToolCall -__all__ = ["ContentDelta", "TextDelta", "ImageDelta", "ToolCallDelta", "ToolCallDeltaToolCall"] +__all__ = ["ContentDelta", "Text", "Image", "ToolCall", "ToolCallToolCall"] -class TextDelta(BaseModel): +class Text(BaseModel): text: str type: Literal["text"] -class ImageDelta(BaseModel): +class Image(BaseModel): image: str type: Literal["image"] -ToolCallDeltaToolCall: TypeAlias = Union[str, ToolCall] +ToolCallToolCall: TypeAlias = Union[str, tool_call.ToolCall] -class ToolCallDelta(BaseModel): +class ToolCall(BaseModel): parse_status: Literal["started", "in_progress", "failed", "succeeded"] - tool_call: ToolCallDeltaToolCall + tool_call: ToolCallToolCall type: Literal["tool_call"] -ContentDelta: TypeAlias = Union[TextDelta, ImageDelta, ToolCallDelta] +ContentDelta: TypeAlias = Annotated[Union[Text, Image, ToolCall], PropertyInfo(discriminator="type")] diff --git a/src/llama_stack_client/types/shared/document.py b/src/llama_stack_client/types/shared/document.py new file mode 100644 index 00000000..e88960b4 --- /dev/null +++ b/src/llama_stack_client/types/shared/document.py @@ -0,0 +1,41 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Union, Optional +from typing_extensions import Literal, TypeAlias + +from .url import URL +from ..._models import BaseModel +from .interleaved_content_item import InterleavedContentItem + +__all__ = ["Document", "Content", "ContentImageContentItem", "ContentImageContentItemImage", "ContentTextContentItem"] + + +class ContentImageContentItemImage(BaseModel): + data: Optional[str] = None + + url: Optional[URL] = None + + +class ContentImageContentItem(BaseModel): + image: ContentImageContentItemImage + + type: Literal["image"] + + +class ContentTextContentItem(BaseModel): + text: str + + type: Literal["text"] + + +Content: TypeAlias = Union[str, ContentImageContentItem, ContentTextContentItem, List[InterleavedContentItem], URL] + + +class Document(BaseModel): + content: Content + + document_id: str + + metadata: Dict[str, Union[bool, float, str, List[object], object, None]] + + mime_type: Optional[str] = None diff --git a/src/llama_stack_client/types/shared/interleaved_content_item.py b/src/llama_stack_client/types/shared/interleaved_content_item.py index cc3de8f6..087b0863 100644 --- a/src/llama_stack_client/types/shared/interleaved_content_item.py +++ b/src/llama_stack_client/types/shared/interleaved_content_item.py @@ -1,30 +1,31 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union, Optional -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias from .url import URL +from ..._utils import PropertyInfo from ..._models import BaseModel -__all__ = ["InterleavedContentItem", "ImageContentItem", "ImageContentItemImage", "TextContentItem"] +__all__ = ["InterleavedContentItem", "Image", "ImageImage", "Text"] -class ImageContentItemImage(BaseModel): +class ImageImage(BaseModel): data: Optional[str] = None url: Optional[URL] = None -class ImageContentItem(BaseModel): - image: ImageContentItemImage +class Image(BaseModel): + image: ImageImage type: Literal["image"] -class TextContentItem(BaseModel): +class Text(BaseModel): text: str type: Literal["text"] -InterleavedContentItem: TypeAlias = Union[ImageContentItem, TextContentItem] +InterleavedContentItem: TypeAlias = Annotated[Union[Image, Text], PropertyInfo(discriminator="type")] diff --git a/src/llama_stack_client/types/shared/message.py b/src/llama_stack_client/types/shared/message.py index 2238c07b..1da117ee 100644 --- a/src/llama_stack_client/types/shared/message.py +++ b/src/llama_stack_client/types/shared/message.py @@ -1,8 +1,9 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union -from typing_extensions import TypeAlias +from typing_extensions import Annotated, TypeAlias +from ..._utils import PropertyInfo from .user_message import UserMessage from .system_message import SystemMessage from .completion_message import CompletionMessage @@ -10,4 +11,6 @@ __all__ = ["Message"] -Message: TypeAlias = Union[UserMessage, SystemMessage, ToolResponseMessage, CompletionMessage] +Message: TypeAlias = Annotated[ + Union[UserMessage, SystemMessage, ToolResponseMessage, CompletionMessage], PropertyInfo(discriminator="role") +] diff --git a/src/llama_stack_client/types/shared/param_type.py b/src/llama_stack_client/types/shared/param_type.py index 8512c0f4..aed161e3 100644 --- a/src/llama_stack_client/types/shared/param_type.py +++ b/src/llama_stack_client/types/shared/param_type.py @@ -1,74 +1,69 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union -from typing_extensions import Literal, TypeAlias +import typing +from typing_extensions import Literal, Annotated, TypeAlias +from ..._utils import PropertyInfo from ..._models import BaseModel __all__ = [ "ParamType", - "StringType", - "NumberType", - "BooleanType", - "ArrayType", - "ObjectType", - "JsonType", - "UnionType", - "ChatCompletionInputType", - "CompletionInputType", - "AgentTurnInputType", + "String", + "Number", + "Boolean", + "Array", + "Object", + "Json", + "Union", + "ChatCompletionInput", + "CompletionInput", + "AgentTurnInput", ] -class StringType(BaseModel): +class String(BaseModel): type: Literal["string"] -class NumberType(BaseModel): +class Number(BaseModel): type: Literal["number"] -class BooleanType(BaseModel): +class Boolean(BaseModel): type: Literal["boolean"] -class ArrayType(BaseModel): +class Array(BaseModel): type: Literal["array"] -class ObjectType(BaseModel): +class Object(BaseModel): type: Literal["object"] -class JsonType(BaseModel): +class Json(BaseModel): type: Literal["json"] -class UnionType(BaseModel): +class Union(BaseModel): type: Literal["union"] -class ChatCompletionInputType(BaseModel): +class ChatCompletionInput(BaseModel): type: Literal["chat_completion_input"] -class CompletionInputType(BaseModel): +class CompletionInput(BaseModel): type: Literal["completion_input"] -class AgentTurnInputType(BaseModel): +class AgentTurnInput(BaseModel): type: Literal["agent_turn_input"] -ParamType: TypeAlias = Union[ - StringType, - NumberType, - BooleanType, - ArrayType, - ObjectType, - JsonType, - UnionType, - ChatCompletionInputType, - CompletionInputType, - AgentTurnInputType, +ParamType: TypeAlias = Annotated[ + typing.Union[ + String, Number, Boolean, Array, Object, Json, Union, ChatCompletionInput, CompletionInput, AgentTurnInput + ], + PropertyInfo(discriminator="type"), ] diff --git a/src/llama_stack_client/types/shared/query_config.py b/src/llama_stack_client/types/shared/query_config.py new file mode 100644 index 00000000..cc13cf2f --- /dev/null +++ b/src/llama_stack_client/types/shared/query_config.py @@ -0,0 +1,36 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel + +__all__ = ["QueryConfig", "QueryGeneratorConfig", "QueryGeneratorConfigDefault", "QueryGeneratorConfigLlm"] + + +class QueryGeneratorConfigDefault(BaseModel): + separator: str + + type: Literal["default"] + + +class QueryGeneratorConfigLlm(BaseModel): + model: str + + template: str + + type: Literal["llm"] + + +QueryGeneratorConfig: TypeAlias = Annotated[ + Union[QueryGeneratorConfigDefault, QueryGeneratorConfigLlm], PropertyInfo(discriminator="type") +] + + +class QueryConfig(BaseModel): + max_chunks: int + + max_tokens_in_context: int + + query_generator_config: QueryGeneratorConfig diff --git a/src/llama_stack_client/types/shared/query_result.py b/src/llama_stack_client/types/shared/query_result.py new file mode 100644 index 00000000..5a0156c8 --- /dev/null +++ b/src/llama_stack_client/types/shared/query_result.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel +from .interleaved_content import InterleavedContent + +__all__ = ["QueryResult"] + + +class QueryResult(BaseModel): + content: Optional[InterleavedContent] = None diff --git a/src/llama_stack_client/types/shared/sampling_params.py b/src/llama_stack_client/types/shared/sampling_params.py index 48fbe544..a54899da 100644 --- a/src/llama_stack_client/types/shared/sampling_params.py +++ b/src/llama_stack_client/types/shared/sampling_params.py @@ -1,24 +1,19 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union, Optional -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias +from ..._utils import PropertyInfo from ..._models import BaseModel -__all__ = [ - "SamplingParams", - "Strategy", - "StrategyGreedySamplingStrategy", - "StrategyTopPSamplingStrategy", - "StrategyTopKSamplingStrategy", -] +__all__ = ["SamplingParams", "Strategy", "StrategyGreedy", "StrategyTopP", "StrategyTopK"] -class StrategyGreedySamplingStrategy(BaseModel): +class StrategyGreedy(BaseModel): type: Literal["greedy"] -class StrategyTopPSamplingStrategy(BaseModel): +class StrategyTopP(BaseModel): type: Literal["top_p"] temperature: Optional[float] = None @@ -26,13 +21,13 @@ class StrategyTopPSamplingStrategy(BaseModel): top_p: Optional[float] = None -class StrategyTopKSamplingStrategy(BaseModel): +class StrategyTopK(BaseModel): top_k: int type: Literal["top_k"] -Strategy: TypeAlias = Union[StrategyGreedySamplingStrategy, StrategyTopPSamplingStrategy, StrategyTopKSamplingStrategy] +Strategy: TypeAlias = Annotated[Union[StrategyGreedy, StrategyTopP, StrategyTopK], PropertyInfo(discriminator="type")] class SamplingParams(BaseModel): diff --git a/src/llama_stack_client/types/shared_params/__init__.py b/src/llama_stack_client/types/shared_params/__init__.py index 14873c97..4c092a1a 100644 --- a/src/llama_stack_client/types/shared_params/__init__.py +++ b/src/llama_stack_client/types/shared_params/__init__.py @@ -2,10 +2,12 @@ from .url import URL as URL from .message import Message as Message +from .document import Document as Document from .tool_call import ToolCall as ToolCall from .param_type import ParamType as ParamType from .return_type import ReturnType as ReturnType from .agent_config import AgentConfig as AgentConfig +from .query_config import QueryConfig as QueryConfig from .user_message import UserMessage as UserMessage from .system_message import SystemMessage as SystemMessage from .sampling_params import SamplingParams as SamplingParams diff --git a/src/llama_stack_client/types/shared_params/document.py b/src/llama_stack_client/types/shared_params/document.py new file mode 100644 index 00000000..9fb05ab2 --- /dev/null +++ b/src/llama_stack_client/types/shared_params/document.py @@ -0,0 +1,42 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Iterable +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +from .url import URL +from .interleaved_content_item import InterleavedContentItem + +__all__ = ["Document", "Content", "ContentImageContentItem", "ContentImageContentItemImage", "ContentTextContentItem"] + + +class ContentImageContentItemImage(TypedDict, total=False): + data: str + + url: URL + + +class ContentImageContentItem(TypedDict, total=False): + image: Required[ContentImageContentItemImage] + + type: Required[Literal["image"]] + + +class ContentTextContentItem(TypedDict, total=False): + text: Required[str] + + type: Required[Literal["text"]] + + +Content: TypeAlias = Union[str, ContentImageContentItem, ContentTextContentItem, Iterable[InterleavedContentItem], URL] + + +class Document(TypedDict, total=False): + content: Required[Content] + + document_id: Required[str] + + metadata: Required[Dict[str, Union[bool, float, str, Iterable[object], object, None]]] + + mime_type: str diff --git a/src/llama_stack_client/types/shared_params/interleaved_content_item.py b/src/llama_stack_client/types/shared_params/interleaved_content_item.py index 8a5da06f..f4fd3798 100644 --- a/src/llama_stack_client/types/shared_params/interleaved_content_item.py +++ b/src/llama_stack_client/types/shared_params/interleaved_content_item.py @@ -7,25 +7,25 @@ from .url import URL -__all__ = ["InterleavedContentItem", "ImageContentItem", "ImageContentItemImage", "TextContentItem"] +__all__ = ["InterleavedContentItem", "Image", "ImageImage", "Text"] -class ImageContentItemImage(TypedDict, total=False): +class ImageImage(TypedDict, total=False): data: str url: URL -class ImageContentItem(TypedDict, total=False): - image: Required[ImageContentItemImage] +class Image(TypedDict, total=False): + image: Required[ImageImage] type: Required[Literal["image"]] -class TextContentItem(TypedDict, total=False): +class Text(TypedDict, total=False): text: Required[str] type: Required[Literal["text"]] -InterleavedContentItem: TypeAlias = Union[ImageContentItem, TextContentItem] +InterleavedContentItem: TypeAlias = Union[Image, Text] diff --git a/src/llama_stack_client/types/shared_params/param_type.py b/src/llama_stack_client/types/shared_params/param_type.py index b93dfeff..05d99b4e 100644 --- a/src/llama_stack_client/types/shared_params/param_type.py +++ b/src/llama_stack_client/types/shared_params/param_type.py @@ -2,73 +2,64 @@ from __future__ import annotations -from typing import Union +import typing from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ "ParamType", - "StringType", - "NumberType", - "BooleanType", - "ArrayType", - "ObjectType", - "JsonType", - "UnionType", - "ChatCompletionInputType", - "CompletionInputType", - "AgentTurnInputType", + "String", + "Number", + "Boolean", + "Array", + "Object", + "Json", + "Union", + "ChatCompletionInput", + "CompletionInput", + "AgentTurnInput", ] -class StringType(TypedDict, total=False): +class String(TypedDict, total=False): type: Required[Literal["string"]] -class NumberType(TypedDict, total=False): +class Number(TypedDict, total=False): type: Required[Literal["number"]] -class BooleanType(TypedDict, total=False): +class Boolean(TypedDict, total=False): type: Required[Literal["boolean"]] -class ArrayType(TypedDict, total=False): +class Array(TypedDict, total=False): type: Required[Literal["array"]] -class ObjectType(TypedDict, total=False): +class Object(TypedDict, total=False): type: Required[Literal["object"]] -class JsonType(TypedDict, total=False): +class Json(TypedDict, total=False): type: Required[Literal["json"]] -class UnionType(TypedDict, total=False): +class Union(TypedDict, total=False): type: Required[Literal["union"]] -class ChatCompletionInputType(TypedDict, total=False): +class ChatCompletionInput(TypedDict, total=False): type: Required[Literal["chat_completion_input"]] -class CompletionInputType(TypedDict, total=False): +class CompletionInput(TypedDict, total=False): type: Required[Literal["completion_input"]] -class AgentTurnInputType(TypedDict, total=False): +class AgentTurnInput(TypedDict, total=False): type: Required[Literal["agent_turn_input"]] -ParamType: TypeAlias = Union[ - StringType, - NumberType, - BooleanType, - ArrayType, - ObjectType, - JsonType, - UnionType, - ChatCompletionInputType, - CompletionInputType, - AgentTurnInputType, +ParamType: TypeAlias = typing.Union[ + String, Number, Boolean, Array, Object, Json, Union, ChatCompletionInput, CompletionInput, AgentTurnInput ] diff --git a/src/llama_stack_client/types/shared_params/query_config.py b/src/llama_stack_client/types/shared_params/query_config.py new file mode 100644 index 00000000..683e1aee --- /dev/null +++ b/src/llama_stack_client/types/shared_params/query_config.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +__all__ = ["QueryConfig", "QueryGeneratorConfig", "QueryGeneratorConfigDefault", "QueryGeneratorConfigLlm"] + + +class QueryGeneratorConfigDefault(TypedDict, total=False): + separator: Required[str] + + type: Required[Literal["default"]] + + +class QueryGeneratorConfigLlm(TypedDict, total=False): + model: Required[str] + + template: Required[str] + + type: Required[Literal["llm"]] + + +QueryGeneratorConfig: TypeAlias = Union[QueryGeneratorConfigDefault, QueryGeneratorConfigLlm] + + +class QueryConfig(TypedDict, total=False): + max_chunks: Required[int] + + max_tokens_in_context: Required[int] + + query_generator_config: Required[QueryGeneratorConfig] diff --git a/src/llama_stack_client/types/shared_params/sampling_params.py b/src/llama_stack_client/types/shared_params/sampling_params.py index 1d9bcaf5..daa252f9 100644 --- a/src/llama_stack_client/types/shared_params/sampling_params.py +++ b/src/llama_stack_client/types/shared_params/sampling_params.py @@ -5,20 +5,14 @@ from typing import Union from typing_extensions import Literal, Required, TypeAlias, TypedDict -__all__ = [ - "SamplingParams", - "Strategy", - "StrategyGreedySamplingStrategy", - "StrategyTopPSamplingStrategy", - "StrategyTopKSamplingStrategy", -] +__all__ = ["SamplingParams", "Strategy", "StrategyGreedy", "StrategyTopP", "StrategyTopK"] -class StrategyGreedySamplingStrategy(TypedDict, total=False): +class StrategyGreedy(TypedDict, total=False): type: Required[Literal["greedy"]] -class StrategyTopPSamplingStrategy(TypedDict, total=False): +class StrategyTopP(TypedDict, total=False): type: Required[Literal["top_p"]] temperature: float @@ -26,13 +20,13 @@ class StrategyTopPSamplingStrategy(TypedDict, total=False): top_p: float -class StrategyTopKSamplingStrategy(TypedDict, total=False): +class StrategyTopK(TypedDict, total=False): top_k: Required[int] type: Required[Literal["top_k"]] -Strategy: TypeAlias = Union[StrategyGreedySamplingStrategy, StrategyTopPSamplingStrategy, StrategyTopKSamplingStrategy] +Strategy: TypeAlias = Union[StrategyGreedy, StrategyTopP, StrategyTopK] class SamplingParams(TypedDict, total=False): diff --git a/src/llama_stack_client/types/telemetry_log_event_params.py b/src/llama_stack_client/types/telemetry_log_event_params.py index b5beec98..a6686388 100644 --- a/src/llama_stack_client/types/telemetry_log_event_params.py +++ b/src/llama_stack_client/types/telemetry_log_event_params.py @@ -11,12 +11,12 @@ __all__ = [ "TelemetryLogEventParams", "Event", - "EventUnstructuredLogEvent", - "EventMetricEvent", - "EventStructuredLogEvent", - "EventStructuredLogEventPayload", - "EventStructuredLogEventPayloadSpanStartPayload", - "EventStructuredLogEventPayloadSpanEndPayload", + "EventUnstructuredLog", + "EventMetric", + "EventStructuredLog", + "EventStructuredLogPayload", + "EventStructuredLogPayloadSpanStart", + "EventStructuredLogPayloadSpanEnd", ] @@ -30,7 +30,7 @@ class TelemetryLogEventParams(TypedDict, total=False): x_llama_stack_provider_data: Annotated[str, PropertyInfo(alias="X-LlamaStack-Provider-Data")] -class EventUnstructuredLogEvent(TypedDict, total=False): +class EventUnstructuredLog(TypedDict, total=False): message: Required[str] severity: Required[Literal["verbose", "debug", "info", "warn", "error", "critical"]] @@ -46,7 +46,7 @@ class EventUnstructuredLogEvent(TypedDict, total=False): attributes: Dict[str, Union[bool, float, str, Iterable[object], object, None]] -class EventMetricEvent(TypedDict, total=False): +class EventMetric(TypedDict, total=False): metric: Required[str] span_id: Required[str] @@ -64,7 +64,7 @@ class EventMetricEvent(TypedDict, total=False): attributes: Dict[str, Union[bool, float, str, Iterable[object], object, None]] -class EventStructuredLogEventPayloadSpanStartPayload(TypedDict, total=False): +class EventStructuredLogPayloadSpanStart(TypedDict, total=False): name: Required[str] type: Required[Literal["span_start"]] @@ -72,19 +72,17 @@ class EventStructuredLogEventPayloadSpanStartPayload(TypedDict, total=False): parent_span_id: str -class EventStructuredLogEventPayloadSpanEndPayload(TypedDict, total=False): +class EventStructuredLogPayloadSpanEnd(TypedDict, total=False): status: Required[Literal["ok", "error"]] type: Required[Literal["span_end"]] -EventStructuredLogEventPayload: TypeAlias = Union[ - EventStructuredLogEventPayloadSpanStartPayload, EventStructuredLogEventPayloadSpanEndPayload -] +EventStructuredLogPayload: TypeAlias = Union[EventStructuredLogPayloadSpanStart, EventStructuredLogPayloadSpanEnd] -class EventStructuredLogEvent(TypedDict, total=False): - payload: Required[EventStructuredLogEventPayload] +class EventStructuredLog(TypedDict, total=False): + payload: Required[EventStructuredLogPayload] span_id: Required[str] @@ -97,4 +95,4 @@ class EventStructuredLogEvent(TypedDict, total=False): attributes: Dict[str, Union[bool, float, str, Iterable[object], object, None]] -Event: TypeAlias = Union[EventUnstructuredLogEvent, EventMetricEvent, EventStructuredLogEvent] +Event: TypeAlias = Union[EventUnstructuredLog, EventMetric, EventStructuredLog] diff --git a/src/llama_stack_client/types/tool_runtime/__init__.py b/src/llama_stack_client/types/tool_runtime/__init__.py index 27283e7a..43dd1925 100644 --- a/src/llama_stack_client/types/tool_runtime/__init__.py +++ b/src/llama_stack_client/types/tool_runtime/__init__.py @@ -2,8 +2,5 @@ from __future__ import annotations -from .query_result import QueryResult as QueryResult -from .document_param import DocumentParam as DocumentParam -from .query_config_param import QueryConfigParam as QueryConfigParam from .rag_tool_query_params import RagToolQueryParams as RagToolQueryParams from .rag_tool_insert_params import RagToolInsertParams as RagToolInsertParams diff --git a/src/llama_stack_client/types/tool_runtime/rag_tool_insert_params.py b/src/llama_stack_client/types/tool_runtime/rag_tool_insert_params.py index f9955884..dd1e61ca 100644 --- a/src/llama_stack_client/types/tool_runtime/rag_tool_insert_params.py +++ b/src/llama_stack_client/types/tool_runtime/rag_tool_insert_params.py @@ -6,7 +6,7 @@ from typing_extensions import Required, Annotated, TypedDict from ..._utils import PropertyInfo -from .document_param import DocumentParam +from ..shared_params.document import Document __all__ = ["RagToolInsertParams"] @@ -14,7 +14,7 @@ class RagToolInsertParams(TypedDict, total=False): chunk_size_in_tokens: Required[int] - documents: Required[Iterable[DocumentParam]] + documents: Required[Iterable[Document]] vector_db_id: Required[str] diff --git a/src/llama_stack_client/types/tool_runtime/rag_tool_query_params.py b/src/llama_stack_client/types/tool_runtime/rag_tool_query_params.py index 08086d81..4ddf8d17 100644 --- a/src/llama_stack_client/types/tool_runtime/rag_tool_query_params.py +++ b/src/llama_stack_client/types/tool_runtime/rag_tool_query_params.py @@ -6,7 +6,7 @@ from typing_extensions import Required, Annotated, TypedDict from ..._utils import PropertyInfo -from .query_config_param import QueryConfigParam +from ..shared_params.query_config import QueryConfig from ..shared_params.interleaved_content import InterleavedContent __all__ = ["RagToolQueryParams"] @@ -17,7 +17,7 @@ class RagToolQueryParams(TypedDict, total=False): vector_db_ids: Required[List[str]] - query_config: QueryConfigParam + query_config: QueryConfig x_llama_stack_client_version: Annotated[str, PropertyInfo(alias="X-LlamaStack-Client-Version")] diff --git a/tests/api_resources/tool_runtime/test_rag_tool.py b/tests/api_resources/tool_runtime/test_rag_tool.py index 075b046e..4082752a 100644 --- a/tests/api_resources/tool_runtime/test_rag_tool.py +++ b/tests/api_resources/tool_runtime/test_rag_tool.py @@ -9,9 +9,7 @@ from tests.utils import assert_matches_type from llama_stack_client import LlamaStackClient, AsyncLlamaStackClient -from llama_stack_client.types.tool_runtime import ( - QueryResult, -) +from llama_stack_client.types.shared import QueryResult base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")