langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Weaviate python library doesn't have needed methods for the abstractions

Open Ryangr0 opened this issue 1 year ago • 1 comments

Using

langchain~=0.0.146
openai~=0.27.4
haystack~=0.42
tiktoken~=0.3.3
weaviate-client~=3.15.6
aiohttp~=3.8.4
aiodns~=3.0.0
python-dotenv~=1.0.0
Jinja2~=3.1.2
pandas~=2.0.0
def create_new_memory_retriever():
    """Create a new vector store retriever unique to the agent."""

    client = weaviate.Client(
        url=WEAVIATE_HOST,
        additional_headers={"X-OpenAI-Api-Key": os.getenv("OPENAI_API_KEY")},
        # auth_client_secret: Optional[AuthCredentials] = None,
        # timeout_config: Union[Tuple[Real, Real], Real] = (10, 60),
        # proxies: Union[dict, str, None] = None,
        # trust_env: bool = False,
        # additional_headers: Optional[dict] = None,
        # startup_period: Optional[int] = 5,
        # embedded_options=[],
    )
    embeddings_model = OpenAIEmbeddings()

    vectorstore = Weaviate(client, "Paragraph", "content", embedding=embeddings_model.embed_query)
    
    return TimeWeightedVectorStoreRetriever(vectorstore=vectorstore, other_score_keys=["importance"], k=15)  

Time weighted retriever

...
    def get_salient_docs(self, query: str) -> Dict[int, Tuple[Document, float]]:
        """Return documents that are salient to the query."""
        docs_and_scores: List[Tuple[Document, float]]
        docs_and_scores = self.vectorstore.similarity_search_with_relevance_scores( <----------======
            query, **self.search_kwargs
        )
        results = {}
        for fetched_doc, relevance in docs_and_scores:
            buffer_idx = fetched_doc.metadata["buffer_idx"]
            doc = self.memory_stream[buffer_idx]
            results[buffer_idx] = (doc, relevance)
        return results
...

similarity_search_with_relevance_scores is not in the weaviate python client.

Whose responsibility is this? Langchains? Weaviates? I'm perfectly fine to solve it but I just need to know on whose door to knock.

All of langchains vectorstores have different methods under them and people are writing implementation for all of them. I don't know how maintainable this is gonna be.

Ryangr0 avatar Apr 22 '23 19:04 Ryangr0

For posterity, discussion took place here: Weaviate repo

Ryangr0 avatar Apr 22 '23 23:04 Ryangr0

Hi, @Ryangr0! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue you raised was about the missing similarity_search_with_relevance_scores method in the Weaviate Python library. It seems that the issue has been resolved, as you were directed to address it in the Weaviate repository issue #2935.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project!

dosubot[bot] avatar Sep 02 '23 16:09 dosubot[bot]