Add version to REST API url

This commit is contained in:
Ashwin Bharambe 2024-11-18 18:53:06 -08:00
parent 7693786322
commit c73fe390ad
18 changed files with 32837 additions and 6032 deletions

View file

@ -31,7 +31,7 @@ from .strong_typing.schema import json_schema_type
schema_utils.json_schema_type = json_schema_type
from llama_stack.distribution.stack import LlamaStack
from llama_stack.distribution.stack import LLAMA_STACK_API_VERSION, LlamaStack # noqa
def main(output_dir: str):
@ -50,7 +50,7 @@ def main(output_dir: str):
server=Server(url="http://any-hosted-llama-stack.com"),
info=Info(
title="[DRAFT] Llama Stack Specification",
version="0.0.1",
version=LLAMA_STACK_API_VERSION,
description="""This is the specification of the llama stack that provides
a set of endpoints and their corresponding interfaces that are tailored to
best leverage Llama Models. The specification is still in draft and subject to change.

View file

@ -202,7 +202,9 @@ class ContentBuilder:
) -> MediaType:
schema = self.schema_builder.classdef_to_ref(item_type)
if self.schema_transformer:
schema_transformer: Callable[[SchemaOrRef], SchemaOrRef] = self.schema_transformer # type: ignore
schema_transformer: Callable[[SchemaOrRef], SchemaOrRef] = (
self.schema_transformer
) # type: ignore
schema = schema_transformer(schema)
if not examples:
@ -630,6 +632,7 @@ class Generator:
raise NotImplementedError(f"unknown HTTP method: {op.http_method}")
route = op.get_route()
print(f"route: {route}")
if route in paths:
paths[route].update(pathItem)
else:

View file

@ -12,6 +12,8 @@ import uuid
from dataclasses import dataclass
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
from llama_stack.distribution.stack import LLAMA_STACK_API_VERSION
from termcolor import colored
from ..strong_typing.inspection import (
@ -111,9 +113,12 @@ class EndpointOperation:
def get_route(self) -> str:
if self.route is not None:
return self.route
assert (
"_" not in self.route
), f"route should not contain underscores: {self.route}"
return "/".join(["", LLAMA_STACK_API_VERSION, self.route.lstrip("/")])
route_parts = ["", self.name]
route_parts = ["", LLAMA_STACK_API_VERSION, self.name]
for param_name, _ in self.path_params:
route_parts.append("{" + param_name + "}")
return "/".join(route_parts)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff