File size: 29,690 Bytes
57d6347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef _score(snippet: dict, low: str) -> int:\n    padded = f\" {low} \"\n    score = 0\n```", "response": "    for keyword in snippet[\"keywords\"]:\n        if keyword in padded:\n            score += len(keyword) + (3 if \" \" in keyword else 0)\n    return score", "source_file": "code_helper.py", "function_name": "_score", "class_name": null, "line_start": 50, "line_end": 56, "license": "mit", "source": "SadikAI project"}
{"task": "code_explanation", "language": "python", "instruction": "Explain what this Python function does.\n\n```python\ndef _has_cue(low: str, cues: tuple[str, ...]) -> bool:\n    \"\"\"Whole-word matching: 'script' must not fire inside 'javascript'.\"\"\"\n    for cue in cues:\n        if \" \" in cue or \"/\" in cue:\n            if cue in low:\n                return True\n        elif re.search(rf\"(?<!\\w){re.escape(cue)}(?!\\w)\", low):\n            return True\n    return False\n```", "response": "Whole-word matching: 'script' must not fire inside 'javascript'.", "source_file": "code_helper.py", "function_name": "_has_cue", "class_name": null, "line_start": 59, "line_end": 67, "license": "mit", "source": "SadikAI project"}
{"task": "code_generation", "language": "python", "instruction": "Write a Python function `_has_cue(low: str, cues: tuple[str, ...])` that does the following:\n\nWhole-word matching: 'script' must not fire inside 'javascript'.\n\nReturn only the Python code.", "response": "def _has_cue(low: str, cues: tuple[str, ...]) -> bool:\n    \"\"\"Whole-word matching: 'script' must not fire inside 'javascript'.\"\"\"\n    for cue in cues:\n        if \" \" in cue or \"/\" in cue:\n            if cue in low:\n                return True\n        elif re.search(rf\"(?<!\\w){re.escape(cue)}(?!\\w)\", low):\n            return True\n    return False", "source_file": "code_helper.py", "function_name": "_has_cue", "class_name": null, "line_start": 59, "line_end": 67, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef _format(snippet: dict, explain_first: bool) -> str:\n    language = snippet[\"language\"]\n    pretty = _pretty(language)\n    head = f\"{pretty}: {snippet['title']}.\"\n    code = snippet[\"code\"]\n    explain = f\"Why it works: {snippet['explain']}\"\n```", "response": "    if explain_first:\n        body = f\"{head}\\n\\n{explain}\\n\\n{code}\"\n    else:\n        body = f\"{head}\\n\\n{code}\\n\\n{explain}\"\n\n    if snippet.get(\"demo\"):\n        body += f\"\\n\\nExample output:\\n{snippet['demo']}\"\n    return body", "source_file": "code_helper.py", "function_name": "_format", "class_name": null, "line_start": 89, "line_end": 103, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef overview(language: str) -> str:\n    titles = [s[\"title\"] for s in SNIPPETS if s[\"language\"] == language]\n    pretty = _pretty(language)\n```", "response": "    if not titles:\n        return \"\"\n    sample = \", \".join(titles[:6])\n    return (f\"I have verified {pretty} examples for: {sample}.\\n\"\n            f\"Ask for one directly, e.g. \\\"{language} fibonacci\\\".\")", "source_file": "code_helper.py", "function_name": "overview", "class_name": null, "line_start": 106, "line_end": 113, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef answer_code(text: str) -> str | None:\n    low = \" \".join(text.lower().split())\n    language = detect_language(low)\n    explain_first = any(w in low for w in EXPLAIN_WORDS)\n\n    # A bare topic (\"fibonacci\") or an explicit code cue is needed; this stops\n    # \"who is the prime minister?\" from matching the prime-number snippet.\n    if not language and not _has_context(low) and not _bare_topic(low):\n        return None\n\n    pool = [s for s in SNIPPETS if s[\"language\"] == language] if language else SNIPPETS\n    best = None\n    best_score = 0\n    for snippet in pool:\n        score = _score(snippet, low)\n        if score > best_score:\n            best, best_score = snippet, score\n```", "response": "    if best is not None and best_score >= 3:\n        return _format(best, explain_first)\n\n    # Language named but no task: offer the menu instead of guessing, but only\n    # when the message actually asks for code (not \"why is JavaScript popular?\").\n    topic_only = low.strip(\" .!?\") in {\n        \"javascript\", \"js\", \"node\", \"nodejs\", \"sql\", \"html\", \"css\",\n        \"powershell\", \"c++\", \"cpp\",\n    }\n    if language and language != \"python\" and (_wants_code(low) or topic_only):\n        return overview(language)\n\n    # A generic coding request with no usable keyword: offer the menu instead\n    # of letting the tiny base model invent broken code.\n    if _wants_code(low):\n        return overview(\"python\")\n    return None", "source_file": "code_helper.py", "function_name": "answer_code", "class_name": null, "line_start": 116, "line_end": 150, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef main() -> None:\n    ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)\n    ap.add_argument(\"--checkpoint\", default=\"runs/medium/best.pt\")\n    ap.add_argument(\"--tokenizer\", default=\"tokenizer/tokenizer.json\")\n    ap.add_argument(\"--prompt\", default=None)\n    ap.add_argument(\"--max-new-tokens\", type=int, default=60)\n    ap.add_argument(\"--temperature\", type=float, default=0.8)\n    ap.add_argument(\"--top-k\", type=int, default=50)\n    ap.add_argument(\"--top-p\", type=float, default=0.92)\n    ap.add_argument(\"--seed\", type=int, default=0)\n    ap.add_argument(\"--device\", default=\"auto\")\n    args = ap.parse_args()\n\n    device = torch.device(\n        \"cuda\" if args.device == \"auto\" and torch.cuda.is_available() else\n        (\"cpu\" if args.device == \"auto\" else args.device)\n    )\n    ckpt = torch.load(args.checkpoint, map_location=device, weights_only=False)\n    model = GPT(ModelConfig.from_dict(ckpt[\"model_config\"]))\n    model.load_state_dict(ckpt[\"model\"])\n```", "response": "    model.to(device).eval()\n    tok = Tokenizer(args.tokenizer)\n\n    print(f\"{args.checkpoint} @ step {ckpt.get('step')} | \"\n          f\"{model.num_params() / 1e6:.1f}M params | vocab {tok.vocab_size:,}\\n\")\n\n    todo = [(args.prompt, args.prompt)] if args.prompt else PROMPTS\n    for name, prompt in todo:\n        torch.manual_seed(args.seed)\n        ids = tok.encode(prompt)\n        x = torch.tensor([ids], dtype=torch.long, device=device)\n        out = model.generate(\n            x,\n            max_new_tokens=args.max_new_tokens,\n            temperature=args.temperature,\n            top_k=args.top_k,\n            top_p=args.top_p,\n            repetition_penalty=1.1,\n            eos_id=tok.eos_id,\n        )\n        text = tok.decode(out[0].tolist())\n        print(f\"[{name}]\\n{text}\\n\")", "source_file": "demo_multilingual.py", "function_name": "main", "class_name": null, "line_start": 28, "line_end": 69, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef download(url: str, dest: Path, label: str) -> Path:\n    dest.parent.mkdir(parents=True, exist_ok=True)\n    if dest.exists() and dest.stat().st_size > 0:\n        print(f\"  {label}: cached ({dest.stat().st_size / MB:.1f} MB)\")\n        return dest\n\n    req = urllib.request.Request(url, headers={\"User-Agent\": \"corpus-fetcher/1.0\"})\n```", "response": "    with urllib.request.urlopen(req, timeout=120) as resp:\n        total = int(resp.headers.get(\"Content-Length\") or 0)\n        done = 0\n        last = 0.0\n        with dest.open(\"wb\") as fh:\n            while True:\n                chunk = resp.read(1 << 20)\n                if not chunk:\n                    break\n                fh.write(chunk)\n                done += len(chunk)\n                now = time.time()\n                if now - last > 2:\n                    last = now\n                    pct = f\" {done / total * 100:5.1f}%\" if total else \"\"\n                    print(f\"  {label}: {done / MB:7.1f} MB{pct}\", end=\"\\r\", flush=True)\n    print(f\"  {label}: {done / MB:.1f} MB downloaded\")\n    return dest", "source_file": "fetch_datasets.py", "function_name": "download", "class_name": null, "line_start": 52, "line_end": 76, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def __init__(self, path: Path, target_bytes: int, seen: set[str], min_len: int = 40) -> None:\n        self.path = path\n        self.target = target_bytes\n        self.seen = seen\n```", "response": "        self.min_len = min_len\n        self.bytes = 0\n        self.docs = 0\n        path.parent.mkdir(parents=True, exist_ok=True)\n        self.fh = path.open(\"w\", encoding=\"utf-8\", newline=\"\\n\")", "source_file": "fetch_datasets.py", "function_name": "__init__", "class_name": "Writer", "line_start": 82, "line_end": 90, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def add(self, text: str) -> bool:\n        \"\"\"Append one document. Returns False when the byte budget is full.\"\"\"\n        if self.done():\n            return False\n        if not text:\n            return True\n        text = text.strip()\n        if len(text) < self.min_len:\n            return True\n```", "response": "        key = text[:200]\n        if key in self.seen:\n            return True\n        self.seen.add(key)\n        line = json.dumps({\"text\": text}, ensure_ascii=False) + \"\\n\"\n        self.fh.write(line)\n        self.bytes += len(line.encode(\"utf-8\"))\n        self.docs += 1\n        return not self.done()", "source_file": "fetch_datasets.py", "function_name": "add", "class_name": "Writer", "line_start": 92, "line_end": 109, "license": "mit", "source": "SadikAI project"}
{"task": "code_explanation", "language": "python", "instruction": "Explain what this Python method does.\n\n```python\ndef add(self, text: str) -> bool:\n        \"\"\"Append one document. Returns False when the byte budget is full.\"\"\"\n        if self.done():\n            return False\n        if not text:\n            return True\n        text = text.strip()\n        if len(text) < self.min_len:\n            return True\n        key = text[:200]\n        if key in self.seen:\n            return True\n        self.seen.add(key)\n        line = json.dumps({\"text\": text}, ensure_ascii=False) + \"\\n\"\n        self.fh.write(line)\n        self.bytes += len(line.encode(\"utf-8\"))\n        self.docs += 1\n        return not self.done()\n```", "response": "Append one document. Returns False when the byte budget is full.", "source_file": "fetch_datasets.py", "function_name": "add", "class_name": "Writer", "line_start": 92, "line_end": 109, "license": "mit", "source": "SadikAI project"}
{"task": "code_generation", "language": "python", "instruction": "Write a Python method `Writer.add(self, text: str)` that does the following:\n\nAppend one document. Returns False when the byte budget is full.\n\nReturn only the Python code.", "response": "def add(self, text: str) -> bool:\n        \"\"\"Append one document. Returns False when the byte budget is full.\"\"\"\n        if self.done():\n            return False\n        if not text:\n            return True\n        text = text.strip()\n        if len(text) < self.min_len:\n            return True\n        key = text[:200]\n        if key in self.seen:\n            return True\n        self.seen.add(key)\n        line = json.dumps({\"text\": text}, ensure_ascii=False) + \"\\n\"\n        self.fh.write(line)\n        self.bytes += len(line.encode(\"utf-8\"))\n        self.docs += 1\n        return not self.done()", "source_file": "fetch_datasets.py", "function_name": "add", "class_name": "Writer", "line_start": 92, "line_end": 109, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef parquet_texts(path: Path, columns: list[str]):\n    import pyarrow.parquet as pq\n```", "response": "    pf = pq.ParquetFile(path)\n    for batch in pf.iter_batches(batch_size=256, columns=columns):\n        for row in batch.to_pylist():\n            yield row", "source_file": "fetch_datasets.py", "function_name": "parquet_texts", "class_name": null, "line_start": 124, "line_end": 130, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef fetch_english(out: Path, mb: float, seen: set[str]) -> None:\n    if mb <= 0:\n        return\n    print(f\"English: Gutenberg books ({mb:.1f} MB)\")\n    w = Writer(out / \"english\" / \"gutenberg.jsonl\", int(mb * MB), seen)\n    cache = Path(\"data/cache/gutenberg\")\n\n    header = re.compile(\n        r\"\\*\\*\\*\\s*START OF (THE|THIS) PROJECT GUTENBERG EBOOK.*?\\*\\*\\*\", re.S | re.I\n    )\n    footer = re.compile(\n        r\"\\*\\*\\*\\s*END OF (THE|THIS) PROJECT GUTENBERG EBOOK.*\", re.S | re.I\n    )\n```", "response": "    for gid in GUTENBERG_IDS:\n        if w.done():\n            break\n        try:\n            path = download(\n                f\"https://www.gutenberg.org/cache/epub/{gid}/pg{gid}.txt\",\n                cache / f\"pg{gid}.txt\",\n                f\"book {gid}\",\n            )\n        except Exception as exc:\n            print(f\"  book {gid}: {exc}\")\n            continue\n        raw = path.read_text(encoding=\"utf-8\", errors=\"ignore\")\n        raw = header.sub(\"\", raw)\n        raw = footer.sub(\"\", raw)\n        for block in re.split(r\"\\n\\s*\\n\\s*\\n\", raw):\n            block = block.strip()\n            if len(block) > 200:\n                if not w.add(block):\n                    break\n    w.close()", "source_file": "fetch_datasets.py", "function_name": "fetch_english", "class_name": null, "line_start": 134, "line_end": 168, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef fetch_hindi(out: Path, mb: float, seen: set[str]) -> None:\n    if mb <= 0:\n        return\n    print(f\"Hindi: Hindi Wikipedia ({mb:.1f} MB)\")\n```", "response": "    path = download(HINDI_URL, Path(\"data/cache/hi_wiki.parquet\"), \"hindi wiki\")\n    w = Writer(out / \"hindi\" / \"wikipedia_hi.jsonl\", int(mb * MB), seen)\n    for row in parquet_texts(path, [\"text\"]):\n        if not w.add(row.get(\"text\") or \"\"):\n            break\n    w.close()", "source_file": "fetch_datasets.py", "function_name": "fetch_hindi", "class_name": null, "line_start": 171, "line_end": 180, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef fetch_hinglish(out: Path, mb: float, seen: set[str]) -> None:\n    if mb <= 0:\n        return\n    print(f\"Hinglish: L3Cube Hinglish tweets ({mb:.1f} MB)\")\n    path = download(HINGLISH_URL, Path(\"data/cache/hinglish.parquet\"), \"hinglish\")\n    w = Writer(out / \"hinglish\" / \"l3cube.jsonl\", int(mb * MB), seen, min_len=12)\n    marker = re.compile(r\"###\\s*Hinglish\\s*:\", re.I)\n```", "response": "    for row in parquet_texts(path, [\"text\"]):\n        text = row.get(\"text\") or \"\"\n        m = marker.search(text)\n        if m:\n            text = text[m.end() :]\n        text = text.replace(\"</s>\", \" \").strip()\n        if not w.add(text):\n            break\n    w.close()", "source_file": "fetch_datasets.py", "function_name": "fetch_hinglish", "class_name": null, "line_start": 183, "line_end": 198, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef fetch_code(out: Path, mb: float, seen: set[str]) -> None:\n    if mb <= 0:\n        return\n    stdlib = Path(sysconfig.get_paths()[\"stdlib\"])\n    roots = [stdlib, Path(__file__).resolve().parent]\n    print(f\"Code: Python sources from {stdlib} ({mb:.1f} MB)\")\n    w = Writer(out / \"code\" / \"python.jsonl\", int(mb * MB), seen)\n    skip = {\"site-packages\", \"test\", \"tests\", \"__pycache__\", \"idlelib\", \"lib2to3\", \"tkinter\"}\n    files = 0\n```", "response": "    for root in roots:\n        for dirpath, dirnames, filenames in os.walk(root):\n            dirnames[:] = [d for d in dirnames if d.lower() not in skip]\n            for name in filenames:\n                if not name.endswith((\".py\", \".pyi\")):\n                    continue\n                if w.done():\n                    break\n                p = Path(dirpath) / name\n                try:\n                    if p.stat().st_size > 200_000:\n                        continue\n                    text = p.read_text(encoding=\"utf-8\", errors=\"ignore\")\n                except OSError:\n                    continue\n                files += 1\n                if not w.add(f\"# {p.name}\\n{text}\"):\n                    break\n            if w.done():\n                break\n        if w.done():\n            break\n    print(f\"  scanned {files:,} python files\")\n    w.close()", "source_file": "fetch_datasets.py", "function_name": "fetch_code", "class_name": null, "line_start": 201, "line_end": 233, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef main() -> None:\n    ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)\n    ap.add_argument(\"--out\", default=\"data/raw\")\n    ap.add_argument(\"--english-mb\", type=float, default=10)\n    ap.add_argument(\"--hindi-mb\", type=float, default=8)\n    ap.add_argument(\"--hinglish-mb\", type=float, default=4)\n    ap.add_argument(\"--code-mb\", type=float, default=8)\n    args = ap.parse_args()\n\n    out = Path(args.out)\n    out.mkdir(parents=True, exist_ok=True)\n    seen: set[str] = set()\n    total = args.english_mb + args.hindi_mb + args.hinglish_mb + args.code_mb\n```", "response": "    print(f\"building ~{total:.1f} MB corpus in {out}/ \"\n          f\"(en {args.english_mb}, hi {args.hindi_mb}, hinglish {args.hinglish_mb}, code {args.code_mb})\\n\")\n    started = time.time()\n    fetch_english(out, args.english_mb, seen)\n    fetch_hindi(out, args.hindi_mb, seen)\n    fetch_hinglish(out, args.hinglish_mb, seen)\n    fetch_code(out, args.code_mb, seen)\n\n    print(f\"\\ndone in {time.time() - started:.0f}s\")\n    for d in (\"english\", \"hindi\", \"hinglish\", \"code\"):\n        p = out / d\n        if p.exists():\n            n = sum(f.stat().st_size for f in p.rglob(\"*\") if f.is_file())\n            print(f\"  {d:<9} {n / MB:6.1f} MB\")\n    print(\"\\nnext: python train_tokenizer.py --source files --input data/raw --vocab-size 32768\")", "source_file": "fetch_datasets.py", "function_name": "main", "class_name": null, "line_start": 237, "line_end": 265, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def __init__(self, path: str | Path = \"data/chat/memory.json\") -> None:\n        self.path = Path(path)\n        self.entries: list[Entry] = []\n```", "response": "        self._tokens: list[set[str]] = []\n        self.load()", "source_file": "memory_store.py", "function_name": "__init__", "class_name": "MemoryStore", "line_start": 98, "line_end": 102, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def load(self) -> None:\n        if not self.path.exists():\n            return\n```", "response": "        try:\n            data = json.loads(self.path.read_text(encoding=\"utf-8\"))\n        except (OSError, ValueError):\n            return\n        self.entries = [Entry(**{k: v for k, v in row.items()\n                                 if k in Entry.__dataclass_fields__})\n                        for row in data.get(\"entries\", [])]\n        self._tokens = [_tokens(e.text) for e in self.entries]", "source_file": "memory_store.py", "function_name": "load", "class_name": "MemoryStore", "line_start": 105, "line_end": 115, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def save(self) -> None:\n        self.path.parent.mkdir(parents=True, exist_ok=True)\n        payload = {\n            \"version\": 1,\n            \"saved\": time.time(),\n            \"entries\": [e.to_dict() for e in self.entries[-MAX_ENTRIES:]],\n        }\n```", "response": "        tmp = self.path.with_suffix(\".tmp\")\n        tmp.write_text(json.dumps(payload, ensure_ascii=False, indent=1), encoding=\"utf-8\")\n        os.replace(tmp, self.path)", "source_file": "memory_store.py", "function_name": "save", "class_name": "MemoryStore", "line_start": 117, "line_end": 126, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def add(self, text: str, kind: str = \"turn\", key: str = \"\",\n            emotion: str = \"neutral\", salience: float = 1.0) -> None:\n        text = \" \".join(text.split()).strip()\n        if not text:\n            return\n        norm = text.lower()\n```", "response": "        for i, entry in enumerate(self.entries):\n            if entry.text.lower() == norm and entry.kind == kind and entry.key == key:\n                entry.ts = time.time()\n                entry.salience = max(entry.salience, salience)\n                return\n        self.entries.append(Entry(text=text, kind=kind, key=key,\n                                  emotion=emotion, salience=salience))\n        self._tokens.append(_tokens(text))\n        if len(self.entries) > MAX_ENTRIES:\n            drop = len(self.entries) - MAX_ENTRIES\n            del self.entries[:drop]\n            del self._tokens[:drop]", "source_file": "memory_store.py", "function_name": "add", "class_name": "MemoryStore", "line_start": 129, "line_end": 146, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def forget(self, pattern: str) -> int:\n        needle = pattern.lower().strip()\n        if not needle:\n            return 0\n        keep = [e for e in self.entries if needle not in e.text.lower()]\n```", "response": "        removed = len(self.entries) - len(keep)\n        if removed:\n            self.entries = keep\n            self._tokens = [_tokens(e.text) for e in keep]\n            self.save()\n        return removed", "source_file": "memory_store.py", "function_name": "forget", "class_name": "MemoryStore", "line_start": 154, "line_end": 164, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\n    def recall(self, query: str, k: int = 3) -> list[tuple[Entry, float]]:\n        q = _tokens(query)\n        if not q:\n            return []\n        now = time.time()\n        scored: list[tuple[Entry, float]] = []\n```", "response": "        for entry, toks in zip(self.entries, self._tokens):\n            overlap = len(q & toks)\n            if not overlap:\n                continue\n            score = overlap / math.sqrt(len(q) + 1)\n            age_days = (now - entry.ts) / 86_400\n            score += 0.18 * math.exp(-age_days / 14.0)\n            score += 0.10 * entry.salience / 1.6\n            if entry.kind == \"fact\":\n                score += 0.35\n            scored.append((entry, score))\n        scored.sort(key=lambda pair: pair[1], reverse=True)\n        return [(e, s) for e, s in scored[:k] if s >= 0.12]", "source_file": "memory_store.py", "function_name": "recall", "class_name": "MemoryStore", "line_start": 179, "line_end": 197, "license": "mit", "source": "SadikAI project"}
{"task": "code_completion", "language": "python", "instruction": "Complete the following Python code. Return only the continuation, preserving indentation.\n\n```python\ndef extract_facts(text: str) -> list[tuple[str, str]]:\n    \"\"\"Pull durable facts out of a sentence (name, age, city, likes, ...).\"\"\"\n    found: list[tuple[str, str]] = []\n```", "response": "    for key, pattern in FACT_PATTERNS:\n        for match in re.finditer(pattern, text, flags=re.IGNORECASE):\n            value = _clean_value(match.group(1))\n            if not value or value in FACT_STOP or len(value) > 60:\n                continue\n            if key == \"age\":\n                age = int(value)\n                if not (1 <= age <= 120):\n                    continue\n            if key == \"name\" and value.split()[0] in {\"a\", \"an\", \"the\", \"not\"}:\n                continue\n            if (key, value) not in found:\n                found.append((key, value))\n    return found", "source_file": "memory_store.py", "function_name": "extract_facts", "class_name": null, "line_start": 214, "line_end": 230, "license": "mit", "source": "SadikAI project"}
{"task": "code_explanation", "language": "python", "instruction": "Explain what this Python function does.\n\n```python\ndef extract_facts(text: str) -> list[tuple[str, str]]:\n    \"\"\"Pull durable facts out of a sentence (name, age, city, likes, ...).\"\"\"\n    found: list[tuple[str, str]] = []\n    for key, pattern in FACT_PATTERNS:\n        for match in re.finditer(pattern, text, flags=re.IGNORECASE):\n            value = _clean_value(match.group(1))\n            if not value or value in FACT_STOP or len(value) > 60:\n                continue\n            if key == \"age\":\n                age = int(value)\n                if not (1 <= age <= 120):\n                    continue\n            if key == \"name\" and value.split()[0] in {\"a\", \"an\", \"the\", \"not\"}:\n                continue\n            if (key, value) not in found:\n                found.append((key, value))\n    return found\n```", "response": "Pull durable facts out of a sentence (name, age, city, likes, ...).", "source_file": "memory_store.py", "function_name": "extract_facts", "class_name": null, "line_start": 214, "line_end": 230, "license": "mit", "source": "SadikAI project"}
{"task": "code_generation", "language": "python", "instruction": "Write a Python function `extract_facts(text: str)` that does the following:\n\nPull durable facts out of a sentence (name, age, city, likes, ...).\n\nReturn only the Python code.", "response": "def extract_facts(text: str) -> list[tuple[str, str]]:\n    \"\"\"Pull durable facts out of a sentence (name, age, city, likes, ...).\"\"\"\n    found: list[tuple[str, str]] = []\n    for key, pattern in FACT_PATTERNS:\n        for match in re.finditer(pattern, text, flags=re.IGNORECASE):\n            value = _clean_value(match.group(1))\n            if not value or value in FACT_STOP or len(value) > 60:\n                continue\n            if key == \"age\":\n                age = int(value)\n                if not (1 <= age <= 120):\n                    continue\n            if key == \"name\" and value.split()[0] in {\"a\", \"an\", \"the\", \"not\"}:\n                continue\n            if (key, value) not in found:\n                found.append((key, value))\n    return found", "source_file": "memory_store.py", "function_name": "extract_facts", "class_name": null, "line_start": 214, "line_end": 230, "license": "mit", "source": "SadikAI project"}