Skip to content
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

Open_ai_components #18

Merged
merged 52 commits into from
Aug 21, 2024
Merged

Open_ai_components #18

merged 52 commits into from
Aug 21, 2024

Conversation

efunneko
Copy link
Collaborator

Added a native OpenAI component which is a bit more efficient than going through LangChain. The history is managed directly in this component

Also improved the history handling a bit in the LangChain history component.

efunneko added 30 commits August 4, 2024 12:47
…er than payload to avoid confusion with message payload
@efunneko efunneko requested a review from gregmeldrum August 21, 2024 13:09
@efunneko efunneko self-assigned this Aug 21, 2024
Copy link

gitstream-cm bot commented Aug 21, 2024

Please mark whether you used Copilot to assist coding in this PR

  • Copilot Assisted

Copy link
Collaborator

@gregmeldrum gregmeldrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

{
"name": "history_max_time",
"required": False,
"description": "Maximum time to keep conversation history",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to have the unit here (in seconds).

@efunneko efunneko merged commit f2ab285 into main Aug 21, 2024
2 of 3 checks passed
Copy link

@efunneko efunneko deleted the open_ai_components branch August 22, 2024 10:29
artyom-morozov pushed a commit that referenced this pull request Aug 23, 2024
* First commit of big refactor

* refactor: improve event handling in TestOutputComponent

* refactor: handle both Message and Event objects in TestInputComponent

* fix: handle both Event and Message objects in TestOutputComponent

* feat: add Message import to utils_for_test_files

* feat: add send_message method to ComponentBase

* fix: wrap message in Event before enqueueing to next component

* refactor: move timer_manager creation to SolaceAiConnector and improve error handling

* feat: add logging for timer manager stop process

* perf: optimize TimerManager to reduce CPU usage

* fix: improve shutdown process for timer thread

* perf: Remove unnecessary sleep in TimerManager run loop

* refactor: remove unused send_message method from ComponentBase

* refactor: improve clean exit process and resource cleanup

* fix: import log module to resolve undefined name errors

* refactor: update aggregate component to handle timeout consistently

* refactor: update aggregate component output to return list

* refactor: simplify aggregation logic and improve method naming

* fix: reset current_aggregation after returning aggregation

* All tests now pass

* Warning cleanup

* chore: one additional small fix to account for input components that might return None

* refactor: rename Event class 'payload' to 'data'

* refactor: Update get_message_from_flow to use event.data instead of event.payload

* Switched the contained data in the Event class to be called data rather than payload to avoid confusion with message payload

* Remove commented code

* feat: add OpenAI chat model components with and without history

* refactor: replace LangChain with native OpenAI library for chat models

* feat: add history max time and clear history options to OpenAI chat model

* feat: implement clear_history_but_keep_depth functionality

* more changes

* feat: add method to clear chat history while retaining specified depth

* fix: correct data member references in clear_history_but_keep_depth method

* refactor: implement thread-safe history storage using KV store

* feat: implement history_max_time parameter for message pruning

* feat: add time-based history pruning to OpenAIChatModelWithHistory

* refactor: optimize history management in OpenAIChatModelWithHistory

* feat: implement time-based pruning in conversation history

* refactor: optimize chat history management

* feat: add history age-out functionality with hourly cleanup timer

* clean up some spacing

* feat: add base_url configuration for OpenAIChatModelBase

* feat: add streaming functionality to OpenAIChatModelBase

* feat: update chat history handling for system messages

* refactor: ensure first history message is user message in clear_history_but_keep_depth

* refactor: update clear_history_but_keep_depth to ensure depth includes last user message

* Make sure that the first message in the history has a user role when trimming the history

* Merge branch 'main' into open_ai_components

* chore: Some small formatting changes

* chore: Add some protection around clearing the history to make sure the first message is never a non-user message.
artyom-morozov pushed a commit that referenced this pull request Aug 23, 2024
* First commit of big refactor

* refactor: improve event handling in TestOutputComponent

* refactor: handle both Message and Event objects in TestInputComponent

* fix: handle both Event and Message objects in TestOutputComponent

* feat: add Message import to utils_for_test_files

* feat: add send_message method to ComponentBase

* fix: wrap message in Event before enqueueing to next component

* refactor: move timer_manager creation to SolaceAiConnector and improve error handling

* feat: add logging for timer manager stop process

* perf: optimize TimerManager to reduce CPU usage

* fix: improve shutdown process for timer thread

* perf: Remove unnecessary sleep in TimerManager run loop

* refactor: remove unused send_message method from ComponentBase

* refactor: improve clean exit process and resource cleanup

* fix: import log module to resolve undefined name errors

* refactor: update aggregate component to handle timeout consistently

* refactor: update aggregate component output to return list

* refactor: simplify aggregation logic and improve method naming

* fix: reset current_aggregation after returning aggregation

* All tests now pass

* Warning cleanup

* chore: one additional small fix to account for input components that might return None

* refactor: rename Event class 'payload' to 'data'

* refactor: Update get_message_from_flow to use event.data instead of event.payload

* Switched the contained data in the Event class to be called data rather than payload to avoid confusion with message payload

* Remove commented code

* feat: add OpenAI chat model components with and without history

* refactor: replace LangChain with native OpenAI library for chat models

* feat: add history max time and clear history options to OpenAI chat model

* feat: implement clear_history_but_keep_depth functionality

* more changes

* feat: add method to clear chat history while retaining specified depth

* fix: correct data member references in clear_history_but_keep_depth method

* refactor: implement thread-safe history storage using KV store

* feat: implement history_max_time parameter for message pruning

* feat: add time-based history pruning to OpenAIChatModelWithHistory

* refactor: optimize history management in OpenAIChatModelWithHistory

* feat: implement time-based pruning in conversation history

* refactor: optimize chat history management

* feat: add history age-out functionality with hourly cleanup timer

* clean up some spacing

* feat: add base_url configuration for OpenAIChatModelBase

* feat: add streaming functionality to OpenAIChatModelBase

* feat: update chat history handling for system messages

* refactor: ensure first history message is user message in clear_history_but_keep_depth

* refactor: update clear_history_but_keep_depth to ensure depth includes last user message

* Make sure that the first message in the history has a user role when trimming the history

* Merge branch 'main' into open_ai_components

* chore: Some small formatting changes

* chore: Add some protection around clearing the history to make sure the first message is never a non-user message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants