langchain/libs/experimental/langchain_experimental
UmerHA 8aab39e3ce
Added SmartGPT workflow (issue #4463) (#4816)
# Added SmartGPT workflow by providing SmartLLM wrapper around LLMs
Edit:
As @hwchase17 suggested, this should be a chain, not an LLM. I have
adapted the PR.

It is used like this:
```
from langchain.prompts import PromptTemplate
from langchain.chains import SmartLLMChain
from langchain.chat_models import ChatOpenAI

hard_question = "I have a 12 liter jug and a 6 liter jug. I want to measure 6 liters. How do I do it?"
hard_question_prompt = PromptTemplate.from_template(hard_question)

llm = ChatOpenAI(model_name="gpt-4")
prompt = PromptTemplate.from_template(hard_question)
chain = SmartLLMChain(llm=llm, prompt=prompt, verbose=True)

chain.run({})
```


Original text: 
Added SmartLLM wrapper around LLMs to allow for SmartGPT workflow (as in
https://youtu.be/wVzuvf9D9BU). SmartLLM can be used wherever LLM can be
used. E.g:

```
smart_llm = SmartLLM(llm=OpenAI())
smart_llm("What would be a good company name for a company that makes colorful socks?")
```
or
```
smart_llm = SmartLLM(llm=OpenAI())
prompt = PromptTemplate(
    input_variables=["product"],
    template="What is a good name for a company that makes {product}?",
)
chain = LLMChain(llm=smart_llm, prompt=prompt)
chain.run("colorful socks")
```

SmartGPT consists of 3 steps:

1. Ideate - generate n possible solutions ("ideas") to user prompt
2. Critique - find flaws in every idea & select best one
3. Resolve - improve upon best idea & return it

Fixes #4463

## Who can review?

Community members can review the PR once tests pass. Tag
maintainers/contributors who might be interested:

- @hwchase17
- @agola11

Twitter: [@UmerHAdil](https://twitter.com/@UmerHAdil) | Discord:
RicChilligerDude#7589

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-08-11 15:44:27 -07:00
..
autonomous_agents Fix issue 7445 (#7635) 2023-08-10 16:29:31 -07:00
cpal docstrings experimental (#7969) 2023-07-24 14:21:48 -07:00
generative_agents update experimental (#8402) 2023-07-28 13:01:36 -07:00
llms add anthropic functions wrapper (#8475) 2023-07-30 07:23:46 -07:00
pal_chain remove code (#8425) 2023-07-28 13:19:44 -07:00
plan_and_execute update experimental (#8402) 2023-07-28 13:01:36 -07:00
prompts Harrison/official pre release (#8106) 2023-07-21 18:44:32 -07:00
smart_llm Added SmartGPT workflow (issue #4463) (#4816) 2023-08-11 15:44:27 -07:00
sql cr 2023-07-27 22:00:52 -07:00
tot Tree of Thought introducing a new ToTChain. (#5167) 2023-07-26 21:29:39 -07:00
__init__.py bump versions (#8129) 2023-07-22 08:46:37 -07:00