-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
1e77579
commit afc364f
Showing
5 changed files
with
69 additions
and
9 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,34 @@ | ||
import asyncio | ||
import os | ||
import sys | ||
from timeit import default_timer as timer | ||
|
||
from spice.models import o1_mini, o1_preview | ||
|
||
# Modify sys.path to ensure the script can run even when it's not part of the installed library. | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | ||
|
||
from spice import Spice | ||
|
||
|
||
async def run_o1(): | ||
client = Spice() | ||
|
||
messages = client.new_messages().add_user_text("list 5 random words") | ||
|
||
models = [o1_mini, o1_preview] | ||
|
||
for model in models: | ||
print(f"\nRunning {model.name}:") | ||
start = timer() | ||
response = await client.get_response(messages=messages, model=model) | ||
end = timer() | ||
print(response.text) | ||
print(f"input tokens: {response.input_tokens}") | ||
print(f"output tokens: {response.output_tokens}") | ||
print(f"reasoning tokens: {response.reasoning_tokens}") | ||
print(f"total time: {end - start:.2f}s") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(run_o1()) |
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