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

[Feature]: Support include_usage for bedrock #4407

Open
Manouchehri opened this issue Jun 25, 2024 · 4 comments
Open

[Feature]: Support include_usage for bedrock #4407

Manouchehri opened this issue Jun 25, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@Manouchehri
Copy link
Collaborator

The Feature

It'd be really nice if include_usage worked on providers other than just OpenAI. I think LiteLLM should be able to do this, since we already calculate the cost elsewhere?

Motivation, pitch

It's really useful for users to know how much they've spend in tokens for each streaming request.

Twitter / LinkedIn details

https://www.linkedin.com/in/davidmanouchehri/

@Manouchehri Manouchehri added the enhancement New feature or request label Jun 25, 2024
@krrishdholakia
Copy link
Contributor

this already works @Manouchehri

e.g. response from predibase.

Screenshot 2024-06-27 at 3 48 45 PM

can you share a case where it didn't work? and we can file that as an issue

@Manouchehri
Copy link
Collaborator Author

It's missing from Bedrock.

curl -v "${OPENAI_API_BASE}/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "claude-3-5-sonnet-20240620",
    "max_tokens": 10,
    "seed": 4242,
    "stream": true,
    "temperature": 0.0,
    "messages": [
      {
        "role": "user",
        "content": "Hello"
      }
    ],
    "stream_options": {
      "include_usage": true
    }
  }'
data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":"Hello","role":"assistant"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":"!"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" How"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" can"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" I"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" assist"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" you"}}],"created":1719529524,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" today"}}],"created":1719529525,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":"?"}}],"created":1719529525,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"index":0,"delta":{"content":" Feel"}}],"created":1719529525,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: {"id":"chatcmpl-9569e7af-aaf6-4744-9d8c-0be2bd77f528","choices":[{"finish_reason":"length","index":0,"delta":{}}],"created":1719529525,"model":"anthropic.claude-3-5-sonnet-20240620-v1:0","object":"chat.completion.chunk"}

data: [DONE]

I think it's missing from Azure OpenAI as well, haven't confirmed yet though.

@Manouchehri Manouchehri reopened this Jun 27, 2024
@krrishdholakia krrishdholakia changed the title [Feature]: Support include_usage for all LLM providers? [Feature]: Support include_usage for bedrock Jun 27, 2024
@Manouchehri
Copy link
Collaborator Author

Confirmed, it is also missing/not working for Azure OpenAI requests.

@Manouchehri
Copy link
Collaborator Author

It's missing from Anthropic (directly) too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants