cleaned up the code to support different embedding model#36
Merged
wolfdancer merged 2 commits intomainfrom Apr 6, 2025
Merged
Conversation
src/innieme/document_processor.py
Outdated
Comment on lines
15
to
17
| def __init__(self, docs_dir, embedding_config={}): | ||
| self.docs_dir = docs_dir | ||
| self.embedding_type = embedding_type | ||
| self.embedding_config = embedding_config or {} | ||
| self.embedding_config = embedding_config |
There was a problem hiding this comment.
Using a mutable default argument for embedding_config can lead to unexpected behavior. Consider using None as the default value and initializing with {} inside the method.
| # Only import if needed | ||
| from langchain_openai import OpenAIEmbeddings | ||
| api_key = self.embedding_config.get("api_key", os.getenv("OPENAI_API_KEY")) | ||
| api_key = self.embedding_config["api_key"] |
There was a problem hiding this comment.
Removing the fallback using os.getenv may lead to a KeyError when the API key is not provided. Consider restoring fallback behavior by using self.embedding_config.get('api_key', os.getenv('OPENAI_API_KEY')).
Suggested change
| api_key = self.embedding_config["api_key"] | |
| api_key = self.embedding_config.get('api_key', os.getenv('OPENAI_API_KEY')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.