lybic-guiagents 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lybic-guiagents might be problematic. Click here for more details.

Files changed (85) hide show
  1. desktop_env/__init__.py +1 -0
  2. desktop_env/actions.py +203 -0
  3. desktop_env/controllers/__init__.py +0 -0
  4. desktop_env/controllers/python.py +471 -0
  5. desktop_env/controllers/setup.py +882 -0
  6. desktop_env/desktop_env.py +509 -0
  7. desktop_env/evaluators/__init__.py +5 -0
  8. desktop_env/evaluators/getters/__init__.py +41 -0
  9. desktop_env/evaluators/getters/calc.py +15 -0
  10. desktop_env/evaluators/getters/chrome.py +1774 -0
  11. desktop_env/evaluators/getters/file.py +154 -0
  12. desktop_env/evaluators/getters/general.py +42 -0
  13. desktop_env/evaluators/getters/gimp.py +38 -0
  14. desktop_env/evaluators/getters/impress.py +126 -0
  15. desktop_env/evaluators/getters/info.py +24 -0
  16. desktop_env/evaluators/getters/misc.py +406 -0
  17. desktop_env/evaluators/getters/replay.py +20 -0
  18. desktop_env/evaluators/getters/vlc.py +86 -0
  19. desktop_env/evaluators/getters/vscode.py +35 -0
  20. desktop_env/evaluators/metrics/__init__.py +160 -0
  21. desktop_env/evaluators/metrics/basic_os.py +68 -0
  22. desktop_env/evaluators/metrics/chrome.py +493 -0
  23. desktop_env/evaluators/metrics/docs.py +1011 -0
  24. desktop_env/evaluators/metrics/general.py +665 -0
  25. desktop_env/evaluators/metrics/gimp.py +637 -0
  26. desktop_env/evaluators/metrics/libreoffice.py +28 -0
  27. desktop_env/evaluators/metrics/others.py +92 -0
  28. desktop_env/evaluators/metrics/pdf.py +31 -0
  29. desktop_env/evaluators/metrics/slides.py +957 -0
  30. desktop_env/evaluators/metrics/table.py +585 -0
  31. desktop_env/evaluators/metrics/thunderbird.py +176 -0
  32. desktop_env/evaluators/metrics/utils.py +719 -0
  33. desktop_env/evaluators/metrics/vlc.py +524 -0
  34. desktop_env/evaluators/metrics/vscode.py +283 -0
  35. desktop_env/providers/__init__.py +35 -0
  36. desktop_env/providers/aws/__init__.py +0 -0
  37. desktop_env/providers/aws/manager.py +278 -0
  38. desktop_env/providers/aws/provider.py +186 -0
  39. desktop_env/providers/aws/provider_with_proxy.py +315 -0
  40. desktop_env/providers/aws/proxy_pool.py +193 -0
  41. desktop_env/providers/azure/__init__.py +0 -0
  42. desktop_env/providers/azure/manager.py +87 -0
  43. desktop_env/providers/azure/provider.py +207 -0
  44. desktop_env/providers/base.py +97 -0
  45. desktop_env/providers/gcp/__init__.py +0 -0
  46. desktop_env/providers/gcp/manager.py +0 -0
  47. desktop_env/providers/gcp/provider.py +0 -0
  48. desktop_env/providers/virtualbox/__init__.py +0 -0
  49. desktop_env/providers/virtualbox/manager.py +463 -0
  50. desktop_env/providers/virtualbox/provider.py +124 -0
  51. desktop_env/providers/vmware/__init__.py +0 -0
  52. desktop_env/providers/vmware/manager.py +455 -0
  53. desktop_env/providers/vmware/provider.py +105 -0
  54. gui_agents/__init__.py +0 -0
  55. gui_agents/agents/Action.py +209 -0
  56. gui_agents/agents/__init__.py +0 -0
  57. gui_agents/agents/agent_s.py +832 -0
  58. gui_agents/agents/global_state.py +610 -0
  59. gui_agents/agents/grounding.py +651 -0
  60. gui_agents/agents/hardware_interface.py +129 -0
  61. gui_agents/agents/manager.py +568 -0
  62. gui_agents/agents/translator.py +132 -0
  63. gui_agents/agents/worker.py +355 -0
  64. gui_agents/cli_app.py +560 -0
  65. gui_agents/core/__init__.py +0 -0
  66. gui_agents/core/engine.py +1496 -0
  67. gui_agents/core/knowledge.py +449 -0
  68. gui_agents/core/mllm.py +555 -0
  69. gui_agents/tools/__init__.py +0 -0
  70. gui_agents/tools/tools.py +727 -0
  71. gui_agents/unit_test/__init__.py +0 -0
  72. gui_agents/unit_test/run_tests.py +65 -0
  73. gui_agents/unit_test/test_manager.py +330 -0
  74. gui_agents/unit_test/test_worker.py +269 -0
  75. gui_agents/utils/__init__.py +0 -0
  76. gui_agents/utils/analyze_display.py +301 -0
  77. gui_agents/utils/common_utils.py +263 -0
  78. gui_agents/utils/display_viewer.py +281 -0
  79. gui_agents/utils/embedding_manager.py +53 -0
  80. gui_agents/utils/image_axis_utils.py +27 -0
  81. lybic_guiagents-0.1.0.dist-info/METADATA +416 -0
  82. lybic_guiagents-0.1.0.dist-info/RECORD +85 -0
  83. lybic_guiagents-0.1.0.dist-info/WHEEL +5 -0
  84. lybic_guiagents-0.1.0.dist-info/licenses/LICENSE +201 -0
  85. lybic_guiagents-0.1.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,92 @@
