mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 17:07:25 +00:00
Update openai/create_llm_result function to consider kwargs (#13815)
Replace this entire comment with: - **Description:** updates `create_llm_result` function within `openai.py` to consider latest `params`, - **Issue:** #8928 - **Dependencies:** -, - **Tag maintainer:** - - **Twitter handle:** [burkomr](https://twitter.com/burkomr) <!-- If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17. --> --------- Co-authored-by: Burak Ömür <burakomur@retorio.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
parent
f97ab84c6b
commit
0e462b72ef
@ -467,6 +467,7 @@ class BaseOpenAI(BaseLLM):
|
|||||||
return self.create_llm_result(
|
return self.create_llm_result(
|
||||||
choices,
|
choices,
|
||||||
prompts,
|
prompts,
|
||||||
|
params,
|
||||||
token_usage,
|
token_usage,
|
||||||
system_fingerprint=system_fingerprint,
|
system_fingerprint=system_fingerprint,
|
||||||
)
|
)
|
||||||
@ -524,6 +525,7 @@ class BaseOpenAI(BaseLLM):
|
|||||||
return self.create_llm_result(
|
return self.create_llm_result(
|
||||||
choices,
|
choices,
|
||||||
prompts,
|
prompts,
|
||||||
|
params,
|
||||||
token_usage,
|
token_usage,
|
||||||
system_fingerprint=system_fingerprint,
|
system_fingerprint=system_fingerprint,
|
||||||
)
|
)
|
||||||
@ -555,14 +557,16 @@ class BaseOpenAI(BaseLLM):
|
|||||||
self,
|
self,
|
||||||
choices: Any,
|
choices: Any,
|
||||||
prompts: List[str],
|
prompts: List[str],
|
||||||
|
params: Dict[str, Any],
|
||||||
token_usage: Dict[str, int],
|
token_usage: Dict[str, int],
|
||||||
*,
|
*,
|
||||||
system_fingerprint: Optional[str] = None,
|
system_fingerprint: Optional[str] = None,
|
||||||
) -> LLMResult:
|
) -> LLMResult:
|
||||||
"""Create the LLMResult from the choices and prompts."""
|
"""Create the LLMResult from the choices and prompts."""
|
||||||
generations = []
|
generations = []
|
||||||
|
n = params.get("n", self.n)
|
||||||
for i, _ in enumerate(prompts):
|
for i, _ in enumerate(prompts):
|
||||||
sub_choices = choices[i * self.n : (i + 1) * self.n]
|
sub_choices = choices[i * n : (i + 1) * n]
|
||||||
generations.append(
|
generations.append(
|
||||||
[
|
[
|
||||||
Generation(
|
Generation(
|
||||||
|
Loading…
Reference in New Issue
Block a user