-
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(): remove llm chain for chatopenai #19
Conversation
LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/hf_hub/base_hf_hub.py
LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/fake_llm.py
LOGAF Level 3 - /home/runner/work/GenossGPT/GenossGPT/genoss/llm/openai/openai_llm.py
🔒📚🔧 Powered by Code Review GPT |
0ea1415
to
86e3f7b
Compare
demo/main.py
Outdated
] | ||
|
||
for msg in st.session_state.messages: | ||
for msg in st.session_state.messages[1:]: # Skip the system message when displaying |
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.
You should probably just add an if with a different display.
Something like :
if msg["role"] == "system":
st.markdown(f"System: *{msg['content']}*")
continue
If you really don't want to display it don't but go with a if logic anyway.
if TYPE_CHECKING: | ||
from langchain.schema import BaseMessage | ||
|
||
from genoss.entities.chat.message import Message |
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.
not clear to me why you are doing this.
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.
Fix-ruff did this otherwise it errored. See other comment
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.
Does it still do the same if you remove TYPE_CHECKING and go with a normal import ?
genoss/llm/openai/openai_llm.py
Outdated
def _parseMessagesAsChatMessage(self, messages: list[Message]) -> list[BaseMessage]: | ||
new_messages: list[BaseMessage] = [] | ||
for message in messages: | ||
new_messages.append(ChatMessage(content=message.content, role=message.role)) | ||
return new_messages |
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.
I feel like it's a good move to leave LLMChain. This method should probably be outside this class tho and reused through various LLMs.
Another thing. Python use snake_case and not CamelCase or pascalCase for functions.
Finally you may want to use python list comprehension.
return [
ChatMessage(content=message.content, role=message.role)
for message in messages
]
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.
Understand and agree most of this but what do you mean by keeping LLM chain?
Calling the LLM directly makes more sense than using a chain IMO. Reduce some latency and remove complexity.
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.
I feel like it's a good move to leave LLMChain
XD I meant move away from it not keep it. I guess it's french synonymy. :P
if TYPE_CHECKING: | ||
from genoss.entities.chat.message import Message | ||
|
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.
Do you have any reason to do that TYPE_CHECKING thing ?
I think we should avoid this unless we have a circular import issue.
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.
fix-ruff did this. Otherwise ruff errored. Happy if you have another option?
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.
I think you probably should just do the import without the TYPE_CHECKING.
e596a35
to
9a0377c
Compare
No description provided.