Generative AI and Large Language Models (LLM) are opening up far-reaching possibilities beyond "smart search" and "generating pretty pictures". And this without having to train or fine-tune the models (although that is definitely possible).
Langchain allows you to connect a Large Language Model like GPT4 to your own sources of data like an entire database filled with your own data like customer data or a collection of documents (reports, images) etc. which then becomes visible to the LLM, can search it and provide answers to questions about the data. And langchain allows to perform actions based on the questions and their answers, like agents interacting with external API's.
This project is a prototype Use Case: connect a LLM to a collection of CV's and resource planning & allocation system and it is possible to have the AI, as a response to particular resource request, propose team compositions at a particular date, which would be very handy in the outsourcing industry.
LangChain Explained in 13 Minutes | QuickStart Tutorial for Beginners
Clone the repository. Use the dependency and package manager Poetry to install all the dependencies of vein.
poetry install
Create a text file "dev.env" in the root of the project. This will contain the "OPENAI_API_KEY" environment variable used by the application to obtain the token associated to a valid OpenAI account when calling the API.
OPENAI_API_KEY=sk-A_seCR_et_key_GENERATED_foryou_by_OPENAI
The environment variable is loaded into the execution context of the application when run in the debugger if as such specified in the file "launch.json". An example launch configuration shows how:
{ //example launch configuration
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "app.py",
"console": "integratedTerminal",
"justMyCode": true,
"envFile": "${workspaceFolder}/dev.env"
}
]
}
The OPENAI_API_KEY should be loaded in an Environment Variable before starting jupyter-lab. This can be by setting the OPENAI_API_KEY environment variable before starting the JupyterLab executable. For example, in Powershell on Windows you can create a file "devenv.ps1" with the following content:
$Env:OPENAI_API_KEY="sk-A_seCR_et_key_GENERATED_foryou_by_OPENAI"
. jupyter-lab.exI
And on Mac and Linux you can create a file "devenv.sh" with the following content:
#!/bin/bash
export OPENAI_API_KEY=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
jupyter-lab
Activate the Python virtual environment with
poetry shell
Running the Jupyter environment with the aformentioned scripts. On Linux:
./devenv.sh
and on Windows:
./devenv.ps1
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Copyright © 2023 Iwan van der Kleijn
Licensed under the MIT License MIT