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/add encoder openai #1441

Closed

Conversation

thejumpman2323
Copy link
Contributor

Description

Related Issues

Checklist

  • Is this code covered by new or existing unit tests or integration tests?
  • Did you run make test successfully?
  • Do new classes, functions, methods and parameters all have docstrings?
  • Were existing docstrings updated, if necessary?
  • Was external documentation updated, if necessary?

Additional Notes or Comments

@@ -151,6 +153,9 @@ class OpenAIChatCompletion(OpenAI):
takes_context: bool = True
prompt: str = ''

def __post_init__(self):
self.encoder = dtype('str')
Copy link
Collaborator

Choose a reason for hiding this comment

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

if self.encoder is None

Copy link
Collaborator

Choose a reason for hiding this comment

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

(users could add post-processing and a custom Encoder)

@@ -316,6 +324,9 @@ class OpenAIImageEdit(OpenAI):
takes_context: bool = True
prompt: str = ''

def __post_init__(self):
self.encoder = pil_image
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will break since the output of those models is currently bytes. So you would need to handle that or change the default output type. I would suggest the 2nd for simplicity.

Copy link
Collaborator

@jieguangzhou jieguangzhou left a comment

Choose a reason for hiding this comment

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

we need to create table for ibis in post_create func
https://github.com/SuperDuperDB/superduperdb/pull/1436#discussion_r1412303263

@@ -151,6 +153,9 @@ class OpenAIChatCompletion(OpenAI):
takes_context: bool = True
prompt: str = ''

def __post_init__(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We just need to add a default str encoder for ibis, do not need in mongodb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I just realised after talking with @blythed

Copy link
Collaborator

@blythed blythed Dec 2, 2023

Choose a reason for hiding this comment

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

This could be handled with Model.pre_create:

def pre_create(self, db):
    if isinstance(db.databackend, IbisBackend) and self.Encoder is None:
        self.encoder = dtype('str')

Then we can tell if we're in the ibis situation or not.

@thejumpman2323 thejumpman2323 force-pushed the fix/add_encoder_openai branch 5 times, most recently from 2feb387 to 6870bd9 Compare December 2, 2023 19:23
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (34830a7) 80.33% compared to head (e468d45) 80.63%.
Report is 165 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1441      +/-   ##
==========================================
+ Coverage   80.33%   80.63%   +0.29%     
==========================================
  Files          95      104       +9     
  Lines        6602     7235     +633     
==========================================
+ Hits         5304     5834     +530     
- Misses       1298     1401     +103     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -215,6 +222,11 @@ class OpenAIImageCreation(OpenAI):
takes_context: bool = True
prompt: str = ''

def __post_init__(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use pre_create.

Copy link
Collaborator

@blythed blythed left a comment

Choose a reason for hiding this comment

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

Please use pre_create and use dtype

@blythed
Copy link
Collaborator

blythed commented Dec 2, 2023

we need to create table for ibis in post_create func #1436 (comment)

I would suggest add the logic to create the table in Predictor not in Model, then you can call if in Model and in OpenAI etc.. I seems like there is some tidying up work to do here.

@jieguangzhou
Copy link
Collaborator

#1444 This PR solves the same problem.

We need to use the simply method to hotfix this quickly for the launch.
Then, Let’s optimize the logic of the Encoder in 0.2 #1310

Comment on lines +3 to +19
int_type = Encoder(
identifier='int',
encoder=lambda x: int(x),
)
float_type = Encoder(
identifier='float',
encoder=lambda x: float(x),
)
str_type = Encoder(
identifier='str',
encoder=lambda x: str(x),
)

bool_type = Encoder(
identifier='bool',
encoder=lambda x: bool(x),
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, I added a discussion about this #1446

@thejumpman2323
Copy link
Contributor Author

duplicate #1444

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.

5 participants