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

feat: Add ConversationMemory and enhance AnnotationMessage #238

Merged
merged 137 commits into from
Nov 26, 2024

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 25, 2024

Add ConversationMemory and enhance AnnotationMessage

Changes

This PR introduces two major features:

  1. ConversationMemory Implementation

    • New ConversationMemory struct for efficient message history management
    • Smart truncation with batch-size awareness
    • Preservation of system messages and initial context
    • Run ID-based deduplication for message appending
    • Direct integration with PromptingTools.jl's aigenerate function
  2. Enhanced AnnotationMessage Testing

    • Comprehensive tests for annotation message filtering across all providers
    • Edge case coverage for multiple consecutive annotations
    • Verification of metadata isolation in rendered output
    • Tests for all annotation message fields (extras, tags, comments)

Testing

  • Added comprehensive test suite in test/memory.jl and related files
  • Enhanced annotation message render tests in test/annotation_messages_render.jl
  • All tests passing across all providers

Implementation Details

  • ConversationMemory maintains conversation history in fixed-size batches
  • Smart truncation preserves system messages and first user message
  • Annotation messages are properly filtered out during rendering across all providers
  • Efficient caching through deterministic truncation points

Link to Devin run: https://preview.devin.ai/devin/1313c322110e474eb7be51c54071a39c

If you have any feedback, you can leave comments in the PR and I'll address them in the app!

svilupp and others added 23 commits October 20, 2024 13:51
* Gwen 72B and open-router Google Flash added.

* Fixing the pricing informations.

* Pricing updated for gemini-flash-1.5-8b

* Removed orgfexp

Removed orgfexp because the model is heavily rate limited.

* Following naming conventions for qwen aliases
* Add GoogleOpenAISchema with OpenAI compatibility mode

- Add GoogleOpenAISchema struct with documentation
- Implement create_chat method with Google API base URL
- Implement create_embedding method with Google API base URL
- Use GOOGLE_API_KEY for authentication

* test: Add tests for GoogleOpenAISchema implementation

* test: Enhance GoogleOpenAISchema tests to improve coverage

* Move GoogleOpenAISchema tests to llm_openai_schema_def.jl

* feat: Add Gemini 1.5 models and aliases to user_preferences.jl

Added new models:
- gemini-1.5-pro-latest
- gemini-1.5-flash-8b-latest
- gemini-1.5-flash-latest

Added corresponding aliases:
- gem15p
- gem15f8
- gem15f

Set pricing according to Google's pay-as-you-go rates:
Input: /bin/bash.075/1M tokens
Output: /bin/bash.30/1M tokens

* Update Gemini model pricing to reflect correct per-million token rates

* revert: Remove unintended changes to test/llm_google.jl

* revert: restore test/llm_google.jl to original state from main branch

* feat: Add GoogleProvider with proper Bearer token auth and update GoogleOpenAISchema methods

- Add GoogleProvider struct with proper Bearer token authentication
- Update create_chat to use GoogleProvider and openai_request
- Update create_embeddings to use GoogleProvider and openai_request
- Maintain consistent URL handling up to /v1beta

* feat: Add Gemini models to registry and fix GoogleOpenAISchema tests

- Add Gemini 1.5 models (Pro, Flash, Flash 8b) with correct pricing
- Fix GoogleOpenAISchema tests to properly handle GOOGLE_API_KEY
- Save and restore original API key value during testing

* fix: restore gpt-4-turbo-preview model and ensure correct model ordering

* Add comprehensive logging to GoogleOpenAISchema test mock servers

- Add detailed request header logging
- Track authorization header values and expectations
- Log request body content and responses
- Improve debugging capabilities for test failures

* fix: Update auth_header in GoogleProvider to use OpenAIProvider implementation

* chore: prepare release v0.63.0

- Update version to 0.63.0
- Add warning about token/cost counting limitations in GoogleOpenAISchema
- Update changelog with correct model aliases (gem15p, gem15f, gem15f8)
- Remove logging from test/llm_openai_schema_def.jl

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Implement ConversationMemory struct for efficient message history management
- Add batch-aware truncation and caching capabilities
- Enhance AnnotationMessage with comprehensive filtering tests across providers
- Add tests for edge cases and multiple consecutive annotations
@svilupp svilupp force-pushed the devin/1732559303-add-conversation-memory-and-annotation branch from 2086464 to 7b79d8b Compare November 26, 2024 10:32
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 91.91176% with 11 lines in your changes missing coverage. Please review.

Project coverage is 92.03%. Comparing base (f92c102) to head (a6fb649).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/llm_shared.jl 50.00% 2 Missing ⚠️
src/llm_tracer.jl 0.00% 2 Missing ⚠️
src/llm_anthropic.jl 66.66% 1 Missing ⚠️
src/llm_google.jl 66.66% 1 Missing ⚠️
src/llm_ollama.jl 66.66% 1 Missing ⚠️
src/llm_ollama_managed.jl 50.00% 1 Missing ⚠️
src/llm_openai.jl 66.66% 1 Missing ⚠️
src/messages.jl 96.42% 1 Missing ⚠️
src/user_preferences.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #238      +/-   ##
==========================================
+ Coverage   91.98%   92.03%   +0.05%     
==========================================
  Files          47       49       +2     
  Lines        4640     4771     +131     
==========================================
+ Hits         4268     4391     +123     
- Misses        372      380       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@svilupp svilupp merged commit 5548745 into main Nov 26, 2024
4 checks passed
@svilupp svilupp deleted the devin/1732559303-add-conversation-memory-and-annotation branch November 26, 2024 19:43
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.

10 participants