-
Notifications
You must be signed in to change notification settings - Fork 372
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
bug: AzureChatOpenAI model name not recorded correctly #2029
Comments
thanks for reporting this, are the token counts correct in Langfuse? What model name gets recorded? |
I think you are on the right track! |
there are two model names available usually
Usually the response name is more specific as the request does not need to include the model version. Here the opposite seems to be the case. we'll need to have a look and add some tests to CI |
Yes, token counts are the same. |
perfect, thanks for confirming |
Note how the request says "model": "gpt-3.5-turbo" even though I use gpt-4 in this example. Azure knows which model to use because I created a deployment in azure and associated it with "gpt4-1106-preview". When using azure you have to create a named deployment and assign a model to it. When calling their API, the URL holds the deployment name. You could hope to parse the model name from the URL which would make it easy for the user. In case the deployment name has a weird name without the model name in it you would need the user to provide a dict in which he maps the deployment name to a model name I guess. Ideally you check how langchain does it in get_openai_callback(). Azure API call example: {
"body": null,
"code": null,
"type": null,
"param": null,
"message": "Connection error.",
"request": {
"url": {
"_uri_reference": [
"https",
"",
"xyz.openai.azure.com",
null,
"/openai/deployments/gpt4-1106-preview/chat/completions",
"api-version=2023-05-15",
null
]
},
"method": "POST",
"stream": {
"_stream": {
"messages": [
{
"content": "...",
"role": "user"
}
],
"model": "gpt-3.5-turbo",
"n": 1,
"stream": false,
"temperature": 1
}
},
"headers": {},
"_content": {
"messages": [
{
"content": "...",
"role": "user"
}
],
"model": "gpt-3.5-turbo",
"n": 1,
"stream": false,
"temperature": 1
},
"extensions": {
"timeout": {
"pool": null,
"read": null,
"write": null,
"connect": null
}
}
}
}
|
Same for me, using gpt-4-32k 0613 from Azureopenai but langfuse reporting gpt-3.5-turbo on dashboard. |
are you on the latest sdk version? |
Describe the bug
The 'Total Cost' in langfuse shows a lower value than langchains get_openai_callback() returns.
Tested with Azure's GPT API. Not sure if it's the same with OpenAI's API.
langchains get_openai_callback(): Total Cost (USD): $0.0010149999999999998
langfuse UI: Total Cost: $0.0008
This discrepancy becomes more obvious with complex chains.
I have already seen differences of up to 3 x.
To reproduce
Requirements:
langfuse.version is 2.27.0
Python Version: 3.11.9 | packaged by Anaconda, Inc. | (main, Apr 19 2024, 16:40:41) [MSC v.1916 64 bit (AMD64)]
Package Information
Code to reproduce:
SDK and container versions
No response
Additional information
No response
Are you interested to contribute a fix for this bug?
Yes
The text was updated successfully, but these errors were encountered: