-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add search_kwargs
when using CustomComponent to create a vectorstore
#1323
Comments
🤖 Hey @wodadehencou, good to see you again! Hope you're doing well. Let's dive into your issue. To add a Here's how you can do it: def build(
self,
vectorstore: VectorStore,
document_content_description: str,
llm: BaseLanguageModel,
metadata_field_info: List[str],
search_kwargs: dict = None, # Add this line
) -> BaseRetriever:
metadata_field_obj = []
for meta in metadata_field_info:
meta_obj = json.loads(meta)
if 'name' not in meta_obj or 'description' not in meta_obj or 'type' not in meta_obj :
raise Exception('Incorrect metadata field info format.')
attribute_info = AttributeInfo(
name = meta_obj['name'],
description = meta_obj['description'],
type = meta_obj['type'],
)
metadata_field_obj.append(attribute_info)
return SelfQueryRetriever.from_llm(
llm,
vectorstore,
document_content_description,
metadata_field_obj,
verbose=True,
search_kwargs=search_kwargs # Add this line
) In the above code, I added a new parameter You can refer to the VectaraSelfQueryRetriver.py file for more details. As for the structure of the I hope this helps! If you have any other questions, feel free to ask. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
VectaraSelfQueryRetriver.py is something like a converter to convert an exist VectorStore to Retrieval, it is like the earlier Langflow version did, every vectorstore has a corresponding But today, I think almost every vectorstore component can act as a |
Hi, @wodadehencou, I'm helping the langflow team manage their backlog and am marking this issue as stale. From what I understand, you were having trouble adding Could you please confirm if this issue is still relevant to the latest version of the langflow repository? If it is, please let the langflow team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days. Thank you for your understanding and cooperation. If you have any further questions or need assistance with anything else, feel free to reach out. |
I want to add a custom vectorstore, like in
src/backend/langflow/components/vectorstores/Chroma.py
did.build method return type is
Union[VectorStore, BaseRetriever]
, but the actual code is return a Chroma instance.If the next component need a Retrieval,
.as_retrieval()
function is auto called when building the graph.If I want to control the retrieval policy, like k or score, I need to add a
search_kwargs
parameter toas_retrieval
.I want to config k or score parameter to my custom vectorstore, but I find it difficult to do it.
The text was updated successfully, but these errors were encountered: