Module core.navigation

Functions

def get_model_name(llm: llama_index.core.base.llms.base.BaseLLM) ‑> str

Classes

class NavigationControl (driver: lavague.core.base_driver.BaseDriver, time_between_actions: float = 1.5, logger: lavague.core.logger.AgentLogger = None, navigation_engine: Optional[NavigationEngine] = None)

Helper class that provides a standard way to create an ABC using inheritance.

Ancestors

  • lavague.core.base_engine.BaseEngine
  • abc.ABC
  • lavague.core.logger.Loggable
  • lavague.core.display.Display

Class variables

var driver : lavague.core.base_driver.BaseDriver
var logger : lavague.core.logger.AgentLogger
var time_between_actions : float

Methods

def execute_instruction(self, instruction: str) ‑> lavague.core.base_engine.ActionResult
def set_display(self, display: bool)
def set_is_full_page(self, is_fullpage: bool)
class NavigationEngine (driver: lavague.core.base_driver.BaseDriver, llm: llama_index.core.base.llms.base.BaseLLM = None, rephraser: Rephraser = None, retriever: lavague.core.retrievers.BaseHtmlRetriever = None, prompt_template: llama_index.core.prompts.base.PromptTemplate = PromptTemplate(metadata={'prompt_type': <PromptType.CUSTOM: 'custom'>}, template_vars=['driver_capability', 'context_str', '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}\nQuery: {query_str}\nCompletion:\n\n'), extractor: lavague.core.extractors.BaseExtractor = <lavague.core.extractors.DynamicExtractor object>, time_between_actions: float = 1.5, n_attempts: int = 5, logger: lavague.core.logger.AgentLogger = None, display: bool = False, raise_on_error: bool = False)

NavigationEngine leverages the llm model and the to output code from the prompt and the html page.

Args

driver (BaseDriver):
The Web driver used to interact with the headless browser
llm (BaseLLM)
llama-index LLM that will generate the action
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

Ancestors

  • lavague.core.base_engine.BaseEngine
  • abc.ABC
  • lavague.core.logger.Loggable
  • lavague.core.display.Display

Static methods

def from_context(context: lavague.core.context.Context, driver: lavague.core.base_driver.BaseDriver, rephraser: Rephraser = None, retriever: lavague.core.retrievers.BaseHtmlRetriever = None, prompt_template: llama_index.core.prompts.base.PromptTemplate = PromptTemplate(metadata={'prompt_type': <PromptType.CUSTOM: 'custom'>}, template_vars=['driver_capability', 'context_str', '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}\nQuery: {query_str}\nCompletion:\n\n'), extractor: lavague.core.extractors.BaseExtractor = <lavague.core.extractors.DynamicExtractor object>) ‑> NavigationEngine

Create an NavigationEngine from a context

Methods

def add_knowledge(self, knowledge: str)
def execute_instruction(self, instruction: str) ‑> lavague.core.base_engine.ActionResult

Generates code and executes it to answer the instruction

Args

instruction (str): The instruction to perform

Return

bool: True if the code was executed without error Any: The output of navigation is always None

def execute_instruction_gradio(self, instruction: str, action_engine: Any)

Generates code and executes it to answer the instruction

Args

instruction (str): The instruction to perform

Return

bool: True if the code was executed without error Any: The output of navigation is always None

def get_action(self, query: str) ‑> Optional[str]

Generate the code from a query

Args

query (str): Instructions given at the end of the prompt to tell the model what to do on the html page

Return

str: The generated code

def get_action_from_context(self, context: str, query: str) ‑> str

Generate the code from a query and a context

def get_nodes(self, query: str) ‑> List[str]

Get the nodes from the html page

Args

query (str): The query to search for

Return

List[str]: The nodes

def set_display(self, display: bool)
class Rephraser (llm: llama_index.core.base.llms.base.BaseLLM = None, prompt: llama_index.core.prompts.base.PromptTemplate = <string.Template object>)

Methods

def rephrase_query(self, instruction: str) ‑> str

Rephrase the query

Args

instruction (str): The instruction to rephrase for the retriever

Return

str: The rephrased query