-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: hugging face in demo #15
Conversation
LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/demo/main.py The code is generally good, but there are areas for potential improvement.
Here's an example of how you could refactor the API key handling: def get_api_key(user_api_key, model_name, huggingface_api_key, openai_api_key):
if user_api_key:
return user_api_key
elif model_name.startswith("hf"):
return huggingface_api_key
else:
return openai_api_key
api_key = get_api_key(api_key, model_name, huggingface_api_key, openai_api_key)
if not api_key:
st.error("Please provide an API key")
st.stop() LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/base_genoss.py The code is generally good, but there are areas for potential improvement.
Here's an example of how you could improve the @abstractmethod
def generate_answer(self, prompt: str) -> Dict:
raise NotImplementedError
@abstractmethod
def generate_embedding(self, text: str) -> List[float]:
raise NotImplementedError LOGAF Level 2 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/hf_hub/base_hf_hub.py The code functions, but has significant issues needing attention.
Here's an example of how you could improve the def __init__(self, api_key, *args, **kwargs):
super().__init__(*args, **kwargs)
if api_key is None:
raise ValueError("API key missing")
self.huggingfacehub_api_token = api_key LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/local/gpt4all.py The code is generally good, but there are areas for potential improvement.
Here's an example of how you could improve the def generate_embedding_from_string(self, text: str):
gpt4all_embd = GPT4AllEmbeddings()
return gpt4all_embd.embed_query(text)
def generate_embedding_from_list(self, text_list: list[str]):
gpt4all_embd = GPT4AllEmbeddings()
return gpt4all_embd.embed_query(" ".join(text_list)) LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/openai/openai_llm.py The code is generally good, but there are areas for potential improvement.
Here's an example of how you could improve the def __init__(self, model_name: str, api_key, *args, **kwargs):
super().__init__(*args, **kwargs)
if api_key is None:
raise ValueError("API key is missing")
self.openai_api_key = api_key
self.model_name = model_name
self.embedding_model = OpenAIEmbeddings()
def generate_embedding(self, text: str):
return self.embedding_model.embed_query(text) 🔧🔍👍 Powered by Code Review GPT |
No description provided.