Skip to content
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

fix storeindex cosmosnosql query issue - (BadRequest) One of the inpu… #17385

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nqtung
Copy link

@nqtung nqtung commented Dec 28, 2024

Fix the CosmosNoSQL query parameter and update dependencies version llama-index-core = "^0.12.0"

Fixes # (17384) - #17384

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • [ x] No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • [x ] Yes
  • No

Type of Change

Please delete options that are not relevant.

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • [ x] I believe this change is already covered by existing unit tests

Suggested Checklist:

  • [ x] I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • [ x] New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 28, 2024
@@ -325,25 +325,31 @@ def _query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResu

# If limit_offset_clause is not specified, add TOP clause
if pre_filter is None or pre_filter.get("limit_offset_clause") is None:
query += "TOP @limit "
# query += "TOP @limit "
query += f"TOP {params.get('k', 2)} "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally if you are making a change, we just remove the old code, don't comment it out

@@ -325,25 +325,31 @@ def _query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResu

# If limit_offset_clause is not specified, add TOP clause
if pre_filter is None or pre_filter.get("limit_offset_clause") is None:
query += "TOP @limit "
# query += "TOP @limit "
query += f"TOP {params.get('k', 2)} "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious, can you give some explanation on this change? This seems to be changing a lot of the query text


# Add limit_offset_clause if specified
if pre_filter is not None and pre_filter.get("limit_offset_clause") is not None:
query += " {}".format(pre_filter["limit_offset_clause"])
parameters = [
{"name": "@limit", "value": params["k"]},
{"name": "@embeddingKey", "value": self._embedding_key},
# {"name": "@limit", "value": params["k"]},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the limit param?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use clear limit value in query, we dont need to pass @limit as parameter

{"name": "@limit", "value": params["k"]},
{"name": "@embeddingKey", "value": self._embedding_key},
# {"name": "@limit", "value": params["k"]},
# {"name": "@embeddingKey", "value": self._embedding_key},
{"name": "@embeddings", "value": params["vector"]},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params["vector"] is not the same as self._embedding_key? looking at line 316 above

params: Dict[str, Any] = {
            "vector": query.query_embedding,
            "path": self._embedding_key,
            "k": query.similarity_top_k,
        }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot use the parameter @embeddingKey for container field name in the query. in the query we need to use clear field name c.embeding instead of c.@embeddingKey

@limit will process default 2 if there is no value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants