MCPcopy
hub / github.com/Andyyyy64/whichllm / _substring_search

Function _substring_search

src/whichllm/hardware/gpu_simulator.py:132–151  ·  view source on GitHub ↗

Substring match with word-boundary filtering. e.g. "RTX 3060" should match "GeForce RTX 3060 12 GB" but NOT "GeForce RTX 3060 Ti".

(db, name: str)

Source from the content-addressed store, hash-verified

130
131
132def _substring_search(db, name: str):
133 """Substring match with word-boundary filtering.
134
135 e.g. "RTX 3060" should match "GeForce RTX 3060 12 GB" but NOT "GeForce RTX 3060 Ti".
136 """
137 name_upper = name.upper()
138 candidates = []
139 for db_name in db.names:
140 idx = db_name.upper().find(name_upper)
141 if idx < 0:
142 continue
143 after = db_name[idx + len(name) :]
144 # Accept if nothing follows, or what follows is VRAM/form-factor spec
145 # Reject if a variant suffix follows (Ti, SUPER, Mobile, Max-Q, etc.)
146 if not after or re.match(r"^(\s+(\d|GA\d|PCIe|SXM|NVL|CNX))", after):
147 candidates.append(db_name)
148 if candidates:
149 candidates.sort(key=len)
150 return db[candidates[0]]
151 return None
152
153
154def _lookup_dbgpu(name: str) -> GPUSpecification | None:

Callers 1

_lookup_dbgpuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected