Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lynxrv21 committed Nov 2, 2023
1 parent f8d89eb commit 2c09f2a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ fmt: ## Format code with isort and blace
check: ## Run code quality tools.
@echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry check --lock
# @echo "🚀 Static type checking: Running mypy -p dream_team_gpt"
# @poetry run mypy -p dream_team_gpt
@echo "🚀 Static type checking: Running mypy -p dream_team_gpt"
@poetry run mypy -p dream_team_gpt

style: ## Run code style checks.
@echo "🚀 Checking code formatting with isort: Running isort --check --diff ."
@poetry run isort --check --diff .
@echo "🚀 Checking code formatting with black: Running black --check --diff ."
@poetry run black --check --diff .
# @echo "🚀 Static type checking: Running mypy -p dream_team_gpt"
# @poetry run mypy -p dream_team_gpt
@echo "🚀 Static type checking: Running mypy -p dream_team_gpt"
@poetry run mypy -p dream_team_gpt


test: ## Test the code with pytest
@echo "🚀 Testing code: Running pytest"
@poetry run pytest
@#poetry run pytest tests/

verify: ## Run style and tests
check
Expand Down
19 changes: 18 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.11"
tiktoken = "~=0.5.1"
openai = "~=0.28.1"
python-dotenv = "~=1.0.0"
click = "~=8.1.7"
loguru = "~=0.7.2"
openai = "~=0.28.1"
python-dotenv = "~=1.0.0"
pyyaml = "~=6.0.1"
tiktoken = "~=0.5.1"

[tool.poetry.group.dev.dependencies]
black = "*"
pytest = "*"
pytest-cov = "^4.0.0"
isort = "*"
mypy = "^1.5.1"
pre-commit = "^3.4.0"
pytest = "*"
pytest-cov = "^4.0.0"

[tool.poetry.group.docs.dependencies]
mkdocs = "^1.4.2"
Expand Down
47 changes: 25 additions & 22 deletions tests/test_token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,28 @@
},
]

for model in [
"gpt-3.5-turbo-0301",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo",
"gpt-4-0314",
"gpt-4-0613",
"gpt-4",
]:
print(model)
# example token count from the function defined above
print(
f"{num_tokens_from_messages(example_messages, model)} prompt tokens counted by num_tokens_from_messages()."
)
# example token count from the OpenAI API
response = openai.ChatCompletion.create(
model=model,
messages=example_messages,
temperature=0,
max_tokens=1, # we're only counting input tokens here, so let's not waste tokens on the output
)
print(f'{response["usage"]["prompt_tokens"]} prompt tokens counted by the OpenAI API.')
print()

# TODO: update test to work without API key and actually assert something
def test_token_counter():
for model in [
"gpt-3.5-turbo-0301",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo",
"gpt-4-0314",
"gpt-4-0613",
"gpt-4",
]:
print(model)
# example token count from the function defined above
print(
f"{num_tokens_from_messages(example_messages, model)} prompt tokens counted by num_tokens_from_messages()."
)
# example token count from the OpenAI API
response = openai.ChatCompletion.create(
model=model,
messages=example_messages,
temperature=0,
max_tokens=1, # we're only counting input tokens here, so let's not waste tokens on the output
)
print(f'{response["usage"]["prompt_tokens"]} prompt tokens counted by the OpenAI API.')
print()

0 comments on commit 2c09f2a

Please sign in to comment.