core.job_description

class celi_framework.core.job_description.BaseDocToolImplementations(drafts_dir='target/celi_output/drafts', callback=None)

Bases: ToolImplementations, ABC

A base class for ToolImplementations that draft documents. Adds a standard update_draft_doc tool.

save_draft_section(doc_section, draft)

Saves a draft of the current section.

This must be called with the final output before calling complete_section and moving on to the next section.

Parameters:
  • doc_section – The section name to save

  • draft – The draft text

class celi_framework.core.job_description.JobDescription(**data)

Bases: BaseModel

Specifies a configuration for MasterTemplateFactory

This configuration file is a critical component of the automated document drafting framework, designed to work in tandem with the MasterTemplateFactory class. It outlines a series of structured tasks and instructions that guide the drafting process for various types of documents, emphasizing step-by-step clarity and comprehensive coverage of necessary content.

Key Components: - role: Specifies the user’s role in an interactive context, emphasizing active participation in defining the drafting objectives. - context: Establishes the theme of “Interactive Data Collection,” indicating a focus on user engagement and data-driven task generation for document drafting. - task_list: A comprehensive collection of tasks, each defined with a unique task name, a brief description, specific instructions, and examples. These tasks form the backbone of the document drafting process, guiding users or AI agents through each step required to compile a thorough and accurate document. - general_comments and user_message: Provide overarching guidance and specific instructions to users or AI agents undertaking the drafting tasks. These sections ensure that the drafting process is approached systematically, with clear expectations for each task’s completion. - pre_algo_instruct and post_algo_instruct: Introductory and concluding instructions that frame the drafting tasks within a broader context, helping to orient the user or AI agent to the document’s overall structure and objectives. - config: A dictionary consolidating all elements of the configuration, including the role of the user or AI agent, the context for the drafting tasks, and the structure of the task list. Additional parameters like include_prerequisites and final_output_task further customize the drafting guidance provided by the MasterTemplateFactory. - ‘include_schema_in_system_message’: A bool (defaults to True) indicating whether the system message should include the schema. This is useful if the different items in the schema relate to each other (like sections in a document), but not if they are independent (like different test cases in a benchmark) - ‘monitor_instructions’: Explicit items for the monitor to pay attention to.

Usage: This configuration file is intended for use with the MasterTemplateFactory class to generate dynamic, structured instructions for drafting or analyzing documents. By defining tasks, prerequisites, and contextual guidance, it enables the automated creation of detailed documents across a variety of fields, including but not limited to technical documentation, and research reporting.

Example Usage: The configuration is dynamically loaded by the MasterTemplateFactory to create a tailored set of instructions and tasks based on the specific requirements of the document being drafted. The factory class utilizes the task_list to generate a step-by-step guide for users or AI agents, incorporating general_comments and user_message to provide additional context and clarity.

By structuring the document drafting process around this configuration, the MasterTemplateFactory ensures that each section of the document is developed with precision, adhering to the required standards and content specifications outlined in the task_library.

context: str
general_comments: str
include_schema_in_system_message: bool
initial_user_message: str
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'context': FieldInfo(annotation=str, required=True), 'general_comments': FieldInfo(annotation=str, required=False, default=''), 'include_schema_in_system_message': FieldInfo(annotation=bool, required=False, default=True), 'initial_user_message': FieldInfo(annotation=str, required=True), 'monitor_instructions': FieldInfo(annotation=str, required=False, default=''), 'post_context_instruct': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'pre_context_instruct': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'role': FieldInfo(annotation=str, required=True), 'task_list': FieldInfo(annotation=List[Task], required=True), 'tool_implementations_class': FieldInfo(annotation=Type, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

monitor_instructions: str
post_context_instruct: Optional[str]
pre_context_instruct: Optional[str]
role: str
serialize_type(t, _info)
task_list: List[Task]
tool_implementations_class: Type
class celi_framework.core.job_description.Task(**data)

Bases: BaseModel

details: Dict[str, str | List[str] | Dict[str, Any]]
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'details': FieldInfo(annotation=Dict[str, Union[str, List[str], Dict[str, Any]]], required=True), 'task_name': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

task_name: str
with_references_resolved(task_numbering)

Update references in each field and generates a new Task with references replaced.

Return type:

Task

class celi_framework.core.job_description.ToolImplementations

Bases: ABC

Each public function in the class becomes a tool that the LLM can use.

There is one required function, def get_schema(self) -> Dict[str, str]. This function returns a dictionary describing the document sections. The processor will work through the sections, completing the defined tasks for each section. Each dictionary can have any string values, but it is intended to be a section number followed by a section name.

In addition to the get_schema function, the ToolImplementations class can have whatever other functions it needs to enable celi_framework. Each function should be documented with type hints and a doc string. The top section of the docstring will be included as the description of the overall function. If the function takes arguments, there should be a section called “Args:” that contains a list of the arguments to the function and descriptions of each. An example docstring is given below:

‘’’ Extracts text from specified sections of documents. It handles different document types and logs any errors or warnings encountered. Returns concatenated text from the specified sections of the documents. If there is no content for the section, <empty section> will be returned.

If the response contains “Error:”, then there was a problem with the function call.

Args:

sections_dict_str (str): A JSON string mapping document names to their respective section numbers. The json string will have the documents and sections in a dictionary. The sections values should correspond to an entry in the table of contents for the specified document.

‘’’

abstract get_schema()

This function returns a dictionary describing the document sections. The processor will work through the sections, completing the defined tasks for each section. Each dictionary can have any string values, but it is intended to be a section number followed by a section name.

Return type:

Dict[str, str]

celi_framework.core.job_description.encode_class_type(cls)
celi_framework.core.job_description.generate_tool_description(method)

Generates a tool description from a member function object.

Expects a docstring formatted like this one. It uses that for method and parameter descriptions. Uses type hints for determine parameter types

Return type:

ToolDescription

Parameters:

method (Callable) – A member function object to createc a ToolDescription for.

celi_framework.core.job_description.generate_tool_descriptions(cls)
Return type:

List[ToolDescription]

celi_framework.core.job_description.read_json_from_file(file_path)

Reads a JSON object from a file.

Parameters:

file_path – Path to the JSON file.

Returns:

The JSON object.

celi_framework.core.job_description.write_string_to_file(input_string, file_name, encoding='utf-8')

Writes a given string to a text file.

Args: input_string (str): The string to be written to the file. file_name (str): The name of the file where the string will be written.

Returns: None