update memory_banks method name to for openapi generator to work correctly without naming collision

This commit is contained in:
Xi Yan 2024-09-23 10:29:28 -07:00
parent 2d7ce81302
commit 75357df02d
5 changed files with 229 additions and 103 deletions

View file

@ -21,7 +21,7 @@
"info": { "info": {
"title": "[DRAFT] Llama Stack Specification", "title": "[DRAFT] Llama Stack Specification",
"version": "0.0.1", "version": "0.0.1",
"description": "This is the specification of the llama stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models. The specification is still in draft and subject to change.\n Generated at 2024-09-23 10:08:50.987103" "description": "This is the specification of the llama stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models. The specification is still in draft and subject to change.\n Generated at 2024-09-23 10:24:44.422779"
}, },
"servers": [ "servers": [
{ {
@ -1180,7 +1180,7 @@
] ]
} }
}, },
"/memory_banks/get": { "/memory/get": {
"get": { "get": {
"responses": { "responses": {
"200": { "200": {
@ -1190,7 +1190,7 @@
"schema": { "schema": {
"oneOf": [ "oneOf": [
{ {
"$ref": "#/components/schemas/MemoryBankSpec" "$ref": "#/components/schemas/MemoryBank"
}, },
{ {
"type": "null" "type": "null"
@ -1206,11 +1206,11 @@
], ],
"parameters": [ "parameters": [
{ {
"name": "bank_type", "name": "bank_id",
"in": "query", "in": "query",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/components/schemas/MemoryBankType" "type": "string"
} }
}, },
{ {
@ -1270,6 +1270,51 @@
] ]
} }
}, },
"/memory_banks/get": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/MemoryBankSpec"
},
{
"type": "null"
}
]
}
}
}
}
},
"tags": [
"MemoryBanks"
],
"parameters": [
{
"name": "bank_type",
"in": "query",
"required": true,
"schema": {
"$ref": "#/components/schemas/MemoryBankType"
}
},
{
"name": "X-LlamaStack-ProviderData",
"in": "header",
"description": "JSON-encoded provider data which will be made available to the adapter servicing the API",
"required": false,
"schema": {
"type": "string"
}
}
]
}
},
"/shields/get": { "/shields/get": {
"get": { "get": {
"responses": { "responses": {
@ -1544,6 +1589,36 @@
} }
} }
}, },
"tags": [
"MemoryBanks"
],
"parameters": [
{
"name": "X-LlamaStack-ProviderData",
"in": "header",
"description": "JSON-encoded provider data which will be made available to the adapter servicing the API",
"required": false,
"schema": {
"type": "string"
}
}
]
}
},
"/memory/list": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/MemoryBank"
}
}
}
}
},
"tags": [ "tags": [
"Memory" "Memory"
], ],
@ -4471,6 +4546,60 @@
"job_uuid" "job_uuid"
] ]
}, },
"Model": {
"description": "The model family and SKU of the model along with other parameters corresponding to the model."
},
"ModelServingSpec": {
"type": "object",
"properties": {
"llama_model": {
"$ref": "#/components/schemas/Model"
},
"provider_config": {
"type": "object",
"properties": {
"provider_id": {
"type": "string"
},
"config": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
}
},
"additionalProperties": false,
"required": [
"provider_id",
"config"
]
}
},
"additionalProperties": false,
"required": [
"llama_model",
"provider_config"
]
},
"MemoryBankType": { "MemoryBankType": {
"type": "string", "type": "string",
"enum": [ "enum": [
@ -4531,60 +4660,6 @@
"provider_config" "provider_config"
] ]
}, },
"Model": {
"description": "The model family and SKU of the model along with other parameters corresponding to the model."
},
"ModelServingSpec": {
"type": "object",
"properties": {
"llama_model": {
"$ref": "#/components/schemas/Model"
},
"provider_config": {
"type": "object",
"properties": {
"provider_id": {
"type": "string"
},
"config": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
}
},
"additionalProperties": false,
"required": [
"provider_id",
"config"
]
}
},
"additionalProperties": false,
"required": [
"llama_model",
"provider_config"
]
},
"ShieldSpec": { "ShieldSpec": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5895,25 +5970,25 @@
], ],
"tags": [ "tags": [
{ {
"name": "Datasets" "name": "Inference"
},
{
"name": "Safety"
},
{
"name": "Telemetry"
}, },
{ {
"name": "Agents" "name": "Agents"
}, },
{ {
"name": "BatchInference" "name": "PostTraining"
},
{
"name": "SyntheticDataGeneration"
}, },
{ {
"name": "Models" "name": "Models"
}, },
{ {
"name": "SyntheticDataGeneration" "name": "BatchInference"
},
{
"name": "Safety"
}, },
{ {
"name": "Evaluations" "name": "Evaluations"
@ -5922,16 +5997,19 @@
"name": "Shields" "name": "Shields"
}, },
{ {
"name": "Memory" "name": "Telemetry"
},
{
"name": "PostTraining"
}, },
{ {
"name": "RewardScoring" "name": "RewardScoring"
}, },
{ {
"name": "Inference" "name": "MemoryBanks"
},
{
"name": "Datasets"
},
{
"name": "Memory"
}, },
{ {
"name": "BuiltinTool", "name": "BuiltinTool",
@ -6273,14 +6351,6 @@
"name": "EvaluationJobStatusResponse", "name": "EvaluationJobStatusResponse",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/EvaluationJobStatusResponse\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/EvaluationJobStatusResponse\" />"
}, },
{
"name": "MemoryBankType",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/MemoryBankType\" />"
},
{
"name": "MemoryBankSpec",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/MemoryBankSpec\" />"
},
{ {
"name": "Model", "name": "Model",
"description": "The model family and SKU of the model along with other parameters corresponding to the model.\n\n<SchemaDefinition schemaRef=\"#/components/schemas/Model\" />" "description": "The model family and SKU of the model along with other parameters corresponding to the model.\n\n<SchemaDefinition schemaRef=\"#/components/schemas/Model\" />"
@ -6289,6 +6359,14 @@
"name": "ModelServingSpec", "name": "ModelServingSpec",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/ModelServingSpec\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/ModelServingSpec\" />"
}, },
{
"name": "MemoryBankType",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/MemoryBankType\" />"
},
{
"name": "MemoryBankSpec",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/MemoryBankSpec\" />"
},
{ {
"name": "ShieldSpec", "name": "ShieldSpec",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/ShieldSpec\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/ShieldSpec\" />"
@ -6456,6 +6534,7 @@
"Evaluations", "Evaluations",
"Inference", "Inference",
"Memory", "Memory",
"MemoryBanks",
"Models", "Models",
"PostTraining", "PostTraining",
"RewardScoring", "RewardScoring",

View file

@ -2443,7 +2443,7 @@ info:
description: "This is the specification of the llama stack that provides\n \ description: "This is the specification of the llama stack that provides\n \
\ a set of endpoints and their corresponding interfaces that are tailored\ \ a set of endpoints and their corresponding interfaces that are tailored\
\ to\n best leverage Llama Models. The specification is still in\ \ to\n best leverage Llama Models. The specification is still in\
\ draft and subject to change.\n Generated at 2024-09-23 10:08:50.987103" \ draft and subject to change.\n Generated at 2024-09-23 10:24:44.422779"
title: '[DRAFT] Llama Stack Specification' title: '[DRAFT] Llama Stack Specification'
version: 0.0.1 version: 0.0.1
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
@ -3147,6 +3147,32 @@ paths:
description: OK description: OK
tags: tags:
- Memory - Memory
/memory/get:
get:
parameters:
- in: query
name: bank_id
required: true
schema:
type: string
- description: JSON-encoded provider data which will be made available to the
adapter servicing the API
in: header
name: X-LlamaStack-ProviderData
required: false
schema:
type: string
responses:
'200':
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/MemoryBank'
- type: 'null'
description: OK
tags:
- Memory
/memory/insert: /memory/insert:
post: post:
parameters: parameters:
@ -3168,6 +3194,25 @@ paths:
description: OK description: OK
tags: tags:
- Memory - Memory
/memory/list:
get:
parameters:
- description: JSON-encoded provider data which will be made available to the
adapter servicing the API
in: header
name: X-LlamaStack-ProviderData
required: false
schema:
type: string
responses:
'200':
content:
application/jsonl:
schema:
$ref: '#/components/schemas/MemoryBank'
description: OK
tags:
- Memory
/memory/query: /memory/query:
post: post:
parameters: parameters:
@ -3239,7 +3284,7 @@ paths:
- type: 'null' - type: 'null'
description: OK description: OK
tags: tags:
- Memory - MemoryBanks
/memory_banks/list: /memory_banks/list:
get: get:
parameters: parameters:
@ -3258,7 +3303,7 @@ paths:
$ref: '#/components/schemas/MemoryBankSpec' $ref: '#/components/schemas/MemoryBankSpec'
description: OK description: OK
tags: tags:
- Memory - MemoryBanks
/models/get: /models/get:
get: get:
parameters: parameters:
@ -3636,19 +3681,20 @@ security:
servers: servers:
- url: http://any-hosted-llama-stack.com - url: http://any-hosted-llama-stack.com
tags: tags:
- name: Datasets - name: Inference
- name: Safety
- name: Telemetry
- name: Agents - name: Agents
- name: BatchInference - name: PostTraining
- name: Models
- name: SyntheticDataGeneration - name: SyntheticDataGeneration
- name: Models
- name: BatchInference
- name: Safety
- name: Evaluations - name: Evaluations
- name: Shields - name: Shields
- name: Memory - name: Telemetry
- name: PostTraining
- name: RewardScoring - name: RewardScoring
- name: Inference - name: MemoryBanks
- name: Datasets
- name: Memory
- description: <SchemaDefinition schemaRef="#/components/schemas/BuiltinTool" /> - description: <SchemaDefinition schemaRef="#/components/schemas/BuiltinTool" />
name: BuiltinTool name: BuiltinTool
- description: <SchemaDefinition schemaRef="#/components/schemas/CompletionMessage" - description: <SchemaDefinition schemaRef="#/components/schemas/CompletionMessage"
@ -3916,10 +3962,6 @@ tags:
- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluationJobStatusResponse" - description: <SchemaDefinition schemaRef="#/components/schemas/EvaluationJobStatusResponse"
/> />
name: EvaluationJobStatusResponse name: EvaluationJobStatusResponse
- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryBankType" />
name: MemoryBankType
- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryBankSpec" />
name: MemoryBankSpec
- description: 'The model family and SKU of the model along with other parameters - description: 'The model family and SKU of the model along with other parameters
corresponding to the model. corresponding to the model.
@ -3929,6 +3971,10 @@ tags:
- description: <SchemaDefinition schemaRef="#/components/schemas/ModelServingSpec" - description: <SchemaDefinition schemaRef="#/components/schemas/ModelServingSpec"
/> />
name: ModelServingSpec name: ModelServingSpec
- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryBankType" />
name: MemoryBankType
- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryBankSpec" />
name: MemoryBankSpec
- description: <SchemaDefinition schemaRef="#/components/schemas/ShieldSpec" /> - description: <SchemaDefinition schemaRef="#/components/schemas/ShieldSpec" />
name: ShieldSpec name: ShieldSpec
- description: <SchemaDefinition schemaRef="#/components/schemas/Trace" /> - description: <SchemaDefinition schemaRef="#/components/schemas/Trace" />
@ -4063,6 +4109,7 @@ x-tagGroups:
- Evaluations - Evaluations
- Inference - Inference
- Memory - Memory
- MemoryBanks
- Models - Models
- PostTraining - PostTraining
- RewardScoring - RewardScoring

View file

@ -25,7 +25,7 @@ class MemoryBanksClient(MemoryBanks):
async def shutdown(self) -> None: async def shutdown(self) -> None:
pass pass
async def list_memory_banks(self) -> List[MemoryBankSpec]: async def list_available_memory_banks(self) -> List[MemoryBankSpec]:
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
response = await client.get( response = await client.get(
f"{self.base_url}/memory_banks/list", f"{self.base_url}/memory_banks/list",
@ -34,7 +34,7 @@ class MemoryBanksClient(MemoryBanks):
response.raise_for_status() response.raise_for_status()
return [MemoryBankSpec(**x) for x in response.json()] return [MemoryBankSpec(**x) for x in response.json()]
async def get_memory_bank( async def get_serving_memory_bank(
self, bank_type: MemoryBankType self, bank_type: MemoryBankType
) -> Optional[MemoryBankSpec]: ) -> Optional[MemoryBankSpec]:
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
@ -55,7 +55,7 @@ class MemoryBanksClient(MemoryBanks):
async def run_main(host: str, port: int, stream: bool): async def run_main(host: str, port: int, stream: bool):
client = MemoryBanksClient(f"http://{host}:{port}") client = MemoryBanksClient(f"http://{host}:{port}")
response = await client.list_memory_banks() response = await client.list_available_memory_banks()
cprint(f"list_memory_banks response={response}", "green") cprint(f"list_memory_banks response={response}", "green")

View file

@ -24,9 +24,9 @@ class MemoryBankSpec(BaseModel):
class MemoryBanks(Protocol): class MemoryBanks(Protocol):
@webmethod(route="/memory_banks/list", method="GET") @webmethod(route="/memory_banks/list", method="GET")
async def list_memory_banks(self) -> List[MemoryBankSpec]: ... async def list_available_memory_banks(self) -> List[MemoryBankSpec]: ...
@webmethod(route="/memory_banks/get", method="GET") @webmethod(route="/memory_banks/get", method="GET")
async def get_memory_bank( async def get_serving_memory_bank(
self, bank_type: MemoryBankType self, bank_type: MemoryBankType
) -> Optional[MemoryBankSpec]: ... ) -> Optional[MemoryBankSpec]: ...

View file

@ -95,7 +95,7 @@ class ShieldsRoutingTable(CommonRoutingTableImpl, Shields):
class MemoryBanksRoutingTable(CommonRoutingTableImpl, MemoryBanks): class MemoryBanksRoutingTable(CommonRoutingTableImpl, MemoryBanks):
async def list_memory_banks(self) -> List[MemoryBankSpec]: async def list_available_memory_banks(self) -> List[MemoryBankSpec]:
specs = [] specs = []
for entry in self.routing_table_config: for entry in self.routing_table_config:
specs.append( specs.append(
@ -106,7 +106,7 @@ class MemoryBanksRoutingTable(CommonRoutingTableImpl, MemoryBanks):
) )
return specs return specs
async def get_memory_bank(self, bank_type: str) -> Optional[MemoryBankSpec]: async def get_serving_memory_bank(self, bank_type: str) -> Optional[MemoryBankSpec]:
for entry in self.routing_table_config: for entry in self.routing_table_config:
if entry.routing_key == bank_type: if entry.routing_key == bank_type:
return MemoryBankSpec( return MemoryBankSpec(