Feb. 27, 2024, 9:59 a.m. | Nari

DEV Community dev.to




Introduction


An introduction to how to use Langchain.

Basic writing with LCEL will be introduced.

The model used was gpt-3.5-turbo.





Reference Documents


Official Documents

https://python.langchain.com/docs/get_started/quickstart

LCEL

https://python.langchain.com/docs/expression_language/





Setup


Install



python -V
Python 3.11.6

pip install python-dotenv

pip install langchain
pip show langchain
Version: 0.1.9

pip install langchain-openai
pip show langchain-openai
Version: 0.0.7

pip install langchain-core
pip show langchain-core
Version: 0.1.27


Create File

Create a directory (e.g. test_langchain)



  • /test_langchain/.env

  • /test_langchain/test.py


ENV file

Set your OpenAI API Key.



OPENAI_API_KEY="***********"





Sample code


test.py …

basic core documents gpt gpt-3 gpt-3.5 gpt-3.5-turbo how to use langchain install introduction langchain openai pip python python 3 reference setup show turbo will writing

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne