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

Ewiz sql #18

Merged
merged 12 commits into from
May 30, 2024
Merged

Ewiz sql #18

merged 12 commits into from
May 30, 2024

Conversation

spodgorny9
Copy link
Collaborator

Adding code to access postgres vector database and generate query embeddings from AWS. Also includes try_import utility.


Returns
-------
p : package
Copy link
Member

Choose a reason for hiding this comment

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

This function doesn't return anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doesn't this return the import? p = importlib.import_module(package_name) return p

Copy link
Member

Choose a reason for hiding this comment

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

oh sorry! it does. I missed the return statement nested in there. looks fine

elm/utilities/try_import.py Outdated Show resolved Hide resolved
elm/wizard.py Outdated Show resolved Hide resolved
elm/wizard.py Outdated Show resolved Hide resolved
elm/wizard.py Show resolved Hide resolved
elm/wizard.py Outdated Show resolved Hide resolved

body = json.dumps({"inputText": text, })

model_id = self.EMBEDDING_MODEL
Copy link
Member

Choose a reason for hiding this comment

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

Is this supposed to be the titan model name? Seems like this will still be 'text-embedding-ada-002' based on the ApiBase class. I think you need to set the class variable for this class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@grantbuster When I create the wizard object in the run_app.py code I set the model_id using EnergyWizardPostgres.EMBEDDING_MODEL = 'amazon.titan-embed-text-v1' and that seems to do the trick. I was thinking doing it that way would be most consistent with the existing code, would it be better to set the class variable?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should set the class variable because in the get embedding method we hard-code the call to the AWS object, right?

In the docstring we may want to have a description of how this is designed, e.g.:

vector database - postgresql with psycopg2
embedding model - aws titan
llm - GPT4 via Azure deployment

elm/wizard.py Outdated Show resolved Hide resolved
elm/wizard.py Outdated Show resolved Hide resolved
@grantbuster
Copy link
Member

@spodgorny9 can you also add a test for the new class? Please mock the postgres responses.

elm/wizard.py Outdated Show resolved Hide resolved

@staticmethod
def ref_call(*args, **kwargs): # pylint: disable=unused-argument
"""Mock for EnergyWizardPostgres.make_ref_list()"""
Copy link
Member

Choose a reason for hiding this comment

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

This is fine but i was hoping you would mock the psycopg2/boto3 objects and not our methods. Ideally you want to preserve as much of our code as possible and only mock the functions in the dependencies that we cannot call in the test env

tests/test_postgres.py Outdated Show resolved Hide resolved
Copy link
Member

@grantbuster grantbuster left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for working through this with me.

@spodgorny9 spodgorny9 merged commit fa0f871 into main May 30, 2024
12 checks passed
@spodgorny9 spodgorny9 deleted the ewiz_sql branch May 30, 2024 20:02
github-actions bot pushed a commit that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants