-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Nova micro/lite/pro using Converse (#197)
- Loading branch information
1 parent
ec1b94a
commit c061d9c
Showing
7 changed files
with
86 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import json | ||
|
||
from aidial_adapter_bedrock.llm.converse.adapter import ConverseMessages | ||
from aidial_adapter_bedrock.llm.converse.types import ( | ||
ConverseDeployment, | ||
ConverseRequestWrapper, | ||
) | ||
from aidial_adapter_bedrock.llm.tokenize import default_tokenize_string | ||
|
||
|
||
def default_converse_tokenizer_factory( | ||
deployment: ConverseDeployment, params: ConverseRequestWrapper | ||
): | ||
tool_tokens = default_tokenize_string(json.dumps(params.toolConfig)) | ||
system_tokens = default_tokenize_string(json.dumps(params.system)) | ||
|
||
async def tokenizer(msg_items: ConverseMessages) -> int: | ||
tokens = sum( | ||
default_tokenize_string(json.dumps(msg_item[0])) | ||
for msg_item in msg_items | ||
) | ||
return tokens + tool_tokens + system_tokens | ||
|
||
return tokenizer |
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