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

Added call method and dialog turn to memory class, added 3 memory tests [issue #248] #288

Merged

Conversation

lu-ny
Copy link
Contributor

@lu-ny lu-ny commented Nov 28, 2024

What does this PR do?

Fixes #248

Added a call method to the unfinished adalflow.components.memory.memory.Memory class. This method returns a formatted conversation history, handles empty conversations, and formats user and assistant messages.

Additionally, added add_dialog_turn() method to handle new back-and-forth messages. This adds an id to each dialog turn for tracking and appends it to the current_conversation list.

Finally, added 3 new tests for memory -empty memory, single dialog turn, and multiple dialog turn tests. Also updated the chatbot usage notebook to replace the deprecated class with the updated one and verified that it worked.

Submission Details
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
Test Results
======================================================== test session starts ========================================================
platform linux -- Python 3.11.9, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/AdalFlow
configfile: pyproject.toml
plugins: mock-3.14.0, anyio-4.4.0
collected 209 items / 1 skipped                                                                                                     

adalflow/tests/test_AzureClient.py ..                                                                                         [  0%]
adalflow/tests/test_base_data_class.py ..............                                                                         [  7%]
adalflow/tests/test_component.py ...                                                                                          [  9%]
adalflow/tests/test_data.py ...                                                                                               [ 10%]
adalflow/tests/test_data_class_parser.py ......                                                                               [ 13%]
adalflow/tests/test_data_classes.py ....                                                                                      [ 15%]
adalflow/tests/test_data_loader.py .......                                                                                    [ 18%]
adalflow/tests/test_dataclass_object_functions.py ................                                                            [ 26%]
adalflow/tests/test_evaluators.py ..s                                                                                         [ 27%]
adalflow/tests/test_faiss_retriever.py .........                                                                              [ 32%]
adalflow/tests/test_function_expression_parse.py ........................                                                     [ 43%]
adalflow/tests/test_generator.py .....                                                                                        [ 45%]
adalflow/tests/test_generator_call_logger.py ...                                                                              [ 47%]
adalflow/tests/test_grad_component.py ......                                                                                  [ 50%]
adalflow/tests/test_groq_client.py ..                                                                                         [ 51%]
adalflow/tests/test_lazy_import.py ........                                                                                   [ 55%]
adalflow/tests/test_logger.py ......                                                                                          [ 57%]
adalflow/tests/test_memory.py ...                                                                                             [ 59%]
adalflow/tests/test_model_client.py ...                                                                                       [ 60%]
adalflow/tests/test_ollama_client.py ..                                                                                       [ 61%]
adalflow/tests/test_openai_client.py ..                                                                                       [ 62%]
adalflow/tests/test_output_parser.py ......                                                                                   [ 65%]
adalflow/tests/test_parameter.py ............                                                                                 [ 71%]
adalflow/tests/test_parameter_text_grad.py ...                                                                                [ 72%]
adalflow/tests/test_random_sample.py .....                                                                                    [ 75%]
adalflow/tests/test_sequential.py ...............                                                                             [ 82%]
adalflow/tests/test_string_parser.py ..........................                                                               [ 94%]
adalflow/tests/test_text_splitter.py .........                                                                                [ 99%]
adalflow/tests/test_tool.py ..                                                                                                [100%]

========================================================= warnings summary ==========================================================
adalflow/tests/test_ollama_client.py::TestOllamaModelClient::test_ollama_embedding_client
adalflow/tests/test_ollama_client.py::TestOllamaModelClient::test_ollama_llm_client
  /home/AdalFlow/adalflow/adalflow/components/model_client/ollama_client.py:165: UserWarning: Better to provide host or set OLLAMA_HOST env variable. We will use the default host http://localhost:11434 for now.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================ 208 passed, 2 skipped, 2 warnings in 11.53s ============================================

…ry.Memory class. This method returns a formatted conversation history, handles empty conversations, and formats user and assistant messages.Additionally, added add_dialog_turn() method to handle new back-and-forth messages. This adds an id to each dialog turn for tracking and appends it to the current_conversation list. Finally, added 3 new tests for memory -empty memory, single dialog turn, and multiple dialog turn tests. Also updated the chatbot usage notebook to replace the deprecated class with the updated one.
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@lu-ny
Copy link
Contributor Author

lu-ny commented Dec 3, 2024

@fm1320 @liyin2015 lmk when you get a chance to review :)

Copy link
Collaborator

@fm1320 fm1320 left a comment

Choose a reason for hiding this comment

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

Yeah it looks all good, made some small edits in the notebook but its fine :) thanks @lu-ny

@fm1320 fm1320 merged commit 51ac755 into SylphAI-Inc:main Dec 4, 2024
4 checks passed
@liyin2015 liyin2015 added the ready-to-go Used for marking PR as ready to merge (used only in the PR) label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-go Used for marking PR as ready to merge (used only in the PR)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Component Memory is Missing the required 'call' method
3 participants