9x25dillon commited on
Commit
e45b3d7
·
verified ·
1 Parent(s): 07725a6

Create adapters/local_gguf_adapter.py

Browse files
Files changed (1) hide show
  1. adapters/local_gguf_adapter.py +22 -0
adapters/local_gguf_adapter.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # adapters/local_gguf_adapter.py
2
+ from typing import List
3
+ from .base import BaseModelAdapter
4
+
5
+ class LocalGGUFAdapter(BaseModelAdapter):
6
+ """
7
+ Interface placeholder for llama.cpp/gguf runners.
8
+ Implement with your local runner; for now, returns simple echoes.
9
+ """
10
+ def __init__(self, model_path="models/llama.gguf", embed_dim=384):
11
+ self.model_path = model_path
12
+ self.dim = embed_dim
13
+
14
+ def generate(self, prompt: str) -> str:
15
+ return f"[gguf:{self.model_path}] {prompt.strip()}"
16
+
17
+ def embed_text(self, text: str) -> List[float]:
18
+ import numpy as np, hashlib
19
+ h = hashlib.md5((self.model_path + "||" + text).encode()).digest()
20
+ seed = int.from_bytes(h[:8], "little")
21
+ rng = np.random.default_rng(seed)
22
+ return rng.standard_normal(self.dim).astype("float32").tolist()