Update app.py
Browse files
app.py
CHANGED
|
@@ -200,26 +200,48 @@ class QuestionAnsweringAgent(CodeAgent):
|
|
| 200 |
api_key=openai_api_key
|
| 201 |
)
|
| 202 |
|
| 203 |
-
#
|
| 204 |
-
#
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
# Call super() with arguments known/expected by CodeAgent's direct signature
|
| 213 |
-
# and that it then passes appropriately (or not) to MultiStepAgent.
|
| 214 |
-
# This assumes CodeAgent correctly filters what it passes to super()
|
| 215 |
-
# or that these specific ones are indeed handled before the super() call.
|
| 216 |
-
super().__init__(
|
| 217 |
-
model=effective_model,
|
| 218 |
-
tools=tools,
|
| 219 |
-
max_steps=CONFIG.AGENT_MAX_STEPS,
|
| 220 |
-
**code_agent_specific_kwargs
|
| 221 |
-
)
|
| 222 |
-
|
| 223 |
logger.info(f"QuestionAnsweringAgent initialized with model: {CONFIG.OPENAI_MODEL_ID}.")
|
| 224 |
|
| 225 |
async def process_question(self, question_text: str) -> Tuple[str, str]:
|
|
|
|
| 200 |
api_key=openai_api_key
|
| 201 |
)
|
| 202 |
|
| 203 |
+
# Call super() with ONLY arguments known to be core for MultiStepAgent
|
| 204 |
+
# We will lose system_prompt, verbosity, and additional_imports for now,
|
| 205 |
+
# which will likely make the agent not perform as intended, but this is
|
| 206 |
+
# to see if the base MultiStepAgent initializes.
|
| 207 |
+
try:
|
| 208 |
+
super().__init__(
|
| 209 |
+
model=effective_model,
|
| 210 |
+
tools=tools,
|
| 211 |
+
max_steps=CONFIG.AGENT_MAX_STEPS
|
| 212 |
+
# system_prompt IS DELIBERATELY OMITTED for this test
|
| 213 |
+
# verbosity_level IS DELIBERATELY OMITTED for this test
|
| 214 |
+
# additional_authorized_imports IS DELIBERATELY OMITTED for this test
|
| 215 |
+
)
|
| 216 |
+
logger.info("QuestionAnsweringAgent (CodeAgent) super().__init__ called with minimal args.")
|
| 217 |
+
|
| 218 |
+
# If the above works, CodeAgent is initialized but might not have its specific settings.
|
| 219 |
+
# We can try to set them now if they are attributes.
|
| 220 |
+
# This depends on CodeAgent's internal design.
|
| 221 |
+
if hasattr(self, 'system_prompt'):
|
| 222 |
+
self.system_prompt = CONFIG.AGENT_SYSTEM_PROMPT
|
| 223 |
+
logger.info(f"Set self.system_prompt to: {self.system_prompt[:50]}...")
|
| 224 |
+
else:
|
| 225 |
+
logger.warning("CodeAgent instance does not have attribute 'system_prompt' to set after init.")
|
| 226 |
+
|
| 227 |
+
if hasattr(self, 'verbosity_level'):
|
| 228 |
+
self.verbosity_level = CONFIG.AGENT_VERBOSITY_LEVEL
|
| 229 |
+
logger.info(f"Set self.verbosity_level to: {self.verbosity_level}")
|
| 230 |
+
else:
|
| 231 |
+
logger.warning("CodeAgent instance does not have attribute 'verbosity_level' to set after init.")
|
| 232 |
+
|
| 233 |
+
if hasattr(self, 'additional_authorized_imports'):
|
| 234 |
+
self.additional_authorized_imports = ["PIL"]
|
| 235 |
+
logger.info(f"Set self.additional_authorized_imports to: {self.additional_authorized_imports}")
|
| 236 |
+
else:
|
| 237 |
+
logger.warning("CodeAgent instance does not have attribute 'additional_authorized_imports' to set after init.")
|
| 238 |
+
|
| 239 |
+
except TypeError as e:
|
| 240 |
+
logger.error(f"Still got TypeError during minimal super().__init__: {e}", exc_info=True)
|
| 241 |
+
# This would mean even model, tools, or max_steps is an issue for MultiStepAgent's init
|
| 242 |
+
# or CodeAgent itself requires more in its direct init before calling super.
|
| 243 |
+
raise e # re-raise the error
|
| 244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
logger.info(f"QuestionAnsweringAgent initialized with model: {CONFIG.OPENAI_MODEL_ID}.")
|
| 246 |
|
| 247 |
async def process_question(self, question_text: str) -> Tuple[str, str]:
|