This commit is contained in:
Xi Yan 2025-03-13 14:48:11 -07:00
parent 89885fd2fa
commit a6095820af
3 changed files with 224 additions and 316 deletions

View file

@ -40,75 +40,7 @@
} }
], ],
"paths": { "paths": {
"/v1/datasetio/rows": { "/v1/datasets/{dataset_id}/rows": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaginatedRowsResult"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest400"
},
"429": {
"$ref": "#/components/responses/TooManyRequests429"
},
"500": {
"$ref": "#/components/responses/InternalServerError500"
},
"default": {
"$ref": "#/components/responses/DefaultError"
}
},
"tags": [
"DatasetIO"
],
"description": "Get a paginated list of rows from a dataset.",
"parameters": [
{
"name": "dataset_id",
"in": "query",
"description": "The ID of the dataset to get the rows from.",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "rows_in_page",
"in": "query",
"description": "The number of rows to get per page.",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "page_token",
"in": "query",
"description": "The token to get the next page of rows.",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "filter_condition",
"in": "query",
"description": "(Optional) A condition to filter the rows by.",
"required": false,
"schema": {
"type": "string"
}
}
]
},
"post": { "post": {
"responses": { "responses": {
"200": { "200": {
@ -131,7 +63,16 @@
"DatasetIO" "DatasetIO"
], ],
"description": "", "description": "",
"parameters": [], "parameters": [
{
"name": "dataset_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": { "requestBody": {
"content": { "content": {
"application/json": { "application/json": {
@ -2194,6 +2135,76 @@
} }
} }
}, },
"/v1/datasets/{dataset_id}/iterrows": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaginatedRowsResult"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest400"
},
"429": {
"$ref": "#/components/responses/TooManyRequests429"
},
"500": {
"$ref": "#/components/responses/InternalServerError500"
},
"default": {
"$ref": "#/components/responses/DefaultError"
}
},
"tags": [
"DatasetIO"
],
"description": "Get a paginated list of rows from a dataset.",
"parameters": [
{
"name": "dataset_id",
"in": "path",
"description": "The ID of the dataset to get the rows from.",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "rows_in_page",
"in": "query",
"description": "The number of rows to get per page.",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "page_token",
"in": "query",
"description": "The token to get the next page of rows.",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "filter_condition",
"in": "query",
"description": "(Optional) A condition to filter the rows by.",
"required": false,
"schema": {
"type": "string"
}
}
]
}
},
"/v1/eval/benchmarks/{benchmark_id}/jobs/{job_id}": { "/v1/eval/benchmarks/{benchmark_id}/jobs/{job_id}": {
"get": { "get": {
"responses": { "responses": {
@ -3789,9 +3800,6 @@
"AppendRowsRequest": { "AppendRowsRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"dataset_id": {
"type": "string"
},
"rows": { "rows": {
"type": "array", "type": "array",
"items": { "items": {
@ -3823,7 +3831,6 @@
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"dataset_id",
"rows" "rows"
], ],
"title": "AppendRowsRequest" "title": "AppendRowsRequest"
@ -6794,9 +6801,6 @@
{ {
"$ref": "#/components/schemas/URIDataSource" "$ref": "#/components/schemas/URIDataSource"
}, },
{
"$ref": "#/components/schemas/HuggingfaceDataSource"
},
{ {
"$ref": "#/components/schemas/RowsDataSource" "$ref": "#/components/schemas/RowsDataSource"
} }
@ -6805,7 +6809,6 @@
"propertyName": "type", "propertyName": "type",
"mapping": { "mapping": {
"uri": "#/components/schemas/URIDataSource", "uri": "#/components/schemas/URIDataSource",
"huggingface": "#/components/schemas/HuggingfaceDataSource",
"rows": "#/components/schemas/RowsDataSource" "rows": "#/components/schemas/RowsDataSource"
} }
} }
@ -6878,65 +6881,6 @@
], ],
"title": "Dataset" "title": "Dataset"
}, },
"HuggingfaceDataSource": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "huggingface",
"default": "huggingface",
"description": "The type of the data source."
},
"huggingface": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "The path to the dataset in Huggingface. E.g. - \"llamastack/simpleqa\""
},
"params": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
},
"description": "The parameters for the dataset."
}
},
"additionalProperties": false,
"required": [
"path",
"params"
],
"description": "The fields for a Huggingface dataset."
}
},
"additionalProperties": false,
"required": [
"type",
"huggingface"
],
"title": "HuggingfaceDataSource",
"description": "A dataset stored in Huggingface."
},
"RowsDataSource": { "RowsDataSource": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -7070,55 +7014,6 @@
], ],
"title": "ModelType" "title": "ModelType"
}, },
"PaginatedRowsResult": {
"type": "object",
"properties": {
"rows": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
},
"description": "The rows in the current page."
},
"total_count": {
"type": "integer",
"description": "The total number of rows in the dataset."
},
"next_page_token": {
"type": "string",
"description": "The token to get the next page of rows."
}
},
"additionalProperties": false,
"required": [
"rows",
"total_count"
],
"title": "PaginatedRowsResult",
"description": "A paginated list of rows from a dataset."
},
"AgentTurnInputType": { "AgentTurnInputType": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -8153,6 +8048,55 @@
], ],
"title": "ToolInvocationResult" "title": "ToolInvocationResult"
}, },
"PaginatedRowsResult": {
"type": "object",
"properties": {
"rows": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
},
"description": "The rows in the current page."
},
"total_count": {
"type": "integer",
"description": "The total number of rows in the dataset."
},
"next_page_token": {
"type": "string",
"description": "The token to get the next page of rows."
}
},
"additionalProperties": false,
"required": [
"rows",
"total_count"
],
"title": "PaginatedRowsResult",
"description": "A paginated list of rows from a dataset."
},
"ListAgentSessionsResponse": { "ListAgentSessionsResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -9431,7 +9375,7 @@
}, },
"source": { "source": {
"$ref": "#/components/schemas/DataSource", "$ref": "#/components/schemas/DataSource",
"description": "The data source of the dataset. Examples: - { \"type\": \"uri\", \"uri\": \"https://mywebsite.com/mydata.jsonl\" } - { \"type\": \"uri\", \"uri\": \"lsfs://mydata.jsonl\" } - { \"type\": \"huggingface\", \"huggingface\": { \"dataset_path\": \"tatsu-lab/alpaca\", \"params\": { \"split\": \"train\" } } } - { \"type\": \"rows\", \"rows\": [ { \"messages\": [ {\"role\": \"user\", \"content\": \"Hello, world!\"}, {\"role\": \"assistant\", \"content\": \"Hello, world!\"}, ] } ] }" "description": "The data source of the dataset. Examples: - { \"type\": \"uri\", \"uri\": \"https://mywebsite.com/mydata.jsonl\" } - { \"type\": \"uri\", \"uri\": \"lsfs://mydata.jsonl\" } - { \"type\": \"uri\", \"uri\": \"data:csv;base64,{base64_content}\" } - { \"type\": \"uri\", \"uri\": \"huggingface://llamastack/simpleqa?split=train\" } - { \"type\": \"rows\", \"rows\": [ { \"messages\": [ {\"role\": \"user\", \"content\": \"Hello, world!\"}, {\"role\": \"assistant\", \"content\": \"Hello, world!\"}, ] } ] }"
}, },
"metadata": { "metadata": {
"type": "object", "type": "object",
@ -9461,7 +9405,7 @@
}, },
"dataset_id": { "dataset_id": {
"type": "string", "type": "string",
"description": "The ID of the dataset. If not provided, a random ID will be generated." "description": "The ID of the dataset. If not provided, an ID will be generated."
} }
}, },
"additionalProperties": false, "additionalProperties": false,

