Skip to content

Commit 91617d5

Browse files
ckurzeamotl
authored andcommitted
ML/LangChain: Minor changes and finetuning
1 parent de25062 commit 91617d5

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

topic/machine-learning/llm-langchain/cratedb-vectorstore-rag-openai-sql.ipynb

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,11 @@
3737
"source": [
3838
"## Getting Started\n",
3939
"\n",
40-
"CrateDB supports storing vectors since version 5.5. You can install CrateDB on your own,\n",
41-
"or leverage the fully managed service of [CrateDB Cloud].\n",
40+
"CrateDB supports storing vectors since version 5.5. You can leverage the fully managed service of\n",
41+
"[CrateDB Cloud], or install CrateDB on your own, for example using Docker.\n",
4242
"\n",
43-
"If you want to test with the very latest developments, you can run CrateDB instance based\n",
44-
"on Docker:\n",
45-
"\n",
46-
"```\n",
47-
"docker run --publish 4200:4200 --publish 5432:5432 --pull=always crate/crate:5.5 -Cdiscovery.type=single-node\n",
43+
"```shell\n",
44+
"docker run --publish 4200:4200 --publish 5432:5432 --pull=always crate:latest -Cdiscovery.type=single-node\n",
4845
"```\n",
4946
"\n",
5047
"[CrateDB Cloud]: https://console.cratedb.cloud/"
@@ -370,7 +367,7 @@
370367
" for record in results:\n",
371368
" documents.append(record[0])\n",
372369
" \n",
373-
"print(len(documents))"
370+
"print(documents)"
374371
]
375372
},
376373
{
@@ -405,8 +402,12 @@
405402
}
406403
],
407404
"source": [
405+
"from openai import OpenAI\n",
406+
"\n",
407+
"# Concatenate the found documents into the context that will be provided in the system prompt\n",
408408
"context = '---\\n'.join(doc for doc in documents)\n",
409409
"\n",
410+
"# Give instructions and context in the system prompt\n",
410411
"system_prompt = f\"\"\"\n",
411412
"You are a time series expert and get questions from the user covering the area of time series databases and time series use cases. \n",
412413
"Please answer the users question in the language it was asked in. \n",
@@ -415,12 +416,7 @@
415416
"Context: \n",
416417
"{context}\"\"\"\n",
417418
"\n",
418-
"#openai.api_key = os.environ['OPENAI_API_KEY']\n",
419-
"\n",
420-
"\n",
421-
"client = OpenAI(\n",
422-
" api_key=os.environ['OPENAI_API_KEY']\n",
423-
")\n",
419+
"client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])\n",
424420
"\n",
425421
"chat_completion = client.chat.completions.create(\n",
426422
" model=\"gpt-3.5-turbo\", \n",
@@ -430,9 +426,6 @@
430426
" ]\n",
431427
")\n",
432428
"\n",
433-
"#chat_completion = openai.ChatCompletion.create(model=\"gpt-3.5-turbo\", \n",
434-
"# messages=[{\"role\": \"system\", \"content\": system_prompt},\n",
435-
"# {\"role\": \"user\", \"content\": my_question}])\n",
436429
"chat_completion.choices[0].message.content"
437430
]
438431
}

topic/machine-learning/llm-langchain/readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ and [CrateDB].
5757

5858
- `cratedb-vectorstore-rag-openai-sql.ipynb` [![Open on GitHub](https://img.shields.io/badge/Open%20on-GitHub-lightgray?logo=GitHub)](conversational_memory.ipynb) [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/crate/cratedb-examples/main?labpath=topic%2Fmachine-learning%2Fllm-langchain%2Fcratedb-vectorstore-rag-openai-sql.ipynb) [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/crate/cratedb-examples/blob/main/topic/machine-learning/llm-langchain/cratedb-vectorstore-rag-openai-sql.ipynb)
5959

60-
This example intentially shows how to use the CrateDB Vector Store using SQL. There might be cases where the default parameters of the LangChain integration are not sufficient or you need to crate more advanced SQL queries.
60+
This example intentionally shows how to use the CrateDB Vector Store using SQL.
61+
There might be cases where the default parameters of the LangChain integration
62+
are not sufficient, or you need to use more advanced SQL queries.
6163

62-
The example still uses LangChain components to split a PDF file into chunks, leverage OpenAI to calculate embeddings and to execute the request towards an LLM.
64+
The example still uses LangChain components to split a PDF file into chunks,
65+
leverages OpenAI to calculate embeddings, and to execute the request towards an LLM.
6366

6467
- Accompanied to the Jupyter Notebook files, there are also basic variants of
6568
corresponding examples, [vector_search.py](vector_search.py),

0 commit comments

Comments
 (0)