Skip to content

Solved for "TypeError: issubclass() arg 1 must be a class" when using typing.Literal in embedding.py#64

Open
Jupiter1995 wants to merge 3 commits intoGentopia-AI:mainfrom
Jupiter1995:main
Open

Solved for "TypeError: issubclass() arg 1 must be a class" when using typing.Literal in embedding.py#64
Jupiter1995 wants to merge 3 commits intoGentopia-AI:mainfrom
Jupiter1995:main

Conversation

@Jupiter1995
Copy link

Description

It will solve the TypeError caused by using typing.Literal in embedding.py because of the forward reference mechanism. Original Error screenshot is attached.
Screenshot 2023-11-26 at 6 29 45 PM

Solution

Creating a new class with enum.Enum for the literal value to bypass this error, as Literal cannot be subclassed and will cause the TypeError issue mentioned above. The modified parts were screenshots and attached below.
Screenshot 2023-11-26 at 6 32 48 PM

Example

Screenshot 2023-11-26 at 9 08 12 PM

Misc

(Links, notes, @people, etc.)

Inspired by this post

@Jupiter1995
Copy link
Author

fix issue #64

@Jupiter1995 Jupiter1995 marked this pull request as draft May 31, 2024 19:29
@Jupiter1995 Jupiter1995 marked this pull request as ready for review May 31, 2024 19:30
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.

1 participant