Skip to content

Commit

Permalink
Minor changes (Readme + builds fix)
Browse files Browse the repository at this point in the history
1. Removed signing from test-PR build (#23)
2. Added model prefix documentation
  • Loading branch information
dmitry-brazhenko authored Sep 12, 2023
1 parent 68b2126 commit ff2e74c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Write SNK file
shell: pwsh
run: |
$env:SNK_BASE64 -split ' ' -join "`n" | Out-File -Encoding utf8 ./SharpToken/keypair.snk.base64.txt
certutil -decode ./SharpToken/keypair.snk.base64.txt ./SharpToken/keypair.snk
env:
SNK_BASE64: ${{ secrets.SNK_BASE64 }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/build-test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Write SNK file
shell: pwsh
run: |
$env:SNK_BASE64 -split ' ' -join "`n" | Out-File -Encoding utf8 ./SharpToken/keypair.snk.base64.txt
certutil -decode ./SharpToken/keypair.snk.base64.txt ./SharpToken/keypair.snk
env:
SNK_BASE64: ${{ secrets.SNK_BASE64 }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -37,7 +29,7 @@ jobs:
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet build --configuration Release --no-restore /p:EnableSigning=true

- name: Test
run: dotnet test --no-restore --verbosity normal
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,34 @@ var p50kEditEncoding = GptEncoding.GetEncoding("p50k_edit");
var cl100kBaseEncoding = GptEncoding.GetEncoding("cl100k_base");
```

### Model Prefix Matching

Apart from specifying direct model names, SharpToken also provides functionality to map model names based on specific prefixes. This allows users to retrieve an encoding based on a model's prefix.

Here are the current supported prefixes and their corresponding encodings:

| Model Prefix | Encoding |
|---------------------|------------|
| `gpt-4-` | `cl100k_base` |
| `gpt-3.5-turbo-` | `cl100k_base` |
| `gpt-35-turbo` | `cl100k_base` |

Examples of model names that fall under these prefixes include:
- For the prefix `gpt-4-`: `gpt-4-0314`, `gpt-4-32k`, etc.
- For the prefix `gpt-3.5-turbo-`: `gpt-3.5-turbo-0301`, `gpt-3.5-turbo-0401`, etc.
- For the Azure deployment name `gpt-35-turbo`.

To retrieve the encoding name based on a model name or its prefix, you can use the `GetEncodingNameForModel` method:

```csharp
string encodingName = GetEncodingNameForModel("gpt-4-0314"); // This will return "cl100k_base"
```

If the provided model name doesn't match any direct model names or prefixes, the method will return `null`.




## Understanding Encoded Values

When you encode a string using the Encode method, the returned value is a list of integers that represent tokens in the
Expand Down
4 changes: 2 additions & 2 deletions SharpToken/SharpToken.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>


<PropertyGroup>
<KeyFilePath>keypair.snk</KeyFilePath>
<EnableSigning>false</EnableSigning>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<PropertyGroup Condition="'$(Configuration)' == 'Release' AND '$(EnableSigning)' == 'true'">
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(KeyFilePath)</AssemblyOriginatorKeyFile>
</PropertyGroup>
Expand Down

0 comments on commit ff2e74c

Please sign in to comment.