core.section_processor¶
- class celi_framework.core.section_processor.SectionProcessor(current_section, system_message, initial_user_message, tool_descriptions, tool_implementations, primary_model_name, llm_cache, monitor_instructions, max_tokens, force_tool_every_n, seed=777, callback=None, model_url=None, token_counter=None)
Bases:
objectThis is the core processor that uses iterative calls to LLMs to manage the drafting process. Each SectionProcessor runs independently, working through a task list described in the JobDescription and using the tools it provides.
- async add_human_input(input)
- async builtin_review(edit_system_message=True)
-
callback:
Optional[CELIUpdateCallback] = None
- static check_for_duplicates(ongoing_chat)
-
current_section:
str
-
force_tool_every_n:
int
- static format_chat_messages(msgs)
- static format_message_content(m)
-
initial_user_message:
str
-
llm_cache:
bool
- async make_tool_calls(response)
-
max_tokens:
int
-
model_url:
Optional[str] = None
-
monitor_instructions:
str
-
primary_model_name:
str
- async process_iteration()
Run one iteration of the main execution loop for drafting documents.
- Within each iteration of the loop, the method performs the following operations:
Prepares a prompt for the language model based on the current conversation history.
- Processes the language model’s response, including handling any specified function calls, updating
the draft content, and managing the ongoing conversation context.
Checks if the iteration is in a loop.
If the section is complete, call builtin_review to check the resul and decide whether a redo is required.
- Returns:
True if the drafting is still in progress and another iteration should be run. False if the process should stop.
- static responses_since_last_tool_call(ongoing_chat)
- async run()
-
seed:
int= 777
-
system_message:
str
-
token_counter:
Optional[TokenCounter] = None
-
tool_descriptions:
List[ToolDescription]
-
tool_implementations:
ToolImplementations
- async celi_framework.core.section_processor.ask_split(user_prompt, system_message, model_name, max_tokens=0, seed=777, verbose=False, max_retries=7, wait_between_retries=2, temperature=0.0, timeout=120, tool_descriptions=None, model_url=None, json_mode=False, response_format=None, token_counter=None, force_tool_use=False)¶
Sends a prompt to the OpenAI API and returns the response, with retries on error.
user_prompt can be either a string or a list of messages.