Skip to content

Review: Integration Tests » Fake Embeddings » ConsistentFakeEmbeddings.embed_query #28

@amotl

Description

@amotl

def embed_query(self, text: str) -> List[float]:
"""Return consistent embeddings for the text, if seen before, or a constant
one if the text is unknown."""
if text not in self.known_texts:
return [float(1.0)] * (self.dimensionality - 1) + [float(0.0)]
return [float(1.0)] * (self.dimensionality - 1) + [
float(self.known_texts.index(text))
]

This spot has been resolved differently. We will need to check if that will be fine. Otherwise, we will need to use the previous code on behalf of a separate FakeEmbeddings fixture.

Originally posted by @amotl in #1 (comment)

/cc @kneth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions