mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-08 06:23:20 +00:00
openai[patch]: add support for extra_body (#23404)
**Description:** Add support passing extra_body parameter Some OpenAI compatible API's have additional parameters (for example [vLLM](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html#extra-parameters)) that can be passed thought `extra_body`. Same question in https://github.com/openai/openai-python/issues/767 <!-- If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17. -->
This commit is contained in:
@@ -137,6 +137,9 @@ class BaseOpenAI(BaseLLM):
|
||||
http_async_client: Union[Any, None] = None
|
||||
"""Optional httpx.AsyncClient. Only used for async invocations. Must specify
|
||||
http_client as well if you'd like a custom client for sync invocations."""
|
||||
extra_body: Optional[Mapping[str, Any]] = None
|
||||
"""Optional additional JSON properties to include in the request parameters when
|
||||
making requests to OpenAI compatible APIs, such as vLLM."""
|
||||
|
||||
class Config:
|
||||
"""Configuration for this pydantic object."""
|
||||
@@ -222,6 +225,9 @@ class BaseOpenAI(BaseLLM):
|
||||
if self.max_tokens is not None:
|
||||
normal_params["max_tokens"] = self.max_tokens
|
||||
|
||||
if self.extra_body is not None:
|
||||
normal_params["extra_body"] = self.extra_body
|
||||
|
||||
# Azure gpt-35-turbo doesn't support best_of
|
||||
# don't specify best_of if it is 1
|
||||
if self.best_of > 1:
|
||||
|
Reference in New Issue
Block a user