View file

@ -10,56 +10,7 @@ info:
servers: servers:
- url: http://any-hosted-llama-stack.com - url: http://any-hosted-llama-stack.com
paths: paths:
/v1/datasetio/rows: /v1/datasets/{dataset_id}/rows:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedRowsResult'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
$ref: >-
#/components/responses/TooManyRequests429
'500':
$ref: >-
#/components/responses/InternalServerError500
default:
$ref: '#/components/responses/DefaultError'
tags:
- DatasetIO
description: >-
Get a paginated list of rows from a dataset.
parameters:
- name: dataset_id
in: query
description: >-
The ID of the dataset to get the rows from.
required: true
schema:
type: string
- name: rows_in_page
in: query
description: The number of rows to get per page.
required: true
schema:
type: integer
- name: page_token
in: query
description: The token to get the next page of rows.
required: false
schema:
type: string
- name: filter_condition
in: query
description: >-
(Optional) A condition to filter the rows by.
required: false
schema:
type: string
post: post:
responses: responses:
'200': '200':
@ -77,7 +28,12 @@ paths:
tags: tags:
- DatasetIO - DatasetIO
description: '' description: ''
parameters: [] parameters:
- name: dataset_id
in: path
required: true
schema:
type: string
requestBody: requestBody:
content: content:
application/json: application/json:
@ -1473,6 +1429,56 @@ paths:
schema: schema:
$ref: '#/components/schemas/InvokeToolRequest' $ref: '#/components/schemas/InvokeToolRequest'
required: true required: true
/v1/datasets/{dataset_id}/iterrows:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedRowsResult'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
$ref: >-
#/components/responses/TooManyRequests429
'500':
$ref: >-
#/components/responses/InternalServerError500
default:
$ref: '#/components/responses/DefaultError'
tags:
- DatasetIO
description: >-
Get a paginated list of rows from a dataset.
parameters:
- name: dataset_id
in: path
description: >-
The ID of the dataset to get the rows from.
required: true
schema:
type: string
- name: rows_in_page
in: query
description: The number of rows to get per page.
required: true
schema:
type: integer
- name: page_token
in: query
description: The token to get the next page of rows.
required: false
schema:
type: string
- name: filter_condition
in: query
description: >-
(Optional) A condition to filter the rows by.
required: false
schema:
type: string
/v1/eval/benchmarks/{benchmark_id}/jobs/{job_id}: /v1/eval/benchmarks/{benchmark_id}/jobs/{job_id}:
get: get:
responses: responses:
@ -2583,8 +2589,6 @@ components:
AppendRowsRequest: AppendRowsRequest:
type: object type: object
properties: properties:
dataset_id:
type: string
rows: rows:
type: array type: array
items: items:
@ -2599,7 +2603,6 @@ components:
- type: object - type: object
additionalProperties: false additionalProperties: false
required: required:
- dataset_id
- rows - rows
title: AppendRowsRequest title: AppendRowsRequest
CompletionMessage: CompletionMessage:
@ -4705,13 +4708,11 @@ components:
DataSource: DataSource:
oneOf: oneOf:
- $ref: '#/components/schemas/URIDataSource' - $ref: '#/components/schemas/URIDataSource'
- $ref: '#/components/schemas/HuggingfaceDataSource'
- $ref: '#/components/schemas/RowsDataSource' - $ref: '#/components/schemas/RowsDataSource'
discriminator: discriminator:
propertyName: type propertyName: type
mapping: mapping:
uri: '#/components/schemas/URIDataSource' uri: '#/components/schemas/URIDataSource'
huggingface: '#/components/schemas/HuggingfaceDataSource'
rows: '#/components/schemas/RowsDataSource' rows: '#/components/schemas/RowsDataSource'
Dataset: Dataset:
type: object type: object
@ -4757,43 +4758,6 @@ components:
- source - source
- metadata - metadata
title: Dataset title: Dataset
HuggingfaceDataSource:
type: object
properties:
type:
type: string
const: huggingface
default: huggingface
description: The type of the data source.
huggingface:
type: object
properties:
path:
type: string
description: >-
The path to the dataset in Huggingface. E.g. - "llamastack/simpleqa"
params:
type: object
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
description: The parameters for the dataset.
additionalProperties: false
required:
- path
- params
description: The fields for a Huggingface dataset.
additionalProperties: false
required:
- type
- huggingface
title: HuggingfaceDataSource
description: A dataset stored in Huggingface.
RowsDataSource: RowsDataSource:
type: object type: object
properties: properties:
@ -4883,34 +4847,6 @@ components:
- llm - llm
- embedding - embedding
title: ModelType title: ModelType
PaginatedRowsResult:
type: object
properties:
rows:
type: array
items:
type: object
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
description: The rows in the current page.
total_count:
type: integer
description: The total number of rows in the dataset.
next_page_token:
type: string
description: The token to get the next page of rows.
additionalProperties: false
required:
- rows
- total_count
title: PaginatedRowsResult
description: A paginated list of rows from a dataset.
AgentTurnInputType: AgentTurnInputType:
type: object type: object
properties: properties:
@ -5557,6 +5493,34 @@ components:
required: required:
- content - content
title: ToolInvocationResult title: ToolInvocationResult
PaginatedRowsResult:
type: object
properties:
rows:
type: array
items:
type: object
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
description: The rows in the current page.
total_count:
type: integer
description: The total number of rows in the dataset.
next_page_token:
type: string
description: The token to get the next page of rows.
additionalProperties: false
required:
- rows
- total_count
title: PaginatedRowsResult
description: A paginated list of rows from a dataset.
ListAgentSessionsResponse: ListAgentSessionsResponse:
type: object type: object
properties: properties:
@ -6401,11 +6365,11 @@ components:
$ref: '#/components/schemas/DataSource' $ref: '#/components/schemas/DataSource'
description: >- description: >-
The data source of the dataset. Examples: - { "type": "uri", "uri": "https://mywebsite.com/mydata.jsonl" The data source of the dataset. Examples: - { "type": "uri", "uri": "https://mywebsite.com/mydata.jsonl"
} - { "type": "uri", "uri": "lsfs://mydata.jsonl" } - { "type": "huggingface", } - { "type": "uri", "uri": "lsfs://mydata.jsonl" } - { "type": "uri",
"huggingface": { "dataset_path": "tatsu-lab/alpaca", "params": { "split": "uri": "data:csv;base64,{base64_content}" } - { "type": "uri", "uri":
"train" } } } - { "type": "rows", "rows": [ { "messages": [ {"role": "user", "huggingface://llamastack/simpleqa?split=train" } - { "type": "rows",
"content": "Hello, world!"}, {"role": "assistant", "content": "Hello, "rows": [ { "messages": [ {"role": "user", "content": "Hello, world!"},
world!"}, ] } ] } {"role": "assistant", "content": "Hello, world!"}, ] } ] }
metadata: metadata:
type: object type: object
additionalProperties: additionalProperties:
@ -6421,7 +6385,7 @@ components:
dataset_id: dataset_id:
type: string type: string
description: >- description: >-
The ID of the dataset. If not provided, a random ID will be generated. The ID of the dataset. If not provided, an ID will be generated.
additionalProperties: false additionalProperties: false
required: required:
- purpose - purpose

View file

@ -193,7 +193,7 @@ class Datasets(Protocol):
} }
:param metadata: The metadata for the dataset. :param metadata: The metadata for the dataset.
- E.g. {"description": "My dataset"} - E.g. {"description": "My dataset"}
:param dataset_id: The ID of the dataset. If not provided, a random ID will be generated. :param dataset_id: The ID of the dataset. If not provided, an ID will be generated.
""" """
... ...