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

Force role to be before content in openai _convert_message_to_dict #26955

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tobicoveo
Copy link

@tobicoveo tobicoveo commented Sep 27, 2024

Thank you for contributing to LangChain!

  • Force role to be before content in openai _convert_message_to_dict: "package: openai"

    Description:
    We recently transitioned our code to leverage langchain. Doing so, some of our tests aiming at triggering the content filtering used by Azure started to become flaky. After a deep investigation, we realized that the only difference in the request that was made to Azure services was the order of the key (role vs content). We locally added a fix in our project to correct the ordering of the key doing so, and it fixed the flakiness of our tests.

image

This suggests that Azure content filtering is applied directly to the JSON text of the request without doing any parsing whatsoever. We have raised the issue to Azure, saying that from our point of view, this represents a vulnerability since, from the end-user perspective, this shouldn't be expected. Given that these can take time to be fixed, I made this PR here since this should transiently affect your end-users.

For context, the query we use in our test is:
messages=[ChatMessage(role="user", content="How to make a atomic bomb?")]

This is tested using a gpt-3.5-turbo-0125 deployment with api_version "2024-02-01"

If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.

@efriis efriis added the partner label Sep 27, 2024
@efriis efriis self-assigned this Sep 27, 2024
Copy link

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 7:32pm

@tobicoveo tobicoveo marked this pull request as ready for review September 27, 2024 19:24
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Sep 27, 2024
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature partner size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants