Example node of distributed AI links (Node AI).
Refer simple-ai-chat.
GoLang https://go.dev/doc/
LangChain https://python.langchain.com/docs/
-
Text query
Query fordata.txt
file. -
Database query
LangChain will generate SQL query from text and magically query the data. -
Plugin query
Query as same as ChatGPT plugins.
Refer: https://python.langchain.com/docs/integrations/tools/chatgpt_plugins
Install python dependencies.
pip install -r requirements.txt
Sometimes need to update the packages:
pip install --upgrade openai
pip install --upgrade langchain
pip install --upgrade -r requirements.txt
Tested with Golang 1.21 and Python 3.11.2
-
Docker
docker compose up --build -d
-
Manually
go run serve.go
-
Serve with PM2
pm2 start go --name simple-ai-node --interpreter none -- run serve.go
GET /generate?input=input_text
{
"result": "Sample response text."
}
Or
{
"result": {
"text": "Sample response text.",
"image": "some_imeage_url",
}
}
- text
Simple text query base on langchain.
If use query enginetext
, Createdata.txt
to include the data.
- Supported Data Sources
Data Type | Engine | Supported |
---|---|---|
Text (.txt) | text | Yes |
Relational database | db | Yes |
Plugin (.well-known/ai-plugin.js) | plugin | Yes |
PDF (.pdf) | No | |
Amazon Textract PDF OCR (.pdf, .jpeg) | ocr | No |
EPUB (.epub) | epub | No |
CSV (.csv) | csv | No |
Unstructured | ust | No |
Web browsing | url | No |
Image (.jpg, .png, etc.) | img | No |
Whisper audio (.wav, .mp3, etc.) | audio | No |
PORT
The port of the go server.
PYTHON_PATH
Specify the python executable path.
Get from which python
.
NODE
The node name.
ID
The node ID, use a number, usual I use unix time.
OPENAI_API_KEY
Get from OpenAI
MODEL_NAME
TEMPERATURE
Refer OpenAI API document.
QUERY_ENGINE
Engine name refer "Supported Data Sources".
CUSTOM_DATA_ONLY
Custom data only for text query.
Outside the custom data AI will say "I don't know"
DEBUG
To debug the Python code from the API response.
USE_VERBOSE
The LangChain response verbose details.
MYSQL_DB_USERNAME
MYSQL_DB_PASSWORD
MYSQL_DB_HOST
MYSQL_DB_PORT
MYSQL_DB_DATABASE
For relational database node.
DB connection settings.
PLUGIN_URL
For plugin node.
.well-known/ai-plugin.json file URL.
Refer OpenAI plagin document.