• Home
  • Explore

Async API for Chain β€” πŸ¦œπŸ”— LangChain 0.0.142

python.langchain.com/en/latest/modules/chains/generic/async_chain.html

1 Users

0 Comments

5 Highlights

0 Notes

Tags

Top Highlights

  • Async API for Chain

  • LangChain provides async support for Chains by leveraging the asyncio library. Async methods are currently supported in LLMChain (through arun, apredict, acall) and LLMMathChain (through arun and acall), ChatVectorDBChain, and QA chains. Async support for other chains is on the roadmap.

  • async def async_generate(chain): resp = await chain.arun(product="toothpaste") print(resp)

  • chain = LLMChain(llm=llm, prompt=prompt) tasks = [async_generate(chain) for _ in range(5)] await asyncio.gather(*tasks)

  • async def generate_concurrently():

Ready to highlight and find good content?

Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.

AboutPrivacyTerms

Β© 2023 Glasp Inc. All rights reserved.