Module core.action_engine
Classes
class ActionEngine (driver: BaseDriver,
navigation_engine: BaseEngine = None,
python_engine: BaseEngine = None,
navigation_control: BaseEngine = None,
llm: BaseLLM = None,
embedding: BaseEmbedding = None,
retriever: BaseHtmlRetriever = None,
prompt_template: PromptTemplate = PromptTemplate(metadata={'prompt_type': <PromptType.CUSTOM: 'custom'>}, template_vars=['driver_capability', 'context_str', 'authorized_xpaths', 'query_str'], kwargs={}, output_parser=None, template_var_mappings=None, function_mappings=None, template='\n{driver_capability}\n\nHere is a the next example to answer:\n\nHTML:\n{context_str}\nAuthorized Xpaths: {authorized_xpaths}\nQuery: {query_str}\nCompletion:\n\n'),
extractor: BaseExtractor = <lavague.core.extractors.DynamicExtractor object>,
time_between_actions: float = 1.5,
n_attempts: int = 5,
logger: AgentLogger = None,
extraction_llm: Optional[BaseLLM] = None)-
ActionEngine is a wrapper that instantiate every other engines (Navigation Engine, Python Engine, Navigation Control)
Args
- driver (
BaseDriver): - The Web driver used to interact with the headless browser
- python_engine (
BaseActionEngine) - Python Engine for generating code that doesn't interact with an html page.
- navigation_control (
BaseActionEngine) - Navigation Control
- llm (
BaseLLM) - llama-index LLM that will generate the action
- embedding (
BaseEmbedding) - llama-index Embedding model
- retriever (
BaseHtmlRetriever) - Specify which algorithm will be used for RAG
- prompt_template (
PromptTemplate) - Squelette of the final prompt
- extractor (
BaseExtractor) - Specify how to extract the final code from the llm answer
- time_between_actions (
float) - Time between each action
logger- (
AgentLogger) Logger to log the actions taken by the agent
Static methods
def from_context(context: Context,
driver: BaseDriver,
navigation_engine: BaseEngine = None,
python_engine: BaseEngine = None,
navigation_control: BaseEngine = None,
retriever: BaseHtmlRetriever = None,
prompt_template: PromptTemplate = PromptTemplate(metadata={'prompt_type': <PromptType.CUSTOM: 'custom'>}, template_vars=['driver_capability', 'context_str', 'authorized_xpaths', 'query_str'], kwargs={}, output_parser=None, template_var_mappings=None, function_mappings=None, template='\n{driver_capability}\n\nHere is a the next example to answer:\n\nHTML:\n{context_str}\nAuthorized Xpaths: {authorized_xpaths}\nQuery: {query_str}\nCompletion:\n\n'),
extractor: BaseExtractor = <lavague.core.extractors.DynamicExtractor object>,
time_between_actions: float = 1.5,
n_attempts: int = 5,
logger: AgentLogger = None) ‑> ActionEngine-
Create an ActionEngine from a context
Methods
def dispatch_instruction(self, next_engine_name: str, instruction: str) ‑> lavague.core.base_engine.ActionResult-
Dispatch the instruction to the appropriate ActionEngine
Args
next_engine_name (
str): The name of the engine to call instruction (str): The instruction to performReturn
bool: True if the code was executed without errorAny: The output of the code def dispatch_instruction_gradio(self, next_engine_name: str, instruction: str)-
Dispatch the instruction to the appropriate ActionEngine
Args
next_engine_name (
str): The name of the engine to call instruction (str): The instruction to performReturn
bool: True if the code was executed without errorAny: The output of the code def get_embedding_name(self)def get_llm_name(self)def set_display_all(self, display: bool)def set_gradio_mode_all(self, gradio_mode: bool, objective, url_input, image_display, history)def set_logger_all(self, logger: AgentLogger)
- driver (