feat: added Grok as a provider and related functionality#45
feat: added Grok as a provider and related functionality#45johnny-emp merged 13 commits intomainfrom
Conversation
ahmedhamedaly
commented
Apr 6, 2025
- Updated imports to include GrokProvider in init.py files.
- Added to_grok method in GenericTool class for converting to Grok tool format.
- Included GrokModelType in the providers' all list.
- Updated imports to include GrokProvider in __init__.py files. - Added to_grok method in GenericTool class for converting to Grok tool format. - Included GrokModelType in the providers' __all__ list.
|
90% of your code is copied and pasted, please try to use class inheritance |
| from .types import GrokModelType | ||
|
|
||
|
|
||
| class Request(BaseModel): |
There was a problem hiding this comment.
this looks like it can mostly inherit from OpenAI, is there a reason to not inherit from the OpenAI implementation?
There was a problem hiding this comment.
It also might be better to make a generic type that takes an argument for the ModelType, ie.
ModelType = TypeVar("ModelType")
class StandardRequest(Generic[ModelType]):
model: ModelTypeand then it can be used by all platforms that mimic the openai format
|
I made a small PR to this branch fixing a couple type issues, this should help by simplifying the tools type: #46 |
| ), | ||
| ) | ||
|
|
||
| def to_grok(self): |
There was a problem hiding this comment.
we actually don't need this anymore, since we inverted controls to Providers
|
|
||
| tools: Annotated[ | ||
| Optional[list[GenericTool]], | ||
| PlainSerializer( |
There was a problem hiding this comment.
same with this, I believe we can remove the PlainSerializer. I was trying to use Annotations for the serialization initially, but it became simpler to just define the Tool format per provider. Basically we switched to utilize IOC https://en.wikipedia.org/wiki/Inversion_of_control but there's still some relics of the earlier solution.
|
a couple small comments, but this looks great now. Thanks for the hard work! |
246fd2a to
4c8b488
Compare