Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenAI connector] Fix OpenAI node package url (elastic#180955)
## Summary Fixes a bug with OpenAI (not azure) connectors when used with `invokeAsyncIterator`: ``` ActionsClientChatOpenAI: an error occurred while running the action - Unexpected API Error: - 404 Invalid URL (POST /v1/chat/completions/chat/completions) ``` Our current default url for OpenAI connectors is `https://api.openai.com/v1/chat/completions` When using the `invokeAsyncIterator` subaction, we use the OpenAI node package. This takes the url as an argument to instatiate. It wants the URL of OpenAI, not the completions endpoint which is our default. Looking back, I wish we had made the default url `https://api.openai.com/v1`. However, because we want to support existing connectors I think we should keep this the default and remove the endpoint from the url when it is passed to the OpenAI node package. ### To test Send a message in Security Assistant with an OpenAI (not azure) connector with streaming enabled. Observe a successful response. ### Note to docs team @elastic/security-docs We should call this out. If a user has an open source OpenAI connector with a chat completions endpoint that does not have the same structure as OpenAI's ending in `/chat/completions`, their full endpoint url will be used with LangChain OpenAI Streaming implementations. For example, if a user had a url like `https://mycustomllm.com/execute/completions` and tries to use the the Security Assistant with Knowledge Base on and Streaming on, they may get this error: ``` ActionsClientChatOpenAI: an error occurred while running the action - Unexpected API Error: - 404 Invalid URL (POST /execute/completions/chat/completions) ``` We should instruct them to follow the same route structure as OpenAI. Their endpoint needs to end in `/chat/completions`
- Loading branch information