mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-05 18:22:41 +00:00
add duck openai logprobs
This commit is contained in:
parent
44069404fd
commit
e0771e0c47
1 changed files with 12 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from typing import AsyncGenerator, List, Optional
|
from typing import AsyncGenerator, Dict, List, Optional
|
||||||
|
|
||||||
from llama_models.llama3.api.chat_format import ChatFormat
|
from llama_models.llama3.api.chat_format import ChatFormat
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ from llama_models.llama3.api.datatypes import (
|
||||||
TopKSamplingStrategy,
|
TopKSamplingStrategy,
|
||||||
TopPSamplingStrategy,
|
TopPSamplingStrategy,
|
||||||
)
|
)
|
||||||
from openai.types.completion_choice import Logprobs as OpenAILogprobs
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from llama_stack.apis.common.content_types import (
|
from llama_stack.apis.common.content_types import (
|
||||||
|
@ -47,10 +46,21 @@ class OpenAICompatCompletionChoiceDelta(BaseModel):
|
||||||
content: str
|
content: str
|
||||||
|
|
||||||
|
|
||||||
|
class OpenAILogprobs(BaseModel):
|
||||||
|
text_offset: Optional[List[int]] = None
|
||||||
|
|
||||||
|
token_logprobs: Optional[List[float]] = None
|
||||||
|
|
||||||
|
tokens: Optional[List[str]] = None
|
||||||
|
|
||||||
|
top_logprobs: Optional[List[Dict[str, float]]] = None
|
||||||
|
|
||||||
|
|
||||||
class OpenAICompatCompletionChoice(BaseModel):
|
class OpenAICompatCompletionChoice(BaseModel):
|
||||||
finish_reason: Optional[str] = None
|
finish_reason: Optional[str] = None
|
||||||
text: Optional[str] = None
|
text: Optional[str] = None
|
||||||
delta: Optional[OpenAICompatCompletionChoiceDelta] = None
|
delta: Optional[OpenAICompatCompletionChoiceDelta] = None
|
||||||
|
logprobs: Optional[OpenAILogprobs] = None
|
||||||
|
|
||||||
|
|
||||||
class OpenAICompatCompletionResponse(BaseModel):
|
class OpenAICompatCompletionResponse(BaseModel):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue