Skip to content

Commit

Permalink
Add token count to build
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelseeger committed Dec 30, 2023
1 parent e0a79c5 commit 8a33cde
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
import os
from dotenv import load_dotenv
import json
import tiktoken

load_dotenv()


def main():
encoding = tiktoken.get_encoding("cl100k_base")

tools = [
{
"type:": "code_interpreter",
Expand All @@ -16,6 +19,8 @@ def main():

with open(os.path.join("aicoach", "initial_instructions.txt"), "r") as f:
assistant["instructions"] = f.read()
tokens = encoding.encode(assistant["instructions"])
print(f"Current tokens in initial instructions: {len(tokens)}")

assistant["tools"] = assistant["tools"] + [
{"type": "function", "function": f.json()} for f in AIFunctions
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- pandas=2.1.4
- openai=1.6.1
- pytest=7.4.0
- tiktoken=0.5.2
- pip
- pip:
- sc2reader==1.8.0
Expand Down
4 changes: 3 additions & 1 deletion requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
requests==2.31.0
python-dotenv==0.21.0
click==8.1.7
openai==1.6.1
openai==1.6.1
tiktoken==0.5.2
pymongo==4.6.1

0 comments on commit 8a33cde

Please sign in to comment.