Test whether LLM is able to GENERATE nested structured output.
(
test_settings: Settings,
use_functions_api: bool,
)
| 137 | |
| 138 | @pytest.mark.parametrize("use_functions_api", [False, True]) |
| 139 | def test_llm_structured_output_nested( |
| 140 | test_settings: Settings, |
| 141 | use_functions_api: bool, |
| 142 | ): |
| 143 | """ |
| 144 | Test whether LLM is able to GENERATE nested structured output. |
| 145 | """ |
| 146 | set_global(test_settings) |
| 147 | agent = ChatAgent(strict_cfg) |
| 148 | agent.config.use_functions_api = use_functions_api |
| 149 | agent.config.use_tools = not use_functions_api |
| 150 | agent.config.use_tools_api = True |
| 151 | agent.enable_message(PresidentTool) |
| 152 | country = "France" |
| 153 | prompt = f""" |
| 154 | Show me an example of a President of {country}. |
| 155 | Make sure you use the `{PresidentTool.name()}` |
| 156 | correctly with ALL the required fields! |
| 157 | """ |
| 158 | llm_msg = agent.llm_response_forget(prompt) |
| 159 | assert isinstance(agent.get_tool_messages(llm_msg)[0], PresidentTool) |
| 160 | assert country == agent.agent_response(llm_msg).content |
| 161 | |
| 162 | |
| 163 | @pytest.mark.parametrize("instructions", [False, True]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…