Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-langchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- 4200:4200
- 5432:5432

env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

steps:

- name: Acquire sources
Expand Down
1 change: 1 addition & 0 deletions framework/langchain/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"',
Expand Down
11 changes: 11 additions & 0 deletions framework/langchain/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down
63 changes: 57 additions & 6 deletions framework/langchain/vector_search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@
},
"pycharm": {
"is_executing": true
},
"nbreg": {
"diff_ignore": [
"/outputs"
]
}
},
"outputs": [],
Expand Down Expand Up @@ -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": [],
Expand Down Expand Up @@ -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"
]
}
}
},
Expand Down Expand Up @@ -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\")])"
Expand All @@ -389,7 +410,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"nbreg": {
"diff_ignore": [
"/outputs"
]
}
},
"outputs": [],
"source": [
"docs_with_score[0]"
Expand All @@ -398,7 +425,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"nbreg": {
"diff_ignore": [
"/outputs"
]
}
},
"outputs": [],
"source": [
"docs_with_score[1]"
Expand All @@ -417,7 +450,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"nbreg": {
"diff_ignore": [
"/outputs"
]
}
},
"outputs": [],
"source": [
"db = CrateDBVectorSearch.from_documents(\n",
Expand All @@ -441,7 +480,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"nbreg": {
"diff_ignore": [
"/outputs"
]
}
},
"outputs": [],
"source": [
"docs_with_score[0]"
Expand All @@ -466,7 +511,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"nbreg": {
"diff_ignore": [
"/outputs"
]
}
},
"outputs": [],
"source": [
"print(retriever)"
Expand Down