-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add XAI Support #86
base: main
Are you sure you want to change the base?
Add XAI Support #86
Conversation
Pull Request Feedback 🔍
|
try: | ||
import XAi | ||
except ImportError: | ||
print("The XAi module is not installed. Please install it with 'pip install XAi'.") | ||
|
||
try: | ||
self.client = XAi.ClientV2(api_key=self.api_key) | ||
except Exception as e: | ||
raise Exception(f"Failed to initialize XAi client: {str(e)}") |
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.
Suggestion: Ensure that the load_llm
method checks if the XAi
module is successfully imported before attempting to use it, to prevent potential runtime errors. [possible bug]
try: | |
import XAi | |
except ImportError: | |
print("The XAi module is not installed. Please install it with 'pip install XAi'.") | |
try: | |
self.client = XAi.ClientV2(api_key=self.api_key) | |
except Exception as e: | |
raise Exception(f"Failed to initialize XAi client: {str(e)}") | |
try: | |
import XAi | |
except ImportError: | |
print("The XAi module is not installed. Please install it with 'pip install XAi'.") | |
return | |
try: | |
self.client = XAi.ClientV2(api_key=self.api_key) | |
except Exception as e: | |
raise Exception(f"Failed to initialize XAi client: {str(e)}") |
@staticmethod | ||
def load_from_kwargs(self, kwargs: Dict): | ||
model_config = ModelConfig(**kwargs) | ||
self.config = model_config | ||
self.load_llm() | ||
|
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.
Suggestion: Modify the load_from_kwargs
method to avoid using self
as a parameter in a static method, as it is not appropriate and can cause confusion. [best practice]
@staticmethod | |
def load_from_kwargs(self, kwargs: Dict): | |
model_config = ModelConfig(**kwargs) | |
self.config = model_config | |
self.load_llm() | |
@staticmethod | |
def load_from_kwargs(kwargs: Dict): | |
model_config = ModelConfig(**kwargs) | |
instance = XAiModel() | |
instance.config = model_config | |
instance.load_llm() |
model=self.model_name, | ||
messages=[{"role": "user", "content": prompt}] | ||
) | ||
return response.message.content[0].text |
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.
Suggestion: Handle the case where response.message.content
might be empty or not structured as expected to prevent potential index errors in the predict
method. [possible issue]
return response.message.content[0].text | |
if response.message.content: | |
return response.message.content[0].text | |
else: | |
raise Exception("Received an empty response from the model.") |
Description
XAiModel
class to support XAi language models, allowing users to initialize with an API key and model parameters.predict
method to generate responses using the XAi client, enhancing functionality.Changes walkthrough
xAi.py
Add XAiModel class for XAi language model integration
src/beyondllm/llms/xAi.py
XAiModel
for integrating XAi language models.failures.
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.