MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / FakeEmbeddingService

Class FakeEmbeddingService

experiments/tests/test_pdf_parser.py:166–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165def test_infer_research_directions_can_use_embedding_service(monkeypatch):
166 class FakeEmbeddingService:
167 def embed_text(self, text):
168 if "interface automation" in text.lower():
169 return [1.0, 0.0]
170 return [0.0, 1.0]
171
172 def embed_batch(self, texts):
173 embeddings = []
174 for text in texts:
175 if "interface automation" in text.lower() or "computer use" in text.lower():
176 embeddings.append([1.0, 0.0])
177 else:
178 embeddings.append([0.0, 1.0])
179 return embeddings
180
181 def cosine_similarity(self, vector1, vector2):
182 return sum(a * b for a, b in zip(vector1, vector2))
183
184 monkeypatch.setattr(pdf_parser, "_get_embedding_service", lambda: FakeEmbeddingService())
185 monkeypatch.setattr(pdf_parser, "SEMANTIC_DIRECTION_MIN_SIMILARITY", 0.30)

Calls

no outgoing calls