Update app/memory/history_trimmer.py
Browse files
app/memory/history_trimmer.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
from langchain_core.messages import BaseMessage, RemoveMessage, SystemMessage
|
| 4 |
-
from
|
| 5 |
|
| 6 |
from app.config import get_settings
|
| 7 |
|
| 8 |
_summarizer_llm = None
|
| 9 |
|
| 10 |
|
| 11 |
-
def _get_summarizer() ->
|
| 12 |
"""Separate, cheaper model just for summarization — keeps main agent's
|
| 13 |
-
token budget free and avoids competing for the same
|
| 14 |
global _summarizer_llm
|
| 15 |
if _summarizer_llm is None:
|
| 16 |
settings = get_settings()
|
| 17 |
-
_summarizer_llm =
|
| 18 |
-
api_key=settings.
|
| 19 |
-
model="llama-3.1-8b-
|
| 20 |
temperature=0,
|
| 21 |
)
|
| 22 |
return _summarizer_llm
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
from langchain_core.messages import BaseMessage, RemoveMessage, SystemMessage
|
| 4 |
+
from langchain_nvidia_ai_endpoints import ChatNVIDIA
|
| 5 |
|
| 6 |
from app.config import get_settings
|
| 7 |
|
| 8 |
_summarizer_llm = None
|
| 9 |
|
| 10 |
|
| 11 |
+
def _get_summarizer() -> ChatNVIDIA:
|
| 12 |
"""Separate, cheaper model just for summarization — keeps main agent's
|
| 13 |
+
token budget free and avoids competing for the same NVIDIA rate limit."""
|
| 14 |
global _summarizer_llm
|
| 15 |
if _summarizer_llm is None:
|
| 16 |
settings = get_settings()
|
| 17 |
+
_summarizer_llm = ChatNVIDIA(
|
| 18 |
+
api_key=settings.nvidia_api_key,
|
| 19 |
+
model="meta/llama-3.1-8b-instruct", # small/fast model for cheap summarization
|
| 20 |
temperature=0,
|
| 21 |
)
|
| 22 |
return _summarizer_llm
|