langchain/libs/experimental/langchain_experimental
Anish Nag 6da0cfea0e
experimental[patch]: SmartLLMChain Output Key Customization (#14466)
**Description**
The `SmartLLMChain` was was fixed to output key "resolution".
Unfortunately, this prevents the ability to use multiple `SmartLLMChain`
in a `SequentialChain` because of colliding output keys. This change
simply gives the option the customize the output key to allow for
sequential chaining. The default behavior is the same as the current
behavior.

Now, it's possible to do the following:
```
from langchain.chat_models import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain_experimental.smart_llm import SmartLLMChain
from langchain.chains import SequentialChain

joke_prompt = PromptTemplate(
    input_variables=["content"],
    template="Tell me a joke about {content}.",
)
review_prompt = PromptTemplate(
    input_variables=["scale", "joke"],
    template="Rate the following joke from 1 to {scale}: {joke}"
)

llm = ChatOpenAI(temperature=0.9, model_name="gpt-4-32k")
joke_chain = SmartLLMChain(llm=llm, prompt=joke_prompt, output_key="joke")
review_chain = SmartLLMChain(llm=llm, prompt=review_prompt, output_key="review")

chain = SequentialChain(
    chains=[joke_chain, review_chain],
    input_variables=["content", "scale"],
    output_variables=["review"],
    verbose=True
)
response = chain.run({"content": "chickens", "scale": "10"})
print(response)
```

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
2023-12-08 13:55:51 -08:00
..
agents Fix #11737 issue (extra_tools option of create_pandas_dataframe_agent is not working) (#13203) 2023-12-04 20:54:08 -08:00
autonomous_agents core[minor], langchain[patch], experimental[patch]: Added missing py.typed to langchain_core (#14143) 2023-12-01 19:15:23 -08:00
chat_models core[minor], langchain[patch], experimental[patch]: Added missing py.typed to langchain_core (#14143) 2023-12-01 19:15:23 -08:00
comprehend_moderation core[minor], langchain[patch], experimental[patch]: Added missing py.typed to langchain_core (#14143) 2023-12-01 19:15:23 -08:00
cpal Add CI check that integration tests compile (#12090) 2023-10-21 10:52:18 -04:00
data_anonymizer core[patch], langchain[patch], experimental[patch]: import CI (#14414) 2023-12-08 11:28:55 -08: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 Upgrade experimental package dependencies and use Poetry 1.6.1. (#11339) 2023-10-16 21:13:31 -04:00
llm_symbolic_math Add SymbolicMathChain to experiment in preparation for deprecation (#11129) 2023-10-05 13:54:43 -04:00
llms core[minor], langchain[patch], experimental[patch]: Added missing py.typed to langchain_core (#14143) 2023-12-01 19:15:23 -08:00
open_clip Multi-modal RAG template (#14186) 2023-12-05 13:36:38 -08:00
openai_assistant Move OAI assistants to langchain and add callbacks (#13236) 2023-11-13 17:42:07 -08:00
pal_chain Upgrade experimental package dependencies and use Poetry 1.6.1. (#11339) 2023-10-16 21:13:31 -04:00
plan_and_execute Use a submodule for pydantic v1 compat (#9371) 2023-08-17 16:35:49 +01:00
prompt_injection_identifier experimental[patch] Update prompt injection model (#13930) 2023-11-27 17:56:53 -05:00
prompts experimental[patch]: fixed namespace bug (#13585) 2023-11-28 16:40:27 -08:00
pydantic_v1 poetry lock the experimental package. (#9478) 2023-08-22 14:09:35 -04:00
retrievers add missing init files (#12114) 2023-10-21 10:25:50 -07:00
rl_chain Revise vowpal_wabbit notebook 2023-10-05 18:18:19 -07:00
smart_llm experimental[patch]: SmartLLMChain Output Key Customization (#14466) 2023-12-08 13:55:51 -08:00
sql langchain[patch]: Running SQLDatabaseChain adds prefix "SQLQuery:\n" (#14058) 2023-12-01 19:26:16 -08:00
synthetic_data fix experimental imports (#10875) 2023-09-20 23:44:17 -07:00
tabular_synthetic_data Install and use ruff format instead of black for code formatting. (#12585) 2023-10-31 10:53:12 -04:00
tools Clean up deprecated agents and update __init__ in experimental (#12231) 2023-10-27 13:52:50 -04:00
tot core[patch], langchain[patch]: fix required deps (#14373) 2023-12-07 14:24:58 -08:00
utilities Clean up deprecated agents and update __init__ in experimental (#12231) 2023-10-27 13:52:50 -04:00
__init__.py Add version to langchain_experimental (#11613) 2023-10-10 11:17:41 -04:00
py.typed Add py.typed file to langchain-experimental. (#9557) 2023-08-21 15:37:16 -04:00