Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider including timestamps in Turns #337

Open
simonpcouch opened this issue Feb 25, 2025 · 1 comment · May be fixed by #343
Open

consider including timestamps in Turns #337

simonpcouch opened this issue Feb 25, 2025 · 1 comment · May be fixed by #343

Comments

@simonpcouch
Copy link
Contributor

I'd find it super useful to have timestamps when user and assistant turns completed embedded in Chat/Turn objects. One use case beyond my own that this would make straightforward is calculating tokens/sec. I'd like to use this for an R port of a Python LLM eval framework, rinspect.

Inspect implements this by recording the time right before a request is made and then another right after it completes, logging the former as the time when the user turn completed and the latter as the time that the assistant turn completed. I've hacked together a similar implementation while testing and it's served my purposes so far, though I haven't verified that timestamps of tool calls are handled reasonably.

I'd rather not implement this in rinspect itself as I'd like for users to be able to supply arbitrary functions wrapping ellmer Chats that define their "solver." With timestamping implemented, rinspect can just derive all of the information it needs from a Chat. Without it, users would have to do their own timestamping inside of those functions. e.g.:

# without built-in timestamping
solver <- function(x, chat) {
  # do some stuff...

  time_start <- Sys.time()
  result <- chat$chat(x)
  time_completed <- Sys.time()
 
  # do some stuff...

  # one timestamp per Turn
  list(result = result, chat = chat, timestamps = list(time_start, time_completed))
}

# with built-in timestamping
solver <- function(x, chat) {
  # do some stuff...

  result <- chat$chat(x)

  # do some stuff...
 
  list(result = result, chat = chat)
}
@hadley
Copy link
Member

hadley commented Feb 25, 2025

Sounds reasonable to me. Do you want to do a PR?

@simonpcouch simonpcouch linked a pull request Feb 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants