Gentopia-AI / Gentopia

Build Hierarchical Autonomous Agents through Config. Collaborative Growth of Specialized Agents.
MIT License
297 stars 41 forks source link

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

Open Jupiter1995 opened 11 months ago

Jupiter1995 commented 11 months ago

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 commented 5 months ago

fix issue #64