Skip to content
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

SmartLLMChain Output Key Customization #14466

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions libs/experimental/langchain_experimental/smart_llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def resolve_prompt_inputs(self) -> Dict[str, Any]:

prompt: BasePromptTemplate
"""Prompt object to use."""
output_key: str = "resolution"
ideation_llm: Optional[BaseLanguageModel] = None
"""LLM to use in ideation step. If None given, 'llm' will be used."""
critique_llm: Optional[BaseLanguageModel] = None
Expand Down Expand Up @@ -132,8 +133,8 @@ def input_keys(self) -> List[str]:
def output_keys(self) -> List[str]:
"""Defines the output keys."""
if self.return_intermediate_steps:
return ["ideas", "critique", "resolution"]
return ["resolution"]
return ["ideas", "critique", self.output_key]
return [self.output_key]

def prep_prompts(
self,
Expand Down Expand Up @@ -169,8 +170,8 @@ def _call(
self.history.critique = critique
resolution = self._resolve(stop, run_manager)
if self.return_intermediate_steps:
return {"ideas": ideas, "critique": critique, "resolution": resolution}
return {"resolution": resolution}
return {"ideas": ideas, "critique": critique, self.output_key: resolution}
return {self.output_key: resolution}

def _get_text_from_llm_result(self, result: LLMResult, step: str) -> str:
"""Between steps, only the LLM result text is passed, not the LLMResult object.
Expand Down