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

Closed
wants to merge 10 commits into 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 Oct 3, 2024 11:58pm

@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
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Oct 3, 2024
@efriis
Copy link
Member

efriis commented Oct 3, 2024

Hey there! I can't seem to reproduce the failure on master. Just confirming - does the integration test I added accurately reflect the expected failure on master?

@efriis
Copy link
Member

efriis commented Nov 7, 2024

closing as stale

@efriis efriis closed this Nov 7, 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:S This PR changes 10-29 lines, ignoring generated files.
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants