synapse-pkg 2.0.0a2__tar.gz → 2.0.0a4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-pkg
3
- Version: 2.0.0a2
3
+ Version: 2.0.0a4
4
4
  Summary: Knowledge graph extraction library powered by LLMs
5
5
  Author: Piyush Garg
6
6
  Requires-Python: >=3.10
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "synapse-pkg"
7
- version = "2.0.0a2"
7
+ version = "2.0.0a4"
8
8
  description = "Knowledge graph extraction library powered by LLMs"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,5 +1,4 @@
1
1
  import sys
2
-
3
2
  from . import commands
4
3
 
5
4
 
@@ -11,6 +10,7 @@ def main():
11
10
  print("Available commands:")
12
11
  print(" init")
13
12
  print(" knowledge")
13
+ print(" Setup")
14
14
  return
15
15
 
16
16
  command = sys.argv[1].lower()
@@ -0,0 +1,38 @@
1
+ from .persistence import initialize_synapse, save_config
2
+ from .processor import build_repository_context
3
+ from .extractor import build_compressed_context
4
+ from .provider import get_ollama_model
5
+
6
+
7
+ def Setup():
8
+ models = get_ollama_model()
9
+
10
+ for i,model in enumerate(models,start=1):
11
+ print(f"{i}, {model}")
12
+ choice = int(input("select a model"))
13
+ selected_model = models[choice-1]
14
+ save_config(
15
+ {
16
+ "provider":"ollama",
17
+ "model": selected_model
18
+ }
19
+ )
20
+
21
+
22
+ def init():
23
+ initialize_synapse()
24
+
25
+
26
+ def knowledge():
27
+ print("Initializing repository context...")
28
+
29
+ build_repository_context()
30
+
31
+ print(
32
+ "Repository context initialized.\n"
33
+ "Building compressed repository context..."
34
+ )
35
+
36
+ build_compressed_context()
37
+
38
+ print("Successfully initialized compressed repository context.")
@@ -1,5 +1,5 @@
1
1
  import git
2
- from .persistence import load_compressed_context, save_compressed_context, load_metadata, save_metadata
2
+ from .persistence import load_compressed_context, save_compressed_context, load_metadata, save_metadata, load_config
3
3
  from .git_manager import (
4
4
  get_repository_changes,
5
5
  split_commit_by_file
@@ -9,6 +9,8 @@ import json
9
9
 
10
10
  repo = git.Repo(search_parent_directories=True)
11
11
 
12
+ config = load_config()
13
+
12
14
 
13
15
  MAX_PROMPT_SIZE = 30000
14
16
  MAX_FILES_PER_COMMIT = 3
@@ -24,9 +26,31 @@ VALID_KEYS = {
24
26
  }
25
27
 
26
28
 
29
+ SYSTEM_PROMPT = """
30
+ You are Synapse Repository Memory Builder.
31
+
32
+ Your sole responsibility is to construct and maintain a canonical Repository Memory.
33
+
34
+ Always obey the task described by the user.
35
+
36
+ Rules:
37
+
38
+ - Return ONLY valid JSON.
39
+ - Never return markdown.
40
+ - Never explain your reasoning.
41
+ - Never summarize code for a human.
42
+ - Never answer conversationally.
43
+ - Never invent repository knowledge.
44
+ - Only use information present in the input.
45
+ - Follow the requested JSON schema exactly.
46
+ - Maintain a stable repository ontology.
47
+ - Merge equivalent concepts instead of duplicating them.
48
+ - Prefer abstraction over implementation details.
49
+ - If uncertain, omit the information instead of hallucinating.
50
+ """
51
+
27
52
 
28
53
  INITIAL_PROMPT_TEMPLATE = """
29
- You are Synapse Repository Memory Builder.
30
54
 
31
55
  TASK
32
56
 
@@ -188,20 +212,6 @@ OUTPUT FORMAT
188
212
  "current_capabilities": []
189
213
  }}
190
214
 
191
- IMPORTANT
192
-
193
- The output becomes compressed_context.json.
194
-
195
- Return only valid JSON.
196
-
197
- Return only the JSON object shown above.
198
-
199
- No markdown.
200
-
201
- No explanations.
202
-
203
- No text outside JSON.
204
-
205
215
  per_commit_diff:
206
216
 
207
217
  {initial_commit_diff}
@@ -210,7 +220,6 @@ per_commit_diff:
210
220
 
211
221
 
212
222
  UPDATE_PROMPT_TEMPLATE = """
213
- You are Synapse Repository Memory Maintainer.
214
223
 
215
224
  TASK
216
225
 
@@ -525,13 +534,6 @@ OUTPUT FORMAT
525
534
  "current_capabilities": []
526
535
  }}
527
536
 
528
- Return ONLY valid JSON.
529
-
530
- Return ONLY the JSON object.
531
-
532
- No markdown.
533
-
534
- No explanations.
535
537
 
536
538
  current_compressed_context:
537
539
 
@@ -568,6 +570,16 @@ def generate_update_prompt(current_compressed_context, per_commit_diff):
568
570
  def clean_json_response(raw: str) -> dict:
569
571
  text = raw.strip()
570
572
 
573
+
574
+ if not text.startswith("{") and not text.startswith("```"):
575
+ print("=" * 80)
576
+ print("[context_builder] Model ignored JSON output format.")
577
+ print("RAW TEXT:")
578
+ print(text)
579
+ print("=" * 80)
580
+ return None
581
+
582
+
571
583
  if text.startswith("```"):
572
584
  lines = text.splitlines()
573
585
  inner_lines = []
@@ -615,10 +627,21 @@ def clean_json_response(raw: str) -> dict:
615
627
 
616
628
  def get_response(prompt, num_predict=4096):
617
629
 
630
+ if config["model"]:
631
+ model = config["model"]
632
+ else:
633
+ print("no model configured.")
634
+ print("Run 'synapse setup' first.")
635
+ return
636
+
618
637
  try:
619
638
  response = chat(
620
- model="qwen3:14b-q4_K_M",
639
+ model=model,
621
640
  messages=[
641
+ {
642
+ "role": "system",
643
+ "content": SYSTEM_PROMPT
644
+ },
622
645
  {
623
646
  "role": "user",
624
647
  "content": prompt
@@ -630,9 +653,10 @@ def get_response(prompt, num_predict=4096):
630
653
  "temperature": 0
631
654
  }
632
655
  )
633
- except Exception as e:
656
+ except Exception:
634
657
  print("Failed to connect to Ollama.")
635
658
  print("Make sure Ollama is running and the required model is installed.")
659
+ return None
636
660
 
637
661
  raw = response["message"]["content"]
638
662
 
@@ -280,28 +280,93 @@ def preprocess_readme_diff(file_diff: str) -> str:
280
280
  """
281
281
  Remove documentation sections that are not durable repository knowledge.
282
282
  """
283
-
284
283
  ignored_sections = [
285
284
  "# Installation",
286
285
  "## Installation",
286
+
287
287
  "# Quick Start",
288
288
  "## Quick Start",
289
+
290
+ "# Getting Started",
291
+ "## Getting Started",
292
+
293
+ "# Setup",
294
+ "## Setup",
295
+
296
+ "# Requirements",
297
+ "## Requirements",
298
+
299
+ "# Prerequisites",
300
+ "## Prerequisites",
301
+
289
302
  "# Usage",
290
303
  "## Usage",
304
+
291
305
  "# Example",
292
306
  "## Example",
307
+
293
308
  "# Examples",
294
309
  "## Examples",
310
+
311
+ "# Demo",
312
+ "## Demo",
313
+
314
+ "# Screenshots",
315
+ "## Screenshots",
316
+
317
+ "# Benchmark",
318
+ "## Benchmark",
319
+
320
+ "# Benchmarks",
321
+ "## Benchmarks",
322
+
323
+ "# Performance",
324
+ "## Performance",
325
+
326
+ "# Testing",
327
+ "## Testing",
328
+
329
+ "# Troubleshooting",
330
+ "## Troubleshooting",
331
+
332
+ "# FAQ",
333
+ "## FAQ",
334
+
335
+ "# Changelog",
336
+ "## Changelog",
337
+
338
+ "# Release Notes",
339
+ "## Release Notes",
340
+
341
+ "# Version History",
342
+ "## Version History",
343
+
344
+ "# Contributing",
345
+ "## Contributing",
346
+
347
+ "# Authors",
348
+ "## Authors",
349
+
295
350
  "# Author",
296
351
  "## Author",
352
+
353
+ "# Credits",
354
+ "## Credits",
355
+
356
+ "# Acknowledgements",
357
+ "## Acknowledgements",
358
+
359
+ "# Citation",
360
+ "## Citation",
361
+
297
362
  "# License",
298
363
  "## License",
299
- "# Contributing",
300
- "## Contributing",
301
- "# Roadmap",
302
- "## Roadmap",
303
- "# FAQ",
304
- "## FAQ",
364
+
365
+ "# Contact",
366
+ "## Contact",
367
+
368
+ "# Support",
369
+ "## Support"
305
370
  ]
306
371
 
307
372
  lines = file_diff.splitlines()
@@ -0,0 +1,8 @@
1
+ import ollama
2
+ def get_ollama_model():
3
+ response = ollama.list()
4
+ model_names=[]
5
+ for model in response.models:
6
+ model_names.append(model.model)
7
+ return model_names
8
+ print(get_ollama_model())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-pkg
3
- Version: 2.0.0a2
3
+ Version: 2.0.0a4
4
4
  Summary: Knowledge graph extraction library powered by LLMs
5
5
  Author: Piyush Garg
6
6
  Requires-Python: >=3.10
@@ -8,6 +8,7 @@ synapse/extractor.py
8
8
  synapse/git_manager.py
9
9
  synapse/persistence.py
10
10
  synapse/processor.py
11
+ synapse/provider.py
11
12
  synapse_pkg.egg-info/PKG-INFO
12
13
  synapse_pkg.egg-info/SOURCES.txt
13
14
  synapse_pkg.egg-info/dependency_links.txt
@@ -1,22 +0,0 @@
1
- from .persistence import initialize_synapse
2
- from .processor import build_repository_context
3
- from .extractor import build_compressed_context
4
-
5
-
6
- def init():
7
- initialize_synapse()
8
-
9
-
10
- def knowledge():
11
- print("Initializing repository context...")
12
-
13
- build_repository_context()
14
-
15
- print(
16
- "Repository context initialized.\n"
17
- "Building compressed repository context..."
18
- )
19
-
20
- build_compressed_context()
21
-
22
- print("Successfully initialized compressed repository context.")
File without changes
File without changes
File without changes