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

Gathering usage statistics #281

Closed
telepenin opened this issue Sep 6, 2023 · 6 comments
Closed

Gathering usage statistics #281

telepenin opened this issue Sep 6, 2023 · 6 comments

Comments

@telepenin
Copy link
Contributor

Hi,
I've enabled pr-agent (gerrit git provider) for bunch of repositories and I would like to gather some statistics.
Fields might be interesting for me: project, pull request id, action point (/review, /describe, etc.), prompts, result, tokens in, tokens out, costs.

Separately I ran my small project for review + generating improving where I'm using google sphreadsheets (via gspread) directly to store analytics info. Seems it's pretty nice to review how the project work for many multiples projects.

One more thing, pr-agent uses openai library directly, as I understand it does not provide counting tokens in, tokens out, costs for further analyse on the openai requests, but langchain does. It might be interesting as well.

@krrishdholakia
Copy link
Contributor

Hey @telepenin,

the response object for all queries follows the openai object format which contains the tokens used for prompt and completion

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-3.5-turbo-0613",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "\n\nHello there, how may I assist you today?",
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

Since pr-agent also uses litellm - you can also use that count cost per token and cost of the completion query.

I'm happy to make a PR to integrate these, if you can explain how you'd like to call / use these

@Codium-ai Codium-ai deleted a comment from mrT23 Sep 12, 2023
@okotek
Copy link
Contributor

okotek commented Sep 12, 2023

/similar_issue

@Codium-ai Codium-ai deleted a comment from github-actions bot Sep 12, 2023
@okotek
Copy link
Contributor

okotek commented Sep 12, 2023

/similar_issue

@Codium-ai Codium-ai deleted a comment from github-actions bot Sep 12, 2023
@mrT23
Copy link
Collaborator

mrT23 commented Oct 3, 2023

i am closing the issue

if still relevant, please re-open

@mrT23 mrT23 closed this as completed Oct 3, 2023
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

No branches or pull requests

4 participants