-
Notifications
You must be signed in to change notification settings - Fork 16k
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
Moderation: migrate to new openai api #14317
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we try to do this in a way that is compatible with all versions of openai? see https://github.com/langchain-ai/langchain/pull/14222/files for inspiration
Should be compatible with v0 and v1, but reviews are appreciated. |
@hwchase17 is it mergeable ? |
We also need this fix urgently? Can this be merged? cc: @vaibhavbhuva |
CheeseDurger, thanks for suggesting this fix for 13685. I also wanted to comment to share I am eagerly awaiting a solution as well. Thanks all for coding & reviewing efforts! |
CC @efriis, @eyurtsev, @nfcampos I see all of you have also successfully committed changes to this file and are associated with https://github.com/langchain-ai. Could you help @CheeseDurger with a review, more suggestions, or if appropriate, successfully merge this fix to continue to support OpenAI Moderation functionality? |
import openai | ||
if is_openai_v1(): | ||
import openai | ||
from openai import moderations as moderation | ||
from openai.types import ModerationCreateResponse, Moderation | ||
from openai.resources.moderations import Moderations | ||
else: | ||
from openai import Moderation as Moderations | ||
moderation = Moderations() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately we can't do imports like this in langchain because of optional dependencies.
If you want to add this to the libs/partners/openai
langchain_openai package, then you can rely on the v1 client there!
closing in favor of #17025 |
Fixes issue #13685 : OpenAIModerationChain still uses the old OpenAI API.
Description
The following snippet:
Gives the following error :