Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jinucho
Copy link
Contributor

@jinucho jinucho commented Dec 30, 2024

[Title] ConversationSummaryMemory

[Version] initial

[Language] ENG

[Package] langchain, langchain-openai
ConversationSummaryMemory & ConversationSummaryBufferMemory

  • Implemented ConversationSummaryMemory and ConversationSummaryBufferMemory to manage conversation history efficiently.
  • Demonstrated memory behavior before and after exceeding the token threshold (e.g., 200 tokens).
  • Showed how recent conversations remain unsummarized, while older conversations are compiled into a summary.
  • Highlighted token-based flushing mechanism, instead of interaction count, for deciding when to summarize conversations.
  • Provided examples of storing and retrieving conversation history with LangChain's memory modules.

…ryMemory
[Version] initial
[Language] ENG
[Package] langchain, langchain-openai

ConversationSummaryMemory & ConversationSummaryBufferMemory
* Implemented  and  to manage conversation history efficiently.
* Demonstrated memory behavior before and after exceeding the token threshold (e.g., 200 tokens).
* Showed how recent conversations remain unsummarized, while older conversations are compiled into a summary.
* Highlighted token-based flushing mechanism, instead of interaction count, for deciding when to summarize conversations.
* Provided examples of storing and retrieving conversation history with LangChain's memory modules.  Force remove reference to missing file from Git index
@jinucho jinucho requested review from Shinar12 and Secludor December 30, 2024 04:51
@teddylee777 teddylee777 changed the title [Team] Existing content development teams 4
[Title] ConversationSummaryMemory ConversationSummaryMemory
 Dec 30, 2024
@Secludor
Copy link
Contributor

1.

현재 셀 순서가 load_dotenv() 뒤에 set_env({~})로 api_key를 초기화하고 있어서 .env만 설정하고 전체 셀을 실행 하는 경우 오류가 발생합니다.

# Set environment variables
from langchain_opentutorial import set_env
import os
set_env(
    {
        "OPENAI_API_KEY": os.getenv("OPENAI_API_KEY"), 
        "LANGCHAIN_API_KEY": os.getenv("LANGCHAIN_API_KEY"),
        "LANGCHAIN_TRACING_V2": "true",
        "LANGCHAIN_ENDPOINT": "https://api.smith.langchain.com",
        "LANGCHAIN_PROJECT": "06-ConversationSummaryMemory",
    }
)

이렇게 초기값을 os.getenv로 가져오도록 설정해주면 어떨까요?

2.

