Skip to content

Commit

Permalink
token counting in run
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttestbot[bot] committed Aug 28, 2024
1 parent 9877f21 commit 2f416bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

async def basic_example():
client = Spice()
model = "gpt-4o"

messages = client.new_messages()
messages.add_system_text("You are a helpful assistant.")
messages.add_user_text("list 5 random words")

response = await client.get_response(messages=messages, model="gpt-4o")
tokens = client.count_prompt_tokens(messages, model=model)
print(f"Prompt tokens: {tokens}")

response = await client.get_response(messages=messages, model=model)
print(response.text)


Expand Down

0 comments on commit 2f416bb

Please sign in to comment.