Dan Godbold
10/31/2024, 2:44 PMAzureChatOpenAI
I get an AttributeError: 'AzureChatOpenAI' object has no attribute 'get'
when the agent's running. The model's assigned to the default as in the docs here
cf.defaults.model = AzureChatOpenAI(
api_version=AZURE_OPENAI_LLM_API_VERSION,
temperature=0,
streaming=True,
model_name=AZURE_OPENAI_LLM_DEPLOYMENT,
api_key=AZURE_OPENAI_LLM_API_KEY,
azure_endpoint=azure_endpoint)
I'll put the stack trace in a comment on the thread. Anyone have any ideas? Presumably it's a mismatch in langchain models - controlflow's requirements.txt.lock say 0.1.23, the pyproject.toml says >= 0.2 while we're using 0.2.2 (we've been using langchain in this project for a while, currently integrating some controlflow elements in).
Using the default model - which from the docs I believe is just a ChatOpenAI? - works fine, so AzureChatOpenAI should, right?Dan Godbold
10/31/2024, 2:44 PMcf.run(
^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/run.py", line 128, in run
results = run_tasks(
^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 997, in __call__
return run_task(
^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1512, in run_task
return run_task_sync(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1325, in run_task_sync
return engine.state if return_type == "state" else engine.result()
^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 457, in result
raise self._raised
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 763, in run_context
yield self
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1323, in run_task_sync
engine.call_task_fn(txn)
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 786, in call_task_fn
result = call_with_parameters(self.task.fn, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 206, in call_with_parameters
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/run.py", line 52, in run_tasks
orchestrator.run(
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 997, in __call__
return run_task(
^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1512, in run_task
return run_task_sync(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1325, in run_task_sync
return engine.state if return_type == "state" else engine.result()
^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 457, in result
raise self._raised
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 763, in run_context
yield self
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1323, in run_task_sync
engine.call_task_fn(txn)
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 786, in call_task_fn
result = call_with_parameters(self.task.fn, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 206, in call_with_parameters
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/orchestration/orchestrator.py", line 217, in run
self.run_agent_turn(
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 997, in __call__
return run_task(
^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1512, in run_task
return run_task_sync(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1325, in run_task_sync
return engine.state if return_type == "state" else engine.result()
^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 457, in result
raise self._raised
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 763, in run_context
yield self
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 1323, in run_task_sync
engine.call_task_fn(txn)
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 786, in call_task_fn
result = call_with_parameters(self.task.fn, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 206, in call_with_parameters
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/orchestration/orchestrator.py", line 372, in run_agent_turn
messages = self.compile_messages()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/orchestration/orchestrator.py", line 492, in compile_messages
llm_rules=self.agent.get_llm_rules(),
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/agents/agent.py", line 187, in get_llm_rules
return controlflow.llm.rules.rules_for_model(self.get_model())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/controlflow/llm/rules.py", line 74, in rules_for_model
return OpenAIRules(model=model)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/pydantic/main.py", line 212, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 480, in build_extra
values = _build_model_kwargs(values, all_required_field_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/langchain_core/utils/utils.py", line 236, in _build_model_kwargs
extra_kwargs = values.get("model_kwargs", {})
^^^^^^^^^^
File "/Users/dangodbold/src/github.com/expectai/acp-llm/.venv/lib/python3.12/site-packages/pydantic/main.py", line 856, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'AzureChatOpenAI' object has no attribute 'get'
Jeremiah
Dan Godbold
11/01/2024, 11:29 AMChatOpenAI
, but I think it's somewhere there in the model inheritance, somethings re-implemented for Azure in a way that breaks this (or not implemented in the first place).Jeremiah
Jeremiah
Jeremiah
Dan Godbold
11/06/2024, 8:42 AMDan Godbold
11/06/2024, 8:47 AMChatOpenAI | AzureChatOpenAI
rather than Union[ChatOpenAI, AzureChatOpenAI]
? Is there a difference under the covers?