Skip to content

Commit

Permalink
fix python engine
Browse files Browse the repository at this point in the history
  • Loading branch information
lyie28 committed Aug 26, 2024
1 parent 73cbca4 commit fe3eeb0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lavague-core/lavague/core/python_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PythonEngine(BaseEngine):
ocr_llm: BaseLLM
batch_size: int
confidence_threshold: float
fallback_theshold: float
temp_screenshots_path: str
n_search_attempts: int

Expand All @@ -54,6 +55,7 @@ def __init__(
display: bool = False,
batch_size: int = 5,
confidence_threshold: float = 0.85,
fallback_threshold: float = 0.65,
temp_screenshots_path="./tmp_screenshots",
n_search_attemps=10,
):
Expand All @@ -71,6 +73,7 @@ def __init__(
self.confidence_threshold = confidence_threshold
self.temp_screenshots_path = temp_screenshots_path
self.n_search_attempts = n_search_attemps
self.fallback_theshold = fallback_threshold

@classmethod
def from_context(cls, context: Context, driver: BaseDriver):
Expand Down Expand Up @@ -152,7 +155,7 @@ def perform_fallback(self, prompt, instruction) -> str:
image_documents=screenshots, prompt=prompt
).text.strip()
output_dict = self.extract_json(output)
context_score = output_dict.get("score")
context_score = output_dict.get("score", 0)
output = output_dict.get("ret")
memory += output

Expand Down Expand Up @@ -208,7 +211,7 @@ def execute_instruction(self, instruction: str) -> ActionResult:

try:
if (
output_dict.get("score", 0) < self.confidence_threshold
output_dict.get("score", 0) < self.fallback_theshold
): # use fallback method
output = self.perform_fallback(prompt=prompt, instruction=instruction)

Expand Down

0 comments on commit fe3eeb0

Please sign in to comment.