Skip to content

Commit

Permalink
Update DTO for new Artemis table
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjoham committed Oct 19, 2024
1 parent 3253c46 commit 9fe9e0a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/common/token_usage_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


class TokenUsageDTO(BaseModel):
model_info: str = Field(alias="modelInfo", default="")
model_info: str = Field(alias="model", default="")
num_input_tokens: int = Field(alias="numInputTokens", default=0)
cost_per_input_token: float = Field(alias="costPerInputToken", default=0)
cost_per_input_token: float = Field(alias="costPerMillionInputToken", default=0)
num_output_tokens: int = Field(alias="numOutputTokens", default=0)
cost_per_output_token: float = Field(alias="costPerOutputToken", default=0)
pipeline: PipelineEnum = Field(default=PipelineEnum.NOT_SET)
cost_per_output_token: float = Field(alias="costPerMillionOutputToken", default=0)
pipeline: PipelineEnum = Field(alias="pipelineId", default=PipelineEnum.NOT_SET)

def __str__(self):
return (
Expand Down
2 changes: 1 addition & 1 deletion app/llm/external/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def convert_to_iris_message(
tokens = TokenUsageDTO(
numInputTokens=num_input_tokens,
numOutputTokens=num_output_tokens,
modelInfo=model,
model=model,
)
return PyrisMessage(
sender=map_str_to_role(message["role"]),
Expand Down
2 changes: 1 addition & 1 deletion app/llm/external/openai_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def convert_to_iris_message(
num_output_tokens = getattr(usage, "completion_tokens", -1)

tokens = TokenUsageDTO(
modelInfo=model,
model=model,
numInputTokens=num_input_tokens,
numOutputTokens=num_output_tokens,
)
Expand Down
6 changes: 3 additions & 3 deletions app/llm/langchain/iris_langchain_chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def _generate(
base_message = convert_iris_message_to_langchain_message(iris_message)
chat_generation = ChatGeneration(message=base_message)
self.tokens = TokenUsageDTO(
modelInfo=iris_message.token_usage.model_info,
model=iris_message.token_usage.model_info,
numInputTokens=iris_message.token_usage.num_input_tokens,
costPerInputToken=iris_message.token_usage.cost_per_input_token,
costPerMillionInputToken=iris_message.token_usage.cost_per_input_token,
numOutputTokens=iris_message.token_usage.num_output_tokens,
costPerOutputToken=iris_message.token_usage.cost_per_output_token,
costPerMillionOutputToken=iris_message.token_usage.cost_per_output_token,
pipeline=PipelineEnum.NOT_SET,
)
return ChatResult(generations=[chat_generation])
Expand Down

0 comments on commit 9fe9e0a

Please sign in to comment.