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

bug: PyCharm - incorrect import suggestions for schemas #279

Closed
Tomas2D opened this issue Jan 23, 2024 · 4 comments
Closed

bug: PyCharm - incorrect import suggestions for schemas #279

Tomas2D opened this issue Jan 23, 2024 · 4 comments
Assignees
Labels
bug Something isn't working high priority

Comments

@Tomas2D
Copy link
Member

Tomas2D commented Jan 23, 2024

Currently, the PyCharm suggests importing re-exported schemas from an incorrect module.

For instance: TextGenerationParamters should be imported from genai.text.generation, but PyCharm suggests importing it from the genai._generated.api which is not desired.

@Tomas2D Tomas2D added bug Something isn't working high priority labels Jan 23, 2024
@jezekra1
Copy link
Member

jezekra1 commented Jan 26, 2024

The proposed solution:

  1. Unify all schemas into a single file, instead of distributed imports per service:
    Instead of from genai.text.generation import DecodingMethod -> from genai.schema import DecodingMethod.
  2. Structure of the schemas:
genai
  |- schemas
     |- __init__.py
        _api.py
        _endpoints.py
        _extensions.py 
  • _api.py will be divided to public and private schemas (prefixed with _) already in the generator
  • __init__.py:
    • will export all public schemas from _api.py (from _api import * hides private classes by default)
    • will export everything from _extensions.py which allow defining classes not generated (e.g HumanMessage)
    • can be used to modify a schema -> (import MySchema from _api as MySchema_, modify and reexport under original name)
  1. Add public schemas to generator config and modify behavior to make all private by default
  2. rewrite all examples and documentation to use from genai.schema imports
  3. modify sevice-local schemas:
  • .schema files (genai/text/generation/schema.py) will now just be an alias for genai.schema
  • show deprecation warning: "Use from genai.schema import ... instead of genai.text.generation.schema

Side-effect:

  • if people were using the old unsupported way (from genai._generated.api import ...), their code will break. We could add yet another alias to schemas and deprecation warning if necessary, but the _ already indicated they were doing something wrong so I'd just mention it in the changelog

jezekra1 added a commit that referenced this issue Jan 29, 2024
Ref: #279

Signed-off-by: Radek Ježek <pc.jezek@gmail.com>
jezekra1 added a commit that referenced this issue Jan 29, 2024
Ref: #279

Signed-off-by: Radek Ježek <pc.jezek@gmail.com>
@Owaiskhan9654
Copy link

Is this a known issue in ibm-generative-ai==2.0.0? I updated this package and using the new migration code.
@Tomas2D @jezekra1

image

@jezekra1
Copy link
Member

The version containing these changes hasn't been released yet, you're probably looking at the unreleased version of the documentation.

Please use the old migration guide for now or wait till the next release

https://ibm.github.io/ibm-generative-ai/v2.0.0/v2_migration_guide.html

@Tomas2D
Copy link
Member Author

Tomas2D commented Jan 30, 2024

Released in v2.1.0

@Tomas2D Tomas2D closed this as completed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

3 participants