compass.plugin.one_shot.generators.generate_query_templates#
- async generate_query_templates(schema_llm, extraction_schema, add_think_prompt=True)[source]#
Generate 5-10 search query templates for document retrieval
- Parameters:
schema_llm (
SchemaOutputLLMCaller) – A LLM caller configured to output structured data according to a provided schema. This function relies on the LLM to generate the query templates, so the quality of the generated templates will depend on the capabilities of the LLM being used and how well it can interpret the provided extraction schema. Highly recommended to use the most powerful/capable instruction-tuned model for this function.extraction_schema (
dict) – A dictionary representing the schema of the desired extraction task. The query templates will be generated based on the content of this schema, so it should be as detailed and specific as possible, and should include domain-specific terminology if applicable. See the wind ordinance schema for an example.add_think_prompt (
bool, optional) – Option to add a “Think before you answer” instruction to the end of the prompt (useful for thinking models). By default,True.
- Returns:
listofstr– List of 5-10 query templates as strings, each including the literal placeholder “{jurisdiction}” for later formatting.- Raises:
COMPASSRuntimeError – If the LLM fails to return any valid query templates after 3 attempts.