Docs: Updated callbacks/index.mdx (#16404)

The callbacks get started demo code was updated , replacing the
chain.run() command ( which is now depricated) ,with the updated
chain.invoke() command.
Solving the following issue : #16379
Twitter/X : @Hazxhx
This commit is contained in:
Sarthak Chaure 2024-01-23 02:40:19 +05:30 committed by GitHub
parent 873de14cd8
commit dd5b8107b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,15 +95,16 @@ prompt = PromptTemplate.from_template("1 + {number} = ")
# Constructor callback: First, let's explicitly set the StdOutCallbackHandler when initializing our chain
chain = LLMChain(llm=llm, prompt=prompt, callbacks=[handler])
chain.run(number=2)
chain.invoke({"number":2})
# Use verbose flag: Then, let's use the `verbose` flag to achieve the same result
chain = LLMChain(llm=llm, prompt=prompt, verbose=True)
chain.run(number=2)
chain.invoke({"number":2})
# Request callbacks: Finally, let's use the request `callbacks` to achieve the same result
chain = LLMChain(llm=llm, prompt=prompt)
chain.run(number=2, callbacks=[handler])
chain.invoke({"number":2}, {"callbacks":[handler]})
```
<CodeOutputBlock lang="python">
@ -128,9 +129,6 @@ chain.run(number=2, callbacks=[handler])
1 + 2 =
> Finished chain.
'\n\n3'
```
</CodeOutputBlock>