diff --git a/libs/core/kiln_ai/adapters/base_adapter.py b/libs/core/kiln_ai/adapters/base_adapter.py index bf47b97..58468d2 100644 --- a/libs/core/kiln_ai/adapters/base_adapter.py +++ b/libs/core/kiln_ai/adapters/base_adapter.py @@ -8,11 +8,11 @@ class BaseAdapter(metaclass=ABCMeta): def __init__(self, kiln_task: Task): self.kiln_task = kiln_task - self._is_structured = self.kiln_task.output_json_schema is not None + self._is_structured_output = self.kiln_task.output_json_schema is not None async def invoke(self, input: str) -> Dict | str: result = await self._run(input) - if self._is_structured: + if self._is_structured_output: if not isinstance(result, dict): raise RuntimeError(f"structured response is not a dict: {result}") if self.kiln_task.output_json_schema is None: diff --git a/libs/core/kiln_ai/adapters/langchain_adapters.py b/libs/core/kiln_ai/adapters/langchain_adapters.py index 0d57f11..cb70988 100644 --- a/libs/core/kiln_ai/adapters/langchain_adapters.py +++ b/libs/core/kiln_ai/adapters/langchain_adapters.py @@ -28,7 +28,7 @@ def __init__( raise ValueError( "model_name and provider must be provided if custom_model is not provided" ) - if self._is_structured: + if self._is_structured_output: if not hasattr(self.model, "with_structured_output") or not callable( getattr(self.model, "with_structured_output") ): @@ -54,7 +54,7 @@ def __init__( def adapter_specific_instructions(self) -> str | None: # TODO: would be better to explicitly use bind_tools:tool_choice="task_response" here - if self._is_structured: + if self._is_structured_output: return "Always respond with a tool call. Never respond with a human readable message." return None @@ -66,7 +66,7 @@ async def _run(self, input: str) -> Dict | str: HumanMessage(content=user_msg), ] response = self.model.invoke(messages) - if self._is_structured: + if self._is_structured_output: if ( not isinstance(response, dict) or "parsed" not in response diff --git a/libs/core/kiln_ai/adapters/prompt_builders.py b/libs/core/kiln_ai/adapters/prompt_builders.py index 45e4fb8..c4ddbbc 100644 --- a/libs/core/kiln_ai/adapters/prompt_builders.py +++ b/libs/core/kiln_ai/adapters/prompt_builders.py @@ -8,7 +8,7 @@ def build_prompt(self) -> str: # TODO: this is just a quick version. Formatting and best practices TBD if len(self.task.requirements()) > 0: base_prompt += ( - "\n\nYour response should respectthe following requirements:\n" + "\n\nYour response should respect the following requirements:\n" ) # iterate requirements, formatting them in numbereed list like 1) task.instruction\n2)... for i, requirement in enumerate(self.task.requirements()): @@ -17,7 +17,7 @@ def build_prompt(self) -> str: if self.adapter is not None: adapter_instructions = self.adapter.adapter_specific_instructions() if adapter_instructions is not None: - base_prompt += f"\n\n{adapter_instructions}\n\n" + base_prompt += f"\n\n{adapter_instructions}" return base_prompt