-
Notifications
You must be signed in to change notification settings - Fork 45
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
Adds GenAI client object #1
Conversation
neo4j_genai/src/client.py
Outdated
List[Dict[str, Any]]: List of dictionaries containing the query results. | ||
""" | ||
params = params or {} | ||
with driver.session() as session: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the proper usage for the driver? I have seen in other places where the database
needs to be passed to session e.g.
with driver.session(database="neo4j") as session:
Is this necessarily the case?
neo4j_genai/src/client.py
Outdated
List[Dict[str, Any]]: List of dictionaries containing the query results. | ||
""" | ||
params = params or {} | ||
with driver.session() as session: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are passing the driver all around the code. Why not just set it in the __init__
and do with self.driver.session()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we initially decided this during the design phase so that it is more explicit, right? I do think setting in __init__
is more readable and Pythonic though. I would prefer to do it like you suggested here
@jonbesga Oskar and I discussed earlier today that we want to add this behaviour for allowing users to give more "advanced" queries where they also pass in a Cypher query string as seen in:
I don't think this should be part of this PR, but I think it's good to include this in the first version of this package, what do you think? |
I'm confused what behaviour are your referring to😅 |
src/neo4j_genai/types.py
Outdated
@root_validator(pre=True) | ||
def check_query(cls, values): | ||
query_vector, query_text = values.get("query_vector"), values.get("query_text") | ||
if bool(query_vector) ^ bool(query_text): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ^
operator only works with booleans
Can you squash all the commits into one? |
I've now set the default for merging PRs to be 'Squash and merge', so on the base branch it will be squashed |
name: str | ||
label: str | ||
property: str | ||
dimensions: int = Field(ge=1, le=2048) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will change to 4096
in the next neo4j v5.18 release, so we will need to make this change in future
Validates that one of either query_vector or query_text is provided exclusively. | ||
""" | ||
query_vector, query_text = values.get("query_vector"), values.get("query_text") | ||
if not (bool(query_vector) ^ bool(query_text)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ^
Python operator only works for booleans
def __init__( | ||
self, | ||
driver: Driver, | ||
embeddings: Optional[Embeddings] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider embedding instead of embeddings? This could be confusing because it could mean embedding the noun instead of the verb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Embedder as seen in haystack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both class and argument
Returns: | ||
List[Dict[str, Any]]: List of dictionaries containing the query results. | ||
""" | ||
with self.driver.session() as session: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use execute_query
as seen in https://neo4j.com/docs/api/python-driver/current/
Description
Adds
GenAIClient
to create indexes, drops indexes, and perform similarity search on a Neo4j database. Also contains pre-commit configuration.Checklist
Configure pre-commit-configHandled in Jonbesga/tests #2Testing
Unit tests passTests are on another PR (Jonbesga/tests #2)