-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Xinference add #4249
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: Xinference add #4249
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ class XInferenceSpeechToText(MaxKBBaseModel, BaseSpeechToText): | |
| api_base: str | ||
| api_key: str | ||
| model: str | ||
| params: dict | ||
|
|
||
| def __init__(self, **kwargs): | ||
| super().__init__(**kwargs) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet for Here's an updated version of the class with corrections and additional comments: from abc import ABC, abstractmethod
import max_kb_base_model # Assuming this module exists
class MaxKBBaseModel(ABC):
@abstractmethod
def process(self):
pass
class BaseSpeechToText(ABC):
@abstractmethod
def transcribe(self, audio_file):
pass
class XInferenceSpeechToText(MaxKBBaseModel, BaseSpeechToText):
api_base: str
api_key: str
model: str
params: dict # Initialize params in __init__ method
def __init__(self, **kwargs):
super().__init__()
self.api_base = kwargs.get('api_base', 'default_url')
self.api_key = kwargs.get('api_key', '')
self.model = kwargs.get('model', 'default_model')
self.params = kwargs.get('params', {}) # Default to an empty dictionary if none provided
print(f"Initialized {type(self).__name__} instance with API base: '{self.api_base}', "
f"API key: '{self.api_key}', model: '{self.model}'")
# Example usage:
# inference_stt = XInferenceSpeechToText(api_base='https://example.com/api',
# api_key='your_api_key',
# model='inception_v3')Key Improvements:
This should address any irregularities present in the original code. Let me know if you have any further questions! |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few potential issues, optimizations, and improvements to consider:
Optimize
get_modelcall: The current implementation of theget_modelcall passes three parameters (model_type,model_name, andmodel_credential). If additional keyword arguments may be needed in the future (such as**kwargs), it might make sense to update this method to handle them properly.Clarify
passstatement: In theget_model_params_setting_formfunction, thepassstatement could indicate some functionality that should be implemented later on. It would be better to removereturn:or replace it with an actual implementation when necessary.Consider moving validation logic elsewhere: Currently, all the validation logic is mixed into the main body of the class's methods. This can lead to duplication and reduce readability. Consider extracting these validations to separate functions or classes where they belong more logically.
Here's the updated code snippet incorporating suggested changes:
These changes aim to improve clarity, maintainability, and flexibility in the code while addressing potential runtime errors related to missing keywords and redundant checks.