Base Agent¶
- class oscopilot.agents.base_agent.BaseAgent[source]¶
Bases:
objectBaseAgent serves as the foundational class for all agents types within the system.
This class initializes the core attributes common across different agents, providing a unified interface for further specialization. Attributes include a language learning model, the execution environments, an action library, and a maximum iteration limit for agents operations.
- llm¶
Placeholder for a language learning model, initialized as None.
- environments¶
The execution environments for the agents, initialized as None.
- action_lib¶
A library of actions available to the agents, initialized as None.
- max_iter¶
The maximum number of iterations the agents can perform, initialized as None.
- extract_information(message, begin_str='[BEGIN]', end_str='[END]')[source]¶
Extracts substrings from a message that are enclosed within specified begin and end markers.
- Parameters:
message (str) – The message from which information is to be extracted.
begin_str (str) – The marker indicating the start of the information to be extracted.
end_str (str) – The marker indicating the end of the information to be extracted.
- Returns:
A list of extracted substrings found between the begin and end markers.
- Return type:
list[str]
- extract_json_from_string(text)[source]¶
Identifies and extracts JSON data embedded within a given string.
This method searches for JSON data within a string, specifically looking for JSON blocks that are marked with
`json`notation. It attempts to parse and return the first JSON object found.- Parameters:
text (str) – The text containing the JSON data to be extracted.
- Returns:
The parsed JSON data as a dictionary if successful. str: An error message indicating a parsing error or that no JSON data was found.
- Return type:
dict