-
-
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.
refactor: Renamed Encoders to ModelToEncoder.
- Loading branch information
Showing
4 changed files
with
39 additions
and
33 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,31 @@ | ||
namespace Tiktoken; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static class ModelToEncoder | ||
{ | ||
/// <summary> | ||
/// Returns encoder by model name. | ||
/// </summary> | ||
/// <param name="modelName">gpt-3.5-turbo</param> | ||
/// <returns></returns> | ||
public static Encoder For(string modelName) | ||
{ | ||
return new Encoder(ModelToEncoding.For(modelName)); | ||
} | ||
|
||
/// <summary> | ||
/// Returns encoder by model name or null. | ||
/// </summary> | ||
/// <param name="modelName">gpt-3.5-turbo</param> | ||
/// <returns></returns> | ||
public static Encoder? TryFor(string modelName) | ||
{ | ||
var encoding = ModelToEncoding.TryFor(modelName); | ||
|
||
return encoding == null | ||
? null | ||
: new Encoder(encoding); | ||
} | ||
} |
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
39b1550
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! Even with "For" and "TryFor"! Someone know what they are doing 😉
Thx again.