Skip to content

Commit c69d91d

Browse files
jonahdcCTY-git
andauthored
Remove RAG group (#1328)
* remove rag group * add lock file * remove chromadb dependent code * remove chroma dependent tests * remove entire rag group * remove rag test --------- Co-authored-by: TIANYOU CHEN <42710806+CTY-git@users.noreply.github.com>
1 parent c0b28f3 commit c69d91d

File tree

21 files changed

+177
-2336
lines changed

21 files changed

+177
-2336
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -118,53 +118,6 @@ jobs:
118118
--force_pr_creation \
119119
--disable_telemetry
120120
121-
rag-test:
122-
# disabled because this currently takes too long
123-
if: false
124-
runs-on: ubuntu-latest
125-
steps:
126-
- name: Checkout code
127-
uses: actions/checkout@v3
128-
with:
129-
ref: ${{ github.head_ref }}
130-
131-
- uses: jwalton/gh-find-current-pr@master
132-
id: findPr
133-
134-
- name: Set up python
135-
id: setup-python
136-
uses: actions/setup-python@v5
137-
with:
138-
python-version: '3.9'
139-
140-
- name: Install Poetry
141-
uses: snok/install-poetry@v1
142-
with:
143-
virtualenvs-create: true
144-
virtualenvs-in-project: true
145-
installer-parallel: true
146-
147-
- name: Load cached venv
148-
id: cached-poetry-dependencies
149-
uses: actions/cache@v4
150-
with:
151-
path: ./.venv
152-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }}
153-
154-
- name: Install dependencies
155-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
156-
run: poetry install --no-interaction --only main --extras rag
157-
158-
- name: Resolve issue
159-
run: |
160-
source .venv/bin/activate
161-
patchwork ResolveIssue --log debug \
162-
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
163-
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
164-
--issue_url=https://github.com/patched-codes/patchwork/issues/1129 \
165-
--disable_telemetry
166-
--max_llm_calls=10
167-
168121
main-test:
169122
runs-on: ubuntu-latest
170123
steps:

patchwork/common/utils/dependency.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from functools import lru_cache
33

44
__DEPENDENCY_GROUPS = {
5-
"rag": ["chromadb"],
65
"security": ["semgrep", "depscan"],
76
"notification": ["slack_sdk"],
87
}
@@ -22,9 +21,5 @@ def import_with_dependency_group(name):
2221
raise ImportError(error_msg)
2322

2423

25-
def chromadb():
26-
return import_with_dependency_group("chromadb")
27-
28-
2924
def slack_sdk():
3025
return import_with_dependency_group("slack_sdk")

patchwork/common/utils/utils.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
from git import Head, Repo
1616
from typing_extensions import Any, Callable, Counter
1717

18-
from patchwork.common.utils.dependency import chromadb
1918
from patchwork.logger import logger
20-
from patchwork.managed_files import HOME_FOLDER
2119

2220
_CLEANUP_FILES: set[Path] = set()
2321
_NEWLINES = {"\n", "\r\n", "\r"}
@@ -129,66 +127,6 @@ def count_openai_tokens(code: str):
129127
return len(_ENCODING.encode(code))
130128

131129

132-
def get_vector_db_path() -> str:
133-
CHROMA_DB_PATH = HOME_FOLDER / "chroma.db"
134-
if CHROMA_DB_PATH:
135-
return str(CHROMA_DB_PATH)
136-
else:
137-
return ".chroma.db"
138-
139-
140-
def openai_embedding_model(
141-
inputs: dict,
142-
) -> "chromadb.api.types.EmbeddingFunction"["chromadb.api.types.Documents"] | None:
143-
model = inputs.get(openai_embedding_model.__name__)
144-
if model is None:
145-
return None
146-
147-
api_key = inputs.get("openai_api_key")
148-
if api_key is None:
149-
raise ValueError("Missing required input data: 'openai_api_key'")
150-
151-
return chromadb().utils.embedding_functions.OpenAIEmbeddingFunction(
152-
api_key=api_key,
153-
model_name=model,
154-
)
155-
156-
157-
def huggingface_embedding_model(
158-
inputs: dict,
159-
) -> "chromadb.api.types.EmbeddingFunction"["chromadb.api.types.Documents"] | None:
160-
model = inputs.get(huggingface_embedding_model.__name__)
161-
if model is None:
162-
return None
163-
164-
api_key = inputs.get("openai_api_key") or inputs.get("huggingface_api_key")
165-
if api_key is None:
166-
raise ValueError("Missing required input data: 'openai_api_key' or 'huggingface_api_key'")
167-
168-
return chromadb().utils.embedding_functions.HuggingFaceEmbeddingFunction(
169-
api_key=api_key,
170-
model_name=model,
171-
)
172-
173-
174-
_EMBEDDING_FUNCS = [openai_embedding_model, huggingface_embedding_model]
175-
176-
_EMBEDDING_TO_API_KEY_NAME: dict[
177-
str, Callable[[dict], "chromadb.api.type.EmbeddingFunction"["chromadb.api.types.Documents"] | None]
178-
] = {func.__name__: func for func in _EMBEDDING_FUNCS}
179-
180-
181-
def get_embedding_function(inputs: dict) -> "chromadb.api.types.EmbeddingFunction"["chromadb.api.types.Documents"]:
182-
embedding_function = next(
183-
(func(inputs) for input_key, func in _EMBEDDING_TO_API_KEY_NAME.items() if input_key in inputs.keys()),
184-
chromadb().utils.embedding_functions.SentenceTransformerEmbeddingFunction(),
185-
)
186-
if embedding_function is None:
187-
raise ValueError(f"Missing required input data: one of {_EMBEDDING_TO_API_KEY_NAME.keys()}")
188-
189-
return embedding_function
190-
191-
192130
def get_current_branch(repo: Repo) -> Head:
193131
remote = repo.remote("origin")
194132
if repo.head.is_detached:

patchwork/steps/GenerateCodeRepositoryEmbeddings/GenerateCodeRepositoryEmbeddings.py

Lines changed: 0 additions & 141 deletions
This file was deleted.

patchwork/steps/GenerateCodeRepositoryEmbeddings/README.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

patchwork/steps/GenerateCodeRepositoryEmbeddings/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)