Skip to content
Open
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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ repos:
# - tags
# - slideshow
# - --
- repo: https://github.com/psf/black
rev: 24.10.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
rev: "v6.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -50,14 +50,14 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.4"
rev: "v0.16.5"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.23"
rev: "0.26"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]
Expand All @@ -70,13 +70,13 @@ repos:
args: [--prose-wrap=always]

- repo: https://github.com/codespell-project/codespell
rev: "v2.3.0"
rev: "v2.4.3"
hooks:
- id: codespell
args: ["-L", "precessing"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.30.0"
rev: "0.38.0"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"metadata": {},
"outputs": [],
"source": [
"from tqdm import tqdm\n",
"import pandas as pd"
"import pandas as pd\n",
"from tqdm import tqdm"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain_community.document_loaders import PyMuPDFLoader\n",
"\n",
"pdf_folder_path = \"/your/folder/path/\" # update path to point to the relevant directory\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"from getpass import getpass\n",
"\n",
"import pandas as pd\n",
"from langchain_huggingface import HuggingFaceEmbeddings\n",
"from langchain_qdrant import Qdrant\n",
"import pandas as pd\n",
"from qdrant_client import QdrantClient"
]
},
Expand All @@ -42,12 +42,12 @@
"from ssec_tutorials import (\n",
" ASTROPH_ARXIV_ABSTRACTS,\n",
" ASTROPY_GITHUB,\n",
" QDRANT_COLLECTION_NAME,\n",
" QDRANT_PATH,\n",
" download_astroph_arxiv_abstracts,\n",
" download_astropy_github_documents,\n",
" fetch_and_process_github_rst_files,\n",
" download_qdrant_data,\n",
" QDRANT_COLLECTION_NAME,\n",
" QDRANT_PATH,\n",
" fetch_and_process_github_rst_files,\n",
")\n",
"from ssec_tutorials.scipy_conf import load_docs_from_jsonl"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,10 @@
"source": [
"# Test the prompt you want to send to OLMo.\n",
"question = \"What is the best method for multiplying large numbers?\"\n",
"input_content = textwrap.dedent(\n",
" f\"\"\"\\\n",
"input_content = textwrap.dedent(f\"\"\"\\\n",
" You are an algorithms expert. Please answer the following question on algorithms.\n",
" Question: {question}\n",
"\"\"\"\n",
")\n",
"\"\"\")\n",
"input_messages = [\n",
" {\n",
" \"role\": \"user\",\n",
Expand Down Expand Up @@ -271,13 +269,11 @@
"metadata": {},
"outputs": [],
"source": [
"input_prompt_template = textwrap.dedent(\n",
" \"\"\"\\\n",
"input_prompt_template = textwrap.dedent(\"\"\"\\\n",
"{instruction}\n",
"\n",
"Question: {question}\n",
"\"\"\"\n",
")"
"\"\"\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain_community.document_loaders import PyMuPDFLoader\n",
"\n",
"pdf_folder_path = \".\" # update path to point to the relevant directory\n",
Expand Down Expand Up @@ -513,10 +514,11 @@
"metadata": {},
"outputs": [],
"source": [
"import shutil\n",
"\n",
"from langchain_qdrant import Qdrant\n",
"from qdrant_client import QdrantClient\n",
"from ssec_tutorials import TUTORIAL_CACHE\n",
"import shutil\n",
"\n",
"qdrant_collection = \"algorithms_book\"\n",
"qdrant_path = TUTORIAL_CACHE / \"algorithms_book\"\n",
Expand Down
21 changes: 8 additions & 13 deletions AI_Postdoc_Workshop/module2/2-olmo-chat-rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,16 @@
"outputs": [],
"source": [
"import textwrap\n",
"from uuid import uuid4\n",
"import warnings\n",
"from uuid import uuid4\n",
"\n",
"\n",
"from langchain_core.runnables import RunnablePassthrough\n",
"from langchain_core.callbacks import CallbackManager, BaseCallbackHandler\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_community.llms import LlamaCpp\n",
"from langchain_qdrant import Qdrant\n",
"from langchain_core.callbacks import BaseCallbackHandler, CallbackManager\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_core.runnables import RunnablePassthrough\n",
"from langchain_huggingface import HuggingFaceEmbeddings\n",
"\n",
"from ssec_tutorials import TUTORIAL_CACHE\n",
"from ssec_tutorials import download_olmo_model"
"from langchain_qdrant import Qdrant\n",
"from ssec_tutorials import TUTORIAL_CACHE, download_olmo_model"
]
},
{
Expand Down Expand Up @@ -342,15 +339,13 @@
"metadata": {},
"outputs": [],
"source": [
"input_prompt_template = textwrap.dedent(\n",
" \"\"\"\\\n",
"input_prompt_template = textwrap.dedent(\"\"\"\\\n",
"You are an algorithms expert. Please answer the question on algorithms based on the following context:\n",
"\n",
"{context}\n",
"\n",
"Question: {question}\n",
"\"\"\"\n",
")"
"\"\"\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"metadata": {},
"outputs": [],
"source": [
"from tqdm import tqdm\n",
"import pandas as pd"
"import pandas as pd\n",
"from tqdm import tqdm"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain_community.document_loaders import PyMuPDFLoader\n",
"\n",
"pdf_folder_path = \"/your/folder/path/\" # update path to point to the relevant directory\n",
Expand Down
10 changes: 5 additions & 5 deletions Archive/SciPy2024/appendix/qdrant-vector-database-creation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"from getpass import getpass\n",
"\n",
"import pandas as pd\n",
"from langchain_huggingface import HuggingFaceEmbeddings\n",
"from langchain_qdrant import Qdrant\n",
"import pandas as pd\n",
"from qdrant_client import QdrantClient"
]
},
Expand All @@ -42,12 +42,12 @@
"from ssec_tutorials import (\n",
" ASTROPH_ARXIV_ABSTRACTS,\n",
" ASTROPY_GITHUB,\n",
" QDRANT_COLLECTION_NAME,\n",
" QDRANT_PATH,\n",
" download_astroph_arxiv_abstracts,\n",
" download_astropy_github_documents,\n",
" fetch_and_process_github_rst_files,\n",
" download_qdrant_data,\n",
" QDRANT_COLLECTION_NAME,\n",
" QDRANT_PATH,\n",
" fetch_and_process_github_rst_files,\n",
")\n",
"from ssec_tutorials.scipy_conf import load_docs_from_jsonl"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@
"metadata": {},
"outputs": [],
"source": [
"from collections import defaultdict\n",
"import nltk\n",
"import random\n",
"import re\n",
"from collections import defaultdict\n",
"\n",
"import nltk\n",
"import numpy as np\n",
"import pandas as pd"
]
Expand Down Expand Up @@ -332,7 +333,7 @@
"outputs": [],
"source": [
"# Removing extra spaces\n",
"abstracts = re.sub(\"\\s+\", \" \", abstracts)"
"abstracts = re.sub(r\"\\s+\", \" \", abstracts)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,10 @@
"source": [
"# Test the prompt you want to send to OLMo.\n",
"question = \"What is dark matter?\"\n",
"input_content = textwrap.dedent(\n",
" f\"\"\"\\\n",
"input_content = textwrap.dedent(f\"\"\"\\\n",
" You are an astrophysics expert. Please answer the following question on astrophysics.\n",
" Question: {question}\n",
"\"\"\"\n",
")\n",
"\"\"\")\n",
"input_messages = [\n",
" {\n",
" \"role\": \"user\",\n",
Expand Down Expand Up @@ -330,13 +328,11 @@
"metadata": {},
"outputs": [],
"source": [
"input_prompt_template = textwrap.dedent(\n",
" \"\"\"\\\n",
"input_prompt_template = textwrap.dedent(\"\"\"\\\n",
"{instruction}\n",
"\n",
"Question: {question}\n",
"\"\"\"\n",
")"
"\"\"\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
"metadata": {},
"outputs": [],
"source": [
"from ssec_tutorials import download_qdrant_data, QDRANT_COLLECTION_NAME"
"from ssec_tutorials import QDRANT_COLLECTION_NAME, download_qdrant_data"
]
},
{
Expand Down
25 changes: 12 additions & 13 deletions Archive/SciPy2024/module3/1-olmo-chat-rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,20 @@
"outputs": [],
"source": [
"import textwrap\n",
"from uuid import uuid4\n",
"import warnings\n",
"from uuid import uuid4\n",
"\n",
"\n",
"from langchain_core.runnables import RunnablePassthrough\n",
"from langchain_core.callbacks import CallbackManager, BaseCallbackHandler\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_community.llms import LlamaCpp\n",
"from langchain_qdrant import Qdrant\n",
"from langchain_core.callbacks import BaseCallbackHandler, CallbackManager\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_core.runnables import RunnablePassthrough\n",
"from langchain_huggingface import HuggingFaceEmbeddings\n",
"\n",
"from ssec_tutorials import QDRANT_COLLECTION_NAME\n",
"from ssec_tutorials import download_olmo_model, download_qdrant_data"
"from langchain_qdrant import Qdrant\n",
"from ssec_tutorials import (\n",
" QDRANT_COLLECTION_NAME,\n",
" download_olmo_model,\n",
" download_qdrant_data,\n",
")"
]
},
{
Expand Down Expand Up @@ -364,15 +365,13 @@
"metadata": {},
"outputs": [],
"source": [
"input_prompt_template = textwrap.dedent(\n",
" \"\"\"\\\n",
"input_prompt_template = textwrap.dedent(\"\"\"\\\n",
"You are an astrophysics expert. Please answer the question on astrophysics based on the following context:\n",
"\n",
"{context}\n",
"\n",
"Question: {question}\n",
"\"\"\"\n",
")"
"\"\"\")"
]
},
{
Expand Down
Loading