혹시 다음의 로그가 저만 발생하는 지 궁금합니다!
LangChainDeprecationWarning: Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/
memory = ConversationSummaryMemory(

@jinucho
Copy link
Contributor Author

jinucho commented Dec 31, 2024

1.

현재 셀 순서가 load_dotenv() 뒤에 set_env({~})로 api_key를 초기화하고 있어서 .env만 설정하고 전체 셀을 실행 하는 경우 오류가 발생합니다.

# Set environment variables
from langchain_opentutorial import set_env
import os
set_env(
    {
        "OPENAI_API_KEY": os.getenv("OPENAI_API_KEY"), 
        "LANGCHAIN_API_KEY": os.getenv("LANGCHAIN_API_KEY"),
        "LANGCHAIN_TRACING_V2": "true",
        "LANGCHAIN_ENDPOINT": "https://api.smith.langchain.com",
        "LANGCHAIN_PROJECT": "06-ConversationSummaryMemory",
    }
)

이렇게 초기값을 os.getenv로 가져오도록 설정해주면 어떨까요?

실제 코드 실행시에는 말씀해주신대로 했었어요, 템플릿을 바꾸지 않고 고정적으로 써야하나? 싶어서 "" 로 바꾸어 놨는데, os.getenv로 바꿔도 된다면 그렇게 변경 하겠습니다!.

2.

혹시 다음의 로그가 저만 발생하는 지 궁금합니다! LangChainDeprecationWarning: Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/ memory = ConversationSummaryMemory(

저도 실행 시 나왔던 경고이긴 한데, 어떻게 처리해야 하나 고민 입니다..

[Version] initial

[Language] ENG

[Package] langchain, langchain-openai
ConversationSummaryMemory & ConversationSummaryBufferMemory

Implemented ConversationSummaryMemory and ConversationSummaryBufferMemory to manage conversation history efficiently.
Demonstrated memory behavior before and after exceeding the token threshold (e.g., 200 tokens).
Showed how recent conversations remain unsummarized, while older conversations are compiled into a summary.
Highlighted token-based flushing mechanism, instead of interaction count, for deciding when to summarize conversations.
Provided examples of storing and retrieving conversation history with LangChain's memory modules.
@jinucho
Copy link
Contributor Author

jinucho commented Dec 31, 2024

우선 load_dotenv를 set_env 셀 아래로 옮기면서

from dotenv import load_dotenv

load_dotenv(override=True)

로 수정 했습니다.

@teddylee777
Copy link
Contributor

@jinucho load_dotenv 는 항상

# Set environment variables
from langchain_opentutorial import set_env
import os
set_env(
    {
        "OPENAI_API_KEY": os.getenv("OPENAI_API_KEY"), 
        "LANGCHAIN_API_KEY": os.getenv("LANGCHAIN_API_KEY"),
        "LANGCHAIN_TRACING_V2": "true",
        "LANGCHAIN_ENDPOINT": "https://api.smith.langchain.com",
        "LANGCHAIN_PROJECT": "06-ConversationSummaryMemory",
    }
)

다음에 오도록 위치해 주시면 되겠습니다^^

향후 deprecation warning 이 뜨는 것 같습니다. 일단은 넘어가셔도 좋을 것 같습니다!

Secludor
Secludor previously approved these changes Jan 1, 2025
Copy link
Contributor

@Secludor Secludor left a comment

Choose a reason for hiding this comment

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

  • Review OS : Win
  • Template Rule 가이드를 준수 하였는가?
  • Table of Contents 의 링크가 원활하게 동작하는지 확인하였는가?
  • 이미지가 포함되어 있다면, 이미지의 파일명이 가이드를 준수하였는가? (해당 없음)
  • import 구문이 예전 legacy 방식이 아닌 최신 버전을 따르는가?
  • 모든 코드가 동작에 오류 없이 동작하는가?
  • 기타 의견: 윈도우 환경에서의 정상 동작 확인 완료했습니다. 고생하셨습니다 :)

Shinar12
Shinar12 previously approved these changes Jan 1, 2025
Copy link

@Shinar12 Shinar12 left a comment

Choose a reason for hiding this comment

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

[Review]

  1. Review OS : Mac
  2. Template Rule 가이드를 준수 하였는가? : YES
  3. Table of Contents 의 링크가 원활하게 동작하는지 확인하였는가? : YES
  4. 이미지가 포함되어 있다면, 이미지의 파일명이 가이드를 준수하였는가? : N/A(이미지 포함 X)
  5. import 구문이 예전 legacy 방식이 아닌 최신 버전을 따르는가?(YES/NO) : YES
  6. 모든 코드가 동작에 오류 없이 동작하는가? (만약, warning 발생시 코멘트에 적어주세요) : YES
  7. 기타 의견 : 고생하셨습니다 👍

[Version] initial

[Language] ENG

[Package] langchain, langchain-openai
ConversationSummaryMemory & ConversationSummaryBufferMemory

Implemented ConversationSummaryMemory and ConversationSummaryBufferMemory to manage conversation history efficiently.
Demonstrated memory behavior before and after exceeding the token threshold (e.g., 200 tokens).
Showed how recent conversations remain unsummarized, while older conversations are compiled into a summary.
Highlighted token-based flushing mechanism, instead of interaction count, for deciding when to summarize conversations.
Provided examples of storing and retrieving conversation history with LangChain's memory modules.
@jinucho jinucho dismissed stale reviews from Shinar12 and Secludor via 84b99dd January 2, 2025 08:41
@Shinar12 Shinar12 self-requested a review January 2, 2025 13:32
@teddylee777 teddylee777 merged commit fd756d7 into LangChain-OpenTutorial:main Jan 2, 2025
1 of 2 checks passed
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.

4 participants