camel.data_collector package#
Submodules#
camel.data_collector.alpaca_collector module#
- class camel.data_collector.alpaca_collector.AlpacaDataCollector[source]#
Bases:
BaseDataCollector
- llm_convert(converter: OpenAISchemaConverter | None = None, prompt: str | None = None) Dict[str, str] [source]#
Convert collected data using an LLM schema converter.
- Parameters:
converter (Optional[OpenAISchemaConverter], optional) β The converter to use. (default:
OpenAISchemaConverter
)prompt (Optional[str], optional) β Prompt to guide the conversion. (default:
DEFAULT_CONVERTER_PROMPTS
)
- Returns:
The converted data.
- Return type:
Dict[str, str]
- Raises:
ValueError β If no agent is injected or data cannot be collected.
camel.data_collector.base module#
- class camel.data_collector.base.BaseDataCollector[source]#
Bases:
ABC
Base class for data collectors.
- get_agent_history(name: str) List[CollectorData] [source]#
Get the message history of an agent.
- Parameters:
name (str) β The name of the agent.
- Returns:
The message history of the agent
- Return type:
List[CollectorData]
- abstract llm_convert(converter: Any, prompt: str | None = None) Any [source]#
Convert the collected data.
- property recording: bool#
Whether the collector is recording.
- reset(reset_agents: bool = True)[source]#
Reset the collector.
- Parameters:
reset_agents (bool, optional) β Whether to reset the agents. Defaults to True.
- step(role: Literal['user', 'assistant', 'system', 'tool'], name: str | None = None, message: str | None = None, function_call: Dict[str, Any] | None = None) Self [source]#
Record a message.
- Parameters:
role (Literal["user", "assistant", "system", "tool"]) β The role of the message.
name (Optional[str], optional) β The name of the agent. (default:
None
)message (Optional[str], optional) β The message to record. (default:
None
)function_call (Optional[Dict[str, Any]], optional) β The function call to record. (default:
None
)
- Returns:
The data collector.
- Return type:
Self
- class camel.data_collector.base.CollectorData(id: UUID, name: str, role: Literal['user', 'assistant', 'system', 'tool'], message: str | None = None, function_call: Dict[str, Any] | None = None)[source]#
Bases:
object
- static from_context(name, context: Dict[str, Any]) CollectorData [source]#
Create a data collector from a context.
- Parameters:
name (str) β The name of the agent.
context (Dict[str, Any]) β The context.
- Returns:
The data collector.
- Return type:
Module contents#
- class camel.data_collector.AlpacaDataCollector[source]#
Bases:
BaseDataCollector
- llm_convert(converter: OpenAISchemaConverter | None = None, prompt: str | None = None) Dict[str, str] [source]#
Convert collected data using an LLM schema converter.
- Parameters:
converter (Optional[OpenAISchemaConverter], optional) β The converter to use. (default:
OpenAISchemaConverter
)prompt (Optional[str], optional) β Prompt to guide the conversion. (default:
DEFAULT_CONVERTER_PROMPTS
)
- Returns:
The converted data.
- Return type:
Dict[str, str]
- Raises:
ValueError β If no agent is injected or data cannot be collected.
- class camel.data_collector.BaseDataCollector[source]#
Bases:
ABC
Base class for data collectors.
- get_agent_history(name: str) List[CollectorData] [source]#
Get the message history of an agent.
- Parameters:
name (str) β The name of the agent.
- Returns:
The message history of the agent
- Return type:
List[CollectorData]
- abstract llm_convert(converter: Any, prompt: str | None = None) Any [source]#
Convert the collected data.
- property recording: bool#
Whether the collector is recording.
- reset(reset_agents: bool = True)[source]#
Reset the collector.
- Parameters:
reset_agents (bool, optional) β Whether to reset the agents. Defaults to True.
- step(role: Literal['user', 'assistant', 'system', 'tool'], name: str | None = None, message: str | None = None, function_call: Dict[str, Any] | None = None) Self [source]#
Record a message.
- Parameters:
role (Literal["user", "assistant", "system", "tool"]) β The role of the message.
name (Optional[str], optional) β The name of the agent. (default:
None
)message (Optional[str], optional) β The message to record. (default:
None
)function_call (Optional[Dict[str, Any]], optional) β The function call to record. (default:
None
)
- Returns:
The data collector.
- Return type:
Self
Bases:
BaseDataCollector
Convert the collected data into a dictionary.
Convert collected data using an LLM schema converter.
- Parameters:
converter (Optional[OpenAISchemaConverter], optional) β The converter to use. (default:
OpenAISchemaConverter
)prompt (Optional[str], optional) β Prompt to guide the conversion. (default:
DEFAULT_CONVERTER_PROMPTS
)
- Returns:
The converted data.
- Return type:
Dict[str, str]
- Raises:
ValueError β If no agent is injected or data cannot be collected.
Inject an agent into the data collector.