diff --git a/.github/workflows/test-langchain.yml b/.github/workflows/test-langchain.yml index b8f0237c..87e41a23 100644 --- a/.github/workflows/test-langchain.yml +++ b/.github/workflows/test-langchain.yml @@ -42,6 +42,9 @@ jobs: - 4200:4200 - 5432:5432 + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + steps: - name: Acquire sources diff --git a/framework/langchain/pyproject.toml b/framework/langchain/pyproject.toml index b9e54d6b..264cb82c 100644 --- a/framework/langchain/pyproject.toml +++ b/framework/langchain/pyproject.toml @@ -22,6 +22,7 @@ markers = [ # pytest-notebook settings nb_test_files = true nb_coverage = true +nb_exec_allow_errors = true nb_diff_replace = [ # Compensate output of `crash`. '"/cells/*/outputs/*/text" "\(\d.\d+ sec\)" "(0.000 sec)"', diff --git a/framework/langchain/test.py b/framework/langchain/test.py index b6f537e4..39f41de8 100644 --- a/framework/langchain/test.py +++ b/framework/langchain/test.py @@ -46,6 +46,17 @@ def str_list(things): return map(str, things) +@pytest.fixture(scope="session", autouse=True) +def nltk_init(): + """ + Initialize nltk upfront, so that it does not run stray output into Jupyter Notebooks. + """ + download_items = ["averaged_perceptron_tagger", "punkt"] + import nltk + for item in download_items: + nltk.download(item) + + @pytest.fixture(scope="function", autouse=True) def db_init(): """ diff --git a/framework/langchain/vector_search.ipynb b/framework/langchain/vector_search.ipynb index 00921d3f..f4f787b2 100644 --- a/framework/langchain/vector_search.ipynb +++ b/framework/langchain/vector_search.ipynb @@ -239,6 +239,11 @@ }, "pycharm": { "is_executing": true + }, + "nbreg": { + "diff_ignore": [ + "/outputs" + ] } }, "outputs": [], @@ -277,6 +282,11 @@ "ExecuteTime": { "end_time": "2023-09-09T08:05:13.532334Z", "start_time": "2023-09-09T08:05:13.523191Z" + }, + "nbreg": { + "diff_ignore": [ + "/outputs" + ] } }, "outputs": [], @@ -329,6 +339,11 @@ "ExecuteTime": { "end_time": "2023-09-09T08:05:27.478580Z", "start_time": "2023-09-09T08:05:27.470138Z" + }, + "nbreg": { + "diff_ignore": [ + "/outputs" + ] } } }, @@ -371,7 +386,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "nbreg": { + "diff_ignore": [ + "/outputs" + ] + } + }, "outputs": [], "source": [ "store.add_documents([Document(page_content=\"foo\")])" @@ -389,7 +410,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "nbreg": { + "diff_ignore": [ + "/outputs" + ] + } + }, "outputs": [], "source": [ "docs_with_score[0]" @@ -398,7 +425,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "nbreg": { + "diff_ignore": [ + "/outputs" + ] + } + }, "outputs": [], "source": [ "docs_with_score[1]" @@ -417,7 +450,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "nbreg": { + "diff_ignore": [ + "/outputs" + ] + } +}, "outputs": [], "source": [ "db = CrateDBVectorSearch.from_documents(\n", @@ -441,7 +480,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "nbreg": { + "diff_ignore": [ + "/outputs" + ] + } + }, "outputs": [], "source": [ "docs_with_score[0]" @@ -466,7 +511,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "nbreg": { + "diff_ignore": [ + "/outputs" + ] + } + }, "outputs": [], "source": [ "print(retriever)"