Compare commits

..

2 Commits

Author SHA1 Message Date
Alex
be842f89b9 fix: ruff 2025-11-24 10:39:27 +00:00
Alex
3737beb2ba feat: context compression 2025-11-23 18:35:51 +00:00
3 changed files with 13 additions and 17 deletions

View File

@@ -26,6 +26,13 @@
</div>
<div align="center">
<br>
🎃 <a href="https://github.com/arc53/DocsGPT/blob/main/HACKTOBERFEST.md"> Hacktoberfest Prizes, Rules & Q&A </a> 🎃
<br>
<br>
</div>
<div align="center">
<br>

View File

@@ -103,10 +103,11 @@ class StreamProcessor:
def initialize(self):
"""Initialize all required components for processing"""
self._configure_agent()
self._validate_and_set_model()
self._configure_agent()
self._configure_source()
self._configure_retriever()
self._configure_agent()
self._load_conversation_history()
self._process_attachments()
@@ -229,12 +230,7 @@ class StreamProcessor:
)
self.model_id = requested_model
else:
# Check if agent has a default model configured
agent_default_model = self.agent_config.get("default_model_id", "")
if agent_default_model and validate_model_id(agent_default_model):
self.model_id = agent_default_model
else:
self.model_id = get_default_model_id()
self.model_id = get_default_model_id()
def _get_agent_key(self, agent_id: Optional[str], user_id: Optional[str]) -> tuple:
"""Get API key for agent with access control"""
@@ -307,10 +303,6 @@ class StreamProcessor:
data["sources"] = sources_list
else:
data["sources"] = []
# Preserve model configuration from agent
data["default_model_id"] = data.get("default_model_id", "")
return data
def _configure_source(self):
@@ -363,7 +355,6 @@ class StreamProcessor:
"agent_type": data_key.get("agent_type", settings.AGENT_NAME),
"user_api_key": api_key,
"json_schema": data_key.get("json_schema"),
"default_model_id": data_key.get("default_model_id", ""),
}
)
self.initial_user_id = data_key.get("user")
@@ -388,7 +379,6 @@ class StreamProcessor:
"agent_type": data_key.get("agent_type", settings.AGENT_NAME),
"user_api_key": self.agent_key,
"json_schema": data_key.get("json_schema"),
"default_model_id": data_key.get("default_model_id", ""),
}
)
self.decoded_token = (
@@ -415,7 +405,6 @@ class StreamProcessor:
"agent_type": settings.AGENT_NAME,
"user_api_key": None,
"json_schema": None,
"default_model_id": "",
}
)

View File

@@ -37,7 +37,7 @@ OPENAI_MODELS = [
supports_tools=True,
supports_structured_output=True,
supported_attachment_types=OPENAI_ATTACHMENTS,
context_window=200000,
context_window=400000,
),
),
AvailableModel(
@@ -49,7 +49,7 @@ OPENAI_MODELS = [
supports_tools=True,
supports_structured_output=True,
supported_attachment_types=OPENAI_ATTACHMENTS,
context_window=200000,
context_window=400000,
),
)
]
@@ -133,7 +133,7 @@ GOOGLE_MODELS = [
supports_tools=True,
supports_structured_output=True,
supported_attachment_types=GOOGLE_ATTACHMENTS,
context_window=2000000,
context_window=20000, # Set low for testing compression
),
),
]