mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-29 15:23:51 +00:00
agentic system stream changes
This commit is contained in:
parent
97f9b18aca
commit
256f1d5991
4 changed files with 282 additions and 18 deletions
|
@ -32,6 +32,7 @@ class ExecutionStepBase:
|
||||||
"""An agentic system turn can consist of one or more such execution steps."""
|
"""An agentic system turn can consist of one or more such execution steps."""
|
||||||
|
|
||||||
step_type: ExecutionStepType
|
step_type: ExecutionStepType
|
||||||
|
uuid: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -63,10 +64,16 @@ class SafetyFilteringStep(ExecutionStepBase):
|
||||||
violation: Optional[SafetyViolation] = None
|
violation: Optional[SafetyViolation] = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class IndexedMemoryDocument:
|
||||||
|
index_id: str
|
||||||
|
content: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MemoryRetrievalStep(ExecutionStepBase):
|
class MemoryRetrievalStep(ExecutionStepBase):
|
||||||
step_type = ExecutionStepType.memory_retrieval
|
step_type = ExecutionStepType.memory_retrieval
|
||||||
documents: List[str]
|
documents: List[IndexedMemoryDocument]
|
||||||
scores: List[float]
|
scores: List[float]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,12 @@ from enum import Enum
|
||||||
from typing import Any, Dict, List, Optional, Protocol, Set, Union
|
from typing import Any, Dict, List, Optional, Protocol, Set, Union
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
from agentic_system_types import (
|
||||||
|
AgenticSystemTurn,
|
||||||
|
ExecutionStepType,
|
||||||
|
IndexedMemoryDocument,
|
||||||
|
SafetyViolation,
|
||||||
|
)
|
||||||
|
|
||||||
from model_types import (
|
from model_types import (
|
||||||
BuiltinTool,
|
BuiltinTool,
|
||||||
|
@ -16,9 +22,6 @@ from model_types import (
|
||||||
ToolDefinition,
|
ToolDefinition,
|
||||||
ToolResponse,
|
ToolResponse,
|
||||||
)
|
)
|
||||||
from agentic_system_types import (
|
|
||||||
AgenticSystemTurn,
|
|
||||||
)
|
|
||||||
|
|
||||||
from pyopenapi import Info, Options, Server, Specification, webmethod
|
from pyopenapi import Info, Options, Server, Specification, webmethod
|
||||||
from strong_typing.schema import json_schema_type
|
from strong_typing.schema import json_schema_type
|
||||||
|
@ -146,13 +149,29 @@ class AgenticSystemExecuteResponse:
|
||||||
turn: AgenticSystemTurn
|
turn: AgenticSystemTurn
|
||||||
|
|
||||||
|
|
||||||
|
class AgenticSystemExecuteResponseEventType(Enum):
|
||||||
|
"""The type of event."""
|
||||||
|
|
||||||
|
step_start = "step_start"
|
||||||
|
step_end = "step_end"
|
||||||
|
step_progress = "step_progress"
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
@dataclass
|
@dataclass
|
||||||
class AgenticSystemExecuteResponseStreamChunk:
|
class AgenticSystemExecuteResponseStreamChunk:
|
||||||
"""Streamed agent execution response."""
|
"""Streamed agent execution response."""
|
||||||
|
|
||||||
# TODO: make things streamable
|
event_type: AgenticSystemExecuteResponseEventType
|
||||||
turn: AgenticSystemTurn
|
|
||||||
|
step_uuid: str
|
||||||
|
step_type: ExecutionStepType
|
||||||
|
|
||||||
|
violation: Optional[SafetyViolation] = None
|
||||||
|
tool_call: Optional[ToolCall] = None
|
||||||
|
tool_response_delta: Optional[ToolResponse] = None
|
||||||
|
response_text_delta: Optional[str] = None
|
||||||
|
retrieved_document: Optional[IndexedMemoryDocument] = None
|
||||||
|
|
||||||
stop_reason: Optional[StopReason] = None
|
stop_reason: Optional[StopReason] = None
|
||||||
|
|
||||||
|
|
|
@ -328,6 +328,9 @@
|
||||||
"title": "The type of execution step.",
|
"title": "The type of execution step.",
|
||||||
"default": "model_inference"
|
"default": "model_inference"
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -360,6 +363,7 @@
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"step_type",
|
"step_type",
|
||||||
|
"uuid",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -377,6 +381,9 @@
|
||||||
"title": "The type of execution step.",
|
"title": "The type of execution step.",
|
||||||
"default": "tool_execution"
|
"default": "tool_execution"
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"tool_calls": {
|
"tool_calls": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
@ -442,6 +449,7 @@
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"step_type",
|
"step_type",
|
||||||
|
"uuid",
|
||||||
"tool_calls",
|
"tool_calls",
|
||||||
"tool_responses"
|
"tool_responses"
|
||||||
]
|
]
|
||||||
|
@ -460,6 +468,9 @@
|
||||||
"title": "The type of execution step.",
|
"title": "The type of execution step.",
|
||||||
"default": "safety_filtering"
|
"default": "safety_filtering"
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"violation": {
|
"violation": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -482,7 +493,8 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"step_type"
|
"step_type",
|
||||||
|
"uuid"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -499,10 +511,26 @@
|
||||||
"title": "The type of execution step.",
|
"title": "The type of execution step.",
|
||||||
"default": "memory_retrieval"
|
"default": "memory_retrieval"
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"documents": {
|
"documents": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"index_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"index_id",
|
||||||
|
"content"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scores": {
|
"scores": {
|
||||||
|
@ -515,6 +543,7 @@
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"step_type",
|
"step_type",
|
||||||
|
"uuid",
|
||||||
"documents",
|
"documents",
|
||||||
"scores"
|
"scores"
|
||||||
]
|
]
|
||||||
|
@ -677,8 +706,120 @@
|
||||||
"AgenticSystemExecuteResponseStreamChunk": {
|
"AgenticSystemExecuteResponseStreamChunk": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"turn": {
|
"event_type": {
|
||||||
"$ref": "#/components/schemas/AgenticSystemTurn"
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"step_start",
|
||||||
|
"step_end",
|
||||||
|
"step_progress"
|
||||||
|
],
|
||||||
|
"title": "The type of event."
|
||||||
|
},
|
||||||
|
"step_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"step_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"model_inference",
|
||||||
|
"tool_execution",
|
||||||
|
"safety_filtering",
|
||||||
|
"memory_retrieval"
|
||||||
|
],
|
||||||
|
"title": "The type of execution step."
|
||||||
|
},
|
||||||
|
"violation": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"violation_type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"details": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"suggested_user_response": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"violation_type",
|
||||||
|
"details"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"tool_call": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"tool_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"arguments": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"tool_name",
|
||||||
|
"arguments"
|
||||||
|
],
|
||||||
|
"title": "A tool call is a request to a tool."
|
||||||
|
},
|
||||||
|
"tool_response_delta": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"tool_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"tool_name",
|
||||||
|
"response"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"response_text_delta": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"retrieved_document": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"index_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"index_id",
|
||||||
|
"content"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"stop_reason": {
|
"stop_reason": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -692,7 +833,9 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"turn"
|
"event_type",
|
||||||
|
"step_uuid",
|
||||||
|
"step_type"
|
||||||
],
|
],
|
||||||
"title": "Streamed agent execution response."
|
"title": "Streamed agent execution response."
|
||||||
},
|
},
|
||||||
|
@ -1202,10 +1345,10 @@
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
{
|
{
|
||||||
"name": "Inference"
|
"name": "AgenticSystem"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "AgenticSystem"
|
"name": "Inference"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "AgenticSystemCreateRequest",
|
"name": "AgenticSystemCreateRequest",
|
||||||
|
|
|
@ -94,6 +94,36 @@ components:
|
||||||
AgenticSystemExecuteResponseStreamChunk:
|
AgenticSystemExecuteResponseStreamChunk:
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
|
event_type:
|
||||||
|
enum:
|
||||||
|
- step_start
|
||||||
|
- step_end
|
||||||
|
- step_progress
|
||||||
|
title: The type of event.
|
||||||
|
type: string
|
||||||
|
response_text_delta:
|
||||||
|
type: string
|
||||||
|
retrieved_document:
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
content:
|
||||||
|
type: string
|
||||||
|
index_id:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- index_id
|
||||||
|
- content
|
||||||
|
type: object
|
||||||
|
step_type:
|
||||||
|
enum:
|
||||||
|
- model_inference
|
||||||
|
- tool_execution
|
||||||
|
- safety_filtering
|
||||||
|
- memory_retrieval
|
||||||
|
title: The type of execution step.
|
||||||
|
type: string
|
||||||
|
step_uuid:
|
||||||
|
type: string
|
||||||
stop_reason:
|
stop_reason:
|
||||||
enum:
|
enum:
|
||||||
- not_stopped
|
- not_stopped
|
||||||
|
@ -102,10 +132,54 @@ components:
|
||||||
title: Stop reasons are used to indicate why the model stopped generating
|
title: Stop reasons are used to indicate why the model stopped generating
|
||||||
text.
|
text.
|
||||||
type: string
|
type: string
|
||||||
turn:
|
tool_call:
|
||||||
$ref: '#/components/schemas/AgenticSystemTurn'
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
arguments:
|
||||||
|
additionalProperties:
|
||||||
|
oneOf:
|
||||||
|
- type: 'null'
|
||||||
|
- type: boolean
|
||||||
|
- type: number
|
||||||
|
- type: string
|
||||||
|
- type: array
|
||||||
|
- type: object
|
||||||
|
type: object
|
||||||
|
tool_name:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- tool_name
|
||||||
|
- arguments
|
||||||
|
title: A tool call is a request to a tool.
|
||||||
|
type: object
|
||||||
|
tool_response_delta:
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
response:
|
||||||
|
type: string
|
||||||
|
tool_name:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- tool_name
|
||||||
|
- response
|
||||||
|
type: object
|
||||||
|
violation:
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
details:
|
||||||
|
type: string
|
||||||
|
suggested_user_response:
|
||||||
|
type: string
|
||||||
|
violation_type:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- violation_type
|
||||||
|
- details
|
||||||
|
type: object
|
||||||
required:
|
required:
|
||||||
- turn
|
- event_type
|
||||||
|
- step_uuid
|
||||||
|
- step_type
|
||||||
title: Streamed agent execution response.
|
title: Streamed agent execution response.
|
||||||
type: object
|
type: object
|
||||||
AgenticSystemTurn:
|
AgenticSystemTurn:
|
||||||
|
@ -139,8 +213,11 @@ components:
|
||||||
type: string
|
type: string
|
||||||
text:
|
text:
|
||||||
type: string
|
type: string
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
required:
|
required:
|
||||||
- step_type
|
- step_type
|
||||||
|
- uuid
|
||||||
- text
|
- text
|
||||||
type: object
|
type: object
|
||||||
- additionalProperties: false
|
- additionalProperties: false
|
||||||
|
@ -189,8 +266,11 @@ components:
|
||||||
- response
|
- response
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
required:
|
required:
|
||||||
- step_type
|
- step_type
|
||||||
|
- uuid
|
||||||
- tool_calls
|
- tool_calls
|
||||||
- tool_responses
|
- tool_responses
|
||||||
type: object
|
type: object
|
||||||
|
@ -205,6 +285,8 @@ components:
|
||||||
- memory_retrieval
|
- memory_retrieval
|
||||||
title: The type of execution step.
|
title: The type of execution step.
|
||||||
type: string
|
type: string
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
violation:
|
violation:
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
|
@ -220,12 +302,22 @@ components:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- step_type
|
- step_type
|
||||||
|
- uuid
|
||||||
type: object
|
type: object
|
||||||
- additionalProperties: false
|
- additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
documents:
|
documents:
|
||||||
items:
|
items:
|
||||||
type: string
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
content:
|
||||||
|
type: string
|
||||||
|
index_id:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- index_id
|
||||||
|
- content
|
||||||
|
type: object
|
||||||
type: array
|
type: array
|
||||||
scores:
|
scores:
|
||||||
items:
|
items:
|
||||||
|
@ -240,8 +332,11 @@ components:
|
||||||
- memory_retrieval
|
- memory_retrieval
|
||||||
title: The type of execution step.
|
title: The type of execution step.
|
||||||
type: string
|
type: string
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
required:
|
required:
|
||||||
- step_type
|
- step_type
|
||||||
|
- uuid
|
||||||
- documents
|
- documents
|
||||||
- scores
|
- scores
|
||||||
type: object
|
type: object
|
||||||
|
@ -720,8 +815,8 @@ security:
|
||||||
servers:
|
servers:
|
||||||
- url: http://llama.meta.com
|
- url: http://llama.meta.com
|
||||||
tags:
|
tags:
|
||||||
- name: Inference
|
|
||||||
- name: AgenticSystem
|
- name: AgenticSystem
|
||||||
|
- name: Inference
|
||||||
- description: <SchemaDefinition schemaRef="#/components/schemas/AgenticSystemCreateRequest"
|
- description: <SchemaDefinition schemaRef="#/components/schemas/AgenticSystemCreateRequest"
|
||||||
/>
|
/>
|
||||||
name: AgenticSystemCreateRequest
|
name: AgenticSystemCreateRequest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue