-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
45 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DEFAULT_MODEL = "gpt-4o-2024-08-06" | ||
DEFAULT_MODEL_MINI = "gpt-4o-mini" |
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
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,34 @@ | ||
import pytest | ||
from openai.types.beta.threads.runs.run_step import Usage | ||
|
||
from agency_swarm.util.tracking import SQLiteTracker | ||
|
||
|
||
@pytest.fixture | ||
def sqlite_tracker(): | ||
tracker = SQLiteTracker(":memory:") | ||
yield tracker | ||
|
||
|
||
def test_sqlite_track_and_get_total_tokens(sqlite_tracker): | ||
usage = Usage(prompt_tokens=10, completion_tokens=5, total_tokens=15) | ||
sqlite_tracker.track_usage( | ||
usage, "test_assistant", "test_thread", "gpt-4o", "sender", "recipient" | ||
) | ||
totals = sqlite_tracker.get_total_tokens() | ||
assert totals == usage | ||
|
||
|
||
def test_sqlite_multiple_entries(sqlite_tracker): | ||
# Insert multiple usage entries | ||
usages = [ | ||
Usage(prompt_tokens=10, completion_tokens=5, total_tokens=15), | ||
Usage(prompt_tokens=20, completion_tokens=10, total_tokens=30), | ||
] | ||
for u in usages: | ||
sqlite_tracker.track_usage( | ||
u, "assistant", "thread", "gpt-4o", "sender", "recipient" | ||
) | ||
|
||
totals = sqlite_tracker.get_total_tokens() | ||
assert totals == Usage(prompt_tokens=30, completion_tokens=15, total_tokens=45) |