-
Notifications
You must be signed in to change notification settings - Fork 3
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
Would openai-responses-python
work with langchain_openai?
#58
Comments
Not a silly question.
Here is a working example using this library to test from langchain_openai import ChatOpenAI
from pydantic.v1 import SecretStr
import openai_responses
from openai_responses import OpenAIMock
@openai_responses.mock()
def test_langchain_chat_openai_invoke(openai_mock: OpenAIMock):
openai_mock.chat.completions.create.response = {
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"content": "J'adore la programmation.",
"role": "assistant",
},
}
]
}
llm = ChatOpenAI(
name="My Custom Chatbot",
model="gpt-4o",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
api_key=SecretStr("sk-fake123"),
)
messages = [
(
"system",
"You are a helpful assistant that translates English to French. Translate the user sentence.",
),
("human", "I love programming."),
]
ai_msg = llm.invoke(messages)
assert ai_msg.content == "J'adore la programmation." # type: ignore I'll add this to the |
Cool, thanks very much. |
* chore(examples): add langchain-openai example from #58 * chore(types): add `refusal` to choice * chore(deps): add langchain-openai as dev dep for testing * chore(docs): remove not about support for older SDK versions * chore(routes): move beta routes to separate dir * chore(types): add structured output type additions * feat(routes): add beta parsed chat route * feat(examples): add parsed chat completion examples
Hello.
Maybe it's a silly question but I had a hard time trying pytest with langchain_openai. Can your lib work with langchain_openai with some tweaking? Thanks.
I ran a quick test.
I tried this (replacing openai with langchain_openai), but got
when running
test_create_assistant()
, probably for an obvious reason.The text was updated successfully, but these errors were encountered: