From 3336bf7d2d1915d77aa712e6366ed78b6de8846c Mon Sep 17 00:00:00 2001 From: granawkins Date: Thu, 30 May 2024 06:18:29 +0700 Subject: [PATCH 1/2] update to latest spiceai and ragdaemon --- benchmarks/context_benchmark.py | 4 ++-- benchmarks/run_sample.py | 9 --------- mentat/code_context.py | 10 ++-------- requirements.txt | 4 ++-- tests/code_context_test.py | 8 +++++--- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/benchmarks/context_benchmark.py b/benchmarks/context_benchmark.py index 031785d18..b6fc51319 100755 --- a/benchmarks/context_benchmark.py +++ b/benchmarks/context_benchmark.py @@ -38,7 +38,7 @@ async def run_auto_context_benchmark(sample: Sample, config: Config, cwd: Path | ignore_patterns = [cwd / ".venv"] annotators = { "hierarchy": {"ignore_patterns": ignore_patterns}, - "chunker_line": {"lines_per_chunk": 100}, + "chunker": {}, } daemon = Daemon(cwd=cwd, annotators=annotators) await daemon.update() @@ -61,7 +61,7 @@ def main(user_samples: list[str], directory: str): assert dir_path.exists(), f"Invalid directory: {directory}" print(f"Running benchmarks from {dir_path}") samples: list[Sample] = [] - for root, dirs, files in os.walk(dir_path): + for root, _, files in os.walk(dir_path): for file in files: path = Path(root) / file if file.endswith(".json"): diff --git a/benchmarks/run_sample.py b/benchmarks/run_sample.py index da89f4305..77e1e32df 100644 --- a/benchmarks/run_sample.py +++ b/benchmarks/run_sample.py @@ -31,15 +31,6 @@ def setup_sample( ) cwd = Path(repo.working_dir) - # Make sure there's a .gitignore file, and that '.ragdaemon/*' is in it - gitignore_path = cwd / ".gitignore" - if not gitignore_path.exists(): - gitignore_path.write_text(".ragdaemon/*\n") - else: - gitignore_contents = gitignore_path.read_text() - if ".ragdaemon/*" not in gitignore_contents: - gitignore_path.write_text(gitignore_contents + ".ragdaemon/*\n") - test_executable = None if not skip_test_exec and (sample.FAIL_TO_PASS or sample.PASS_TO_PASS): # If there's an environment_setup_commit, this is what it's needed for. diff --git a/mentat/code_context.py b/mentat/code_context.py index 0cf65a6c5..5d3e3789b 100644 --- a/mentat/code_context.py +++ b/mentat/code_context.py @@ -20,7 +20,7 @@ from mentat.llm_api_handler import get_max_tokens from mentat.session_context import SESSION_CONTEXT from mentat.session_stream import SessionStream -from mentat.utils import get_relative_path, mentat_dir_path +from mentat.utils import get_relative_path class ContextStreamMessage(TypedDict): @@ -35,10 +35,6 @@ class ContextStreamMessage(TypedDict): total_cost: float -graphs_dir = mentat_dir_path / "ragdaemon" -graphs_dir.mkdir(parents=True, exist_ok=True) - - class CodeContext: daemon: Daemon @@ -75,16 +71,14 @@ async def refresh_daemon(self): annotators: dict[str, dict[str, Any]] = { "hierarchy": {"ignore_patterns": [str(p) for p in self.ignore_patterns]}, - "chunker_line": {"lines_per_chunk": 50}, + "chunker": {}, "diff": {"diff": self.diff_context.target}, } self.daemon = Daemon( cwd=cwd, annotators=annotators, verbose=False, - graph_path=graphs_dir / f"ragdaemon-{cwd.name}.json", spice_client=llm_api_handler.spice, - model=ctx.config.embedding_model, provider=ctx.config.embedding_provider, ) await self.daemon.update() diff --git a/requirements.txt b/requirements.txt index c708d5240..8c641f500 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,12 +9,12 @@ openai==1.13.3 pillow==10.1.0 prompt-toolkit==3.0.39 Pygments==2.15.1 -ragdaemon==0.2.12 +ragdaemon~=0.7.0 selenium==4.15.2 sentry-sdk==1.34.0 sounddevice==0.4.6 soundfile==0.12.1 -spiceai~=0.2.0 +spiceai~=0.3.0 termcolor==2.3.0 textual==0.47.1 textual-autocomplete==2.1.0b0 diff --git a/tests/code_context_test.py b/tests/code_context_test.py index ce384b159..1a8ff2762 100644 --- a/tests/code_context_test.py +++ b/tests/code_context_test.py @@ -213,7 +213,7 @@ def func_4(string): mock_session_context.config.auto_context_tokens = 8000 code_message = await code_context.get_code_message(0, prompt="prompt") - assert mock_session_context.llm_api_handler.spice.count_tokens(code_message, "gpt-4", is_message=True) == 85 # Code + assert mock_session_context.llm_api_handler.spice.count_tokens(code_message, "gpt-4", is_message=True) == 89 # Code assert ( code_message == """\ @@ -225,6 +225,7 @@ def func_4(string): 3: 4:def func_2(): 5: return 3 +6: file_2.py 1:def func_3(a, b, c): @@ -232,6 +233,7 @@ def func_4(string): 3: 4:def func_4(string): 5: print(string) +6: """ ) @@ -256,7 +258,7 @@ async def test_get_all_features(temp_testbed, mock_session_context): # Test without include_files features = mock_code_context.get_all_features() - assert len(features) == 2 + assert len(features) == 6 feature1 = next(f for f in features if f.path == path1) feature2 = next(f for f in features if f.path == path2) for _f, _p in zip((feature1, feature2), (path1, path2)): @@ -266,7 +268,7 @@ async def test_get_all_features(temp_testbed, mock_session_context): # Test with include_files argument matching one file mock_code_context.include(path1) features = mock_code_context.get_all_features(split_intervals=False) - assert len(features) == 2 + assert len(features) == 6 feature1b = next(f for f in features if f.path == path1) feature2b = next(f for f in features if f.path == path2) assert feature1b.interval.whole_file() From b82367103c7eb7ea0e04bbb97028a0371ace0df3 Mon Sep 17 00:00:00 2001 From: granawkins Date: Thu, 30 May 2024 06:55:32 +0700 Subject: [PATCH 2/2] patch version bump --- mentat/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mentat/VERSION b/mentat/VERSION index f8f3c0872..140333f6d 100644 --- a/mentat/VERSION +++ b/mentat/VERSION @@ -1 +1 @@ -1.0.18 +1.0.19