Fix deployment name issue to support Azure

This commit is contained in:
Brandon Hancock
2024-08-23 11:38:29 -04:00
parent 8119edb495
commit 2cc6cab6a9

View File

@@ -117,16 +117,19 @@ class Agent(BaseAgent):
def post_init_setup(self):
self.agent_ops_agent_name = self.role
if hasattr(self.llm, "model_name"):
self._setup_llm_callbacks()
# Different llms store the model name in different attributes
model_name = self.llm.model_name or self.llm.deployment_name
if model_name:
self._setup_llm_callbacks(model_name)
if not self.agent_executor:
self._setup_agent_executor()
return self
def _setup_llm_callbacks(self):
token_handler = TokenCalcHandler(self.llm.model_name, self._token_process)
def _setup_llm_callbacks(self, model_name: str):
token_handler = TokenCalcHandler(model_name, self._token_process)
if not isinstance(self.llm.callbacks, list):
self.llm.callbacks = []