langchain/libs/experimental/langchain_experimental
Qihui Xie 57ade13b2b
fix llm_inputs duplication problem in intermediate_steps in SQLDatabaseChain (#10279)
Use `.copy()` to fix the bug that the first `llm_inputs` element is
overwritten by the second `llm_inputs` element in `intermediate_steps`.

***Problem description:***
In [line 127](

c732d8fffd/libs/experimental/langchain_experimental/sql/base.py (L127C17-L127C17)),
the `llm_inputs` of the sql generation step is appended as the first
element of `intermediate_steps`:
```
            intermediate_steps.append(llm_inputs)  # input: sql generation
```

However, `llm_inputs` is a mutable dict, it is updated in [line
179](https://github.com/langchain-ai/langchain/blob/master/libs/experimental/langchain_experimental/sql/base.py#L179)
for the final answer step:
```
                llm_inputs["input"] = input_text
```
Then, the updated `llm_inputs` is appended as another element of
`intermediate_steps` in [line
180](c732d8fffd/libs/experimental/langchain_experimental/sql/base.py (L180)):
```
                intermediate_steps.append(llm_inputs)  # input: final answer
```

As a result, the final `intermediate_steps` returned in [line
189](c732d8fffd/libs/experimental/langchain_experimental/sql/base.py (L189C43-L189C43))
actually contains two same `llm_inputs` elements, i.e., the `llm_inputs`
for the sql generation step overwritten by the one for final answer step
by mistake. Users are not able to get the actual `llm_inputs` for the
sql generation step from `intermediate_steps`

Simply calling `.copy()` when appending `llm_inputs` to
`intermediate_steps` can solve this problem.
2023-10-05 21:32:08 -07:00
..
autonomous_agents Harrison/move vectorstore base (#11030) 2023-09-25 12:44:23 -07:00
comprehend_moderation Make a copy of external data instead of mutating another object's attributes. (#11349) 2023-10-03 15:27:51 -04:00
cpal rename repo namespace to langchain-ai (#11259) 2023-10-01 15:30:58 -04:00
data_anonymizer Instance anonymization (#10501) 2023-10-05 11:23:02 -07:00
fallacy_removal adding new chain for logical fallacy removal from model output in chain (#9887) 2023-09-03 15:44:27 -07:00
generative_agents Use a submodule for pydantic v1 compat (#9371) 2023-08-17 16:35:49 +01:00
graph_transformers Diffbot Graph Transformer / Neo4j Graph document ingestion (#9979) 2023-09-06 13:32:59 -07:00
llm_bash add LLMBashChain to experimental (#11305) 2023-10-02 16:00:14 -04:00
llm_symbolic_math Add SymbolicMathChain to experiment in preparation for deprecation (#11129) 2023-10-05 13:54:43 -04:00
llms Use a submodule for pydantic v1 compat (#9371) 2023-08-17 16:35:49 +01:00
pal_chain rename repo namespace to langchain-ai (#11259) 2023-10-01 15:30:58 -04:00
plan_and_execute Use a submodule for pydantic v1 compat (#9371) 2023-08-17 16:35:49 +01:00
prompt_injection_identifier HF Injection Identifier Refactor 2023-09-11 14:44:51 -07:00
prompts rename repo namespace to langchain-ai (#11259) 2023-10-01 15:30:58 -04:00
pydantic_v1 poetry lock the experimental package. (#9478) 2023-08-22 14:09:35 -04:00
retrievers Resolve: VectorSearch enabled SQLChain? (#10177) 2023-09-06 17:08:12 -07:00
rl_chain Revise vowpal_wabbit notebook 2023-10-05 18:18:19 -07:00
smart_llm Fixed some grammatical and spelling errors (#10595) 2023-09-14 17:43:36 -07:00
sql fix llm_inputs duplication problem in intermediate_steps in SQLDatabaseChain (#10279) 2023-10-05 21:32:08 -07:00
synthetic_data fix experimental imports (#10875) 2023-09-20 23:44:17 -07:00
tabular_synthetic_data Synthetic Data generation (#9472) 2023-09-28 18:16:05 -07:00
tot Corrected some spelling mistakes and grammatical errors (#10791) 2023-09-19 10:08:59 -07:00
__init__.py Use a submodule for pydantic v1 compat (#9371) 2023-08-17 16:35:49 +01:00
py.typed Add py.typed file to langchain-experimental. (#9557) 2023-08-21 15:37:16 -04:00