1
+ import logging
2
+ import os
3
+ import os.path
4
+ import zipfile
5
+ from typing import List, Dict
6
+ from typing import Union, TypeVar
7
+
8
+ import lxml.html
9
+ from lxml.html import HtmlElement
10
+ from mutagen.easyid3 import EasyID3
11
+
12
+ from .general import diff_text_file
13
+ from .utils import _match_value_to_rule
14
+
15
+ logger = logging.getLogger("desktopenv.metric.others")
16
+
17
+
18
+ def process_epub(filename: str) -> List[str]:
19
+ file_list: List[str] = []
20
+
21
+ base_dir: str = filename + ".dir"
22
+ os.makedirs(base_dir, exist_ok=True)
23
+
24
+ try:
25
+ with zipfile.ZipFile(filename, "r") as z_f:
26
+ with z_f.open("toc.ncx") as in_f \
27
+ , open(os.path.join(base_dir, "toc.ncx"), "w") as out_f:
28
+ contents: str = in_f.read().decode()
29
+ contents = contents.splitlines()
30
+ for l in contents:
31
+ if "navPoint" not in l:
32
+ out_f.write(l + "\n")
33
+ file_list.append(os.path.join(base_dir, "toc.ncx"))
34
+ with z_f.open("content.opf") as in_f \
35
+ , open(os.path.join(base_dir, "content.opf"), "w") as out_f:
36
+ contents: str = in_f.read().decode()
37
+ contents = contents.splitlines()
38
+ for l in contents:
39
+ if "dc:identifier" not in l:
40
+ out_f.write(l + "\n")
41
+ file_list.append(os.path.join(base_dir, "content.opf"))
42
+ for f_n in z_f.namelist():
43
+ if f_n.endswith(".html"):
44
+ with z_f.open(f_n) as in_f \
45
+ , open(os.path.join(base_dir, f_n), "w") as out_f:
46
+ html: HtmlElement = lxml.html.fromstring(
47
+ ''.join(filter(lambda ch: ch != "\n" and ch != "\r"
48
+ , in_f.read().decode()
49
+ )
50
+ ).encode()
51
+ )
52
+ out_f.write(lxml.html.tostring(html, pretty_print=True, encoding="unicode"))
53
+ file_list.append(os.path.join(base_dir, f_n))
54
+ logger.debug("%s: %s", filename, file_list)
55
+ return list(sorted(file_list))
56
+ except zipfile.BadZipFile:
57
+ return []
58
+
59
+
60
+ def compare_epub(result: str, expected: str) -> float:
61
+ if result is None:
62
+ return 0.
63
+ result_files: List[str] = process_epub(result)
64
+ expected_files: List[str] = process_epub(expected)
65
+
66
+ metric: float = 0.
67
+ for f1, f2 in zip(result_files, expected_files):
68
+ current_metric: float = diff_text_file(f1, f2)
69
+ logger.debug("%s vs %s: %f", f1, f2, current_metric)
70
+ metric += current_metric
71
+ if len(result_files) > 0:
72
+ metric /= len(result_files)
73
+ return metric
74
+
75
+
76
+ V = TypeVar("Value")
77
+
78
+
79
+ def check_mp3_meta(result: str, meta: Dict[str, Dict[str, Union[str, V]]]) -> bool:
80
+ # checks using _match_value_to_rule
81
+ if result is None:
82
+ return 0.
83
+
84
+ id3_dict = EasyID3(result)
85
+ metric: bool = True
86
+ for k, r in meta.items():
87
+ value = id3_dict.get(k, "")
88
+ if isinstance(value, list):
89
+ value: str = ",".join(value)
90
+ logger.debug("%s.%s: %s", result, k, value)
91
+ metric = metric and _match_value_to_rule(value, r)
92
+ return float(metric)
@@ -0,0 +1,31 @@
1
+ import operator
2
+ from typing import Any
3
+ from typing import Dict
4
+
5
+ import fitz # PyMuPDF
6
+ from pypdf import PdfReader
7
+
8
+
9
+ def check_pdf_pages(pdf_file: str, rules: Dict[str, Any]) -> float:
10
+ if pdf_file is None:
11
+ return 0.0
12
+ reader = PdfReader(pdf_file)
13
+ nb_pages: int = len(reader.pages)
14
+ return float(getattr(operator, rules["relation"])(nb_pages, rules["ref_value"]))
15
+
16
+
17
+ def extract_answers_from_pdf(pdf_file):
18
+ doc = fitz.open(pdf_file)
19
+ answers = []
20
+
21
+ for page in doc:
22
+ text = page.get_text()
23
+ lines = text.split('\n')
24
+ for line in lines:
25
+ if line.strip():
26
+ parts = line.split('=')
27
+ if len(parts) > 1:
28
+ answer = parts[-1].strip()
29
+ answers.append(answer)
30
+
31
+ return answers