-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from parea-ai/refactor-log-schema
refactor: move log into its own class
- Loading branch information
Showing
10 changed files
with
70 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import Any, Dict, List, Optional, Union | ||
|
||
from enum import Enum | ||
|
||
from attr import define | ||
|
||
|
||
class Role(str, Enum): | ||
user = "user" | ||
assistant = "assistant" | ||
system = "system" | ||
example_user = "example_user" | ||
example_assistant = "example_assistant" | ||
|
||
|
||
@define | ||
class Message: | ||
content: str | ||
role: Role = Role.user | ||
|
||
def to_dict(self) -> dict[str, str]: | ||
return { | ||
"content": self.content, | ||
"role": str(self.role), | ||
} | ||
|
||
|
||
@define | ||
class ModelParams: | ||
temp: float = 1.0 | ||
top_p: float = 1.0 | ||
frequency_penalty: float = 0.0 | ||
presence_penalty: float = 0.0 | ||
max_length: Optional[int] = None | ||
|
||
|
||
@define | ||
class LLMInputs: | ||
model: Optional[str] = None | ||
provider: Optional[str] = None | ||
model_params: Optional[ModelParams] = None | ||
messages: Optional[List[Message]] = None | ||
functions: Optional[List[Any]] = None | ||
function_call: Optional[Union[str, dict[str, str]]] = None | ||
|
||
|
||
@define | ||
class Log: | ||
configuration: LLMInputs = LLMInputs() | ||
inputs: Optional[Dict[str, str]] = None | ||
output: Optional[str] = None | ||
target: Optional[str] = None | ||
latency: Optional[float] = 0.0 | ||
input_tokens: Optional[int] = 0 | ||
output_tokens: Optional[int] = 0 | ||
total_tokens: Optional[int] = 0 | ||
cost: Optional[float] = 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters