Spaces:
Sleeping
Sleeping
Update src/webui/webui_manager.py
Browse files- src/webui/webui_manager.py +34 -97
src/webui/webui_manager.py
CHANGED
|
@@ -1,97 +1,34 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
self.bu_response_event: Optional[asyncio.Event] = None
|
| 36 |
-
self.bu_user_help_response: Optional[str] = None
|
| 37 |
-
self.bu_current_task: Optional[asyncio.Task] = None
|
| 38 |
-
self.bu_agent_task_id: Optional[str] = None
|
| 39 |
-
|
| 40 |
-
def init_deep_research_agent(self) -> None:
|
| 41 |
-
self.dr_agent: Optional[DeepResearchAgent] = None
|
| 42 |
-
self.dr_current_task = None
|
| 43 |
-
self.dr_agent_task_id: Optional[str] = None
|
| 44 |
-
self.dr_save_dir: Optional[str] = None
|
| 45 |
-
|
| 46 |
-
def add_components(self, tab_name: str, components_dict: dict[str, "Component"]) -> None:
|
| 47 |
-
for comp_name, component in components_dict.items():
|
| 48 |
-
comp_id = f"{tab_name}.{comp_name}"
|
| 49 |
-
self.id_to_component[comp_id] = component
|
| 50 |
-
self.component_to_id[component] = comp_id
|
| 51 |
-
|
| 52 |
-
def get_components(self) -> list["Component"]:
|
| 53 |
-
return list(self.id_to_component.values())
|
| 54 |
-
|
| 55 |
-
def get_component_by_id(self, comp_id: str) -> "Component":
|
| 56 |
-
return self.id_to_component[comp_id]
|
| 57 |
-
|
| 58 |
-
def get_id_by_component(self, comp: "Component") -> str:
|
| 59 |
-
return self.component_to_id[comp]
|
| 60 |
-
|
| 61 |
-
def save_config(self, components: Dict["Component", str]) -> None:
|
| 62 |
-
cur_settings = {}
|
| 63 |
-
for comp in components:
|
| 64 |
-
if not isinstance(comp, gr.Button) and not isinstance(comp, gr.File) and str(
|
| 65 |
-
getattr(comp, "interactive", True)).lower() != "false":
|
| 66 |
-
comp_id = self.get_id_by_component(comp)
|
| 67 |
-
cur_settings[comp_id] = components[comp]
|
| 68 |
-
|
| 69 |
-
config_name = datetime.now().strftime("%Y%m%d-%H%M%S")
|
| 70 |
-
with open(os.path.join(self.settings_save_dir, f"{config_name}.json"), "w") as fw:
|
| 71 |
-
json.dump(cur_settings, fw, indent=4)
|
| 72 |
-
|
| 73 |
-
return os.path.join(self.settings_save_dir, f"{config_name}.json")
|
| 74 |
-
|
| 75 |
-
def load_config(self, config_path: str):
|
| 76 |
-
with open(config_path, "r") as fr:
|
| 77 |
-
ui_settings = json.load(fr)
|
| 78 |
-
|
| 79 |
-
update_components = {}
|
| 80 |
-
for comp_id, comp_val in ui_settings.items():
|
| 81 |
-
if comp_id in self.id_to_component:
|
| 82 |
-
comp = self.id_to_component[comp_id]
|
| 83 |
-
if comp.__class__.__name__ == "Chatbot":
|
| 84 |
-
update_components[comp] = comp.__class__(value=comp_val, type="messages")
|
| 85 |
-
else:
|
| 86 |
-
update_components[comp] = comp.__class__(value=comp_val)
|
| 87 |
-
if comp_id == "agent_settings.planner_llm_provider":
|
| 88 |
-
yield update_components
|
| 89 |
-
time.sleep(0.1)
|
| 90 |
-
|
| 91 |
-
config_status = self.id_to_component["load_save_config.config_status"]
|
| 92 |
-
update_components.update(
|
| 93 |
-
{
|
| 94 |
-
config_status: config_status.__class__(value=f"Successfully loaded config: {config_path}")
|
| 95 |
-
}
|
| 96 |
-
)
|
| 97 |
-
yield update_components
|
|
|
|
| 1 |
+
# UI
|
| 2 |
+
gradio==5.27.0
|
| 3 |
+
pyperclip==1.9.0
|
| 4 |
+
|
| 5 |
+
# Web scraping / HTML helpers
|
| 6 |
+
trafilatura
|
| 7 |
+
lxml_html_clean
|
| 8 |
+
html2text
|
| 9 |
+
beautifulsoup4
|
| 10 |
+
uuid-utils
|
| 11 |
+
json-repair
|
| 12 |
+
|
| 13 |
+
# Core Python packages
|
| 14 |
+
pydantic>=2.9.2
|
| 15 |
+
pydantic-settings>=2.6.1
|
| 16 |
+
fastapi>=0.115.5
|
| 17 |
+
python-dotenv
|
| 18 |
+
|
| 19 |
+
# Browser / UI helpers
|
| 20 |
+
browser-use>=0.1.48
|
| 21 |
+
playwright>=1.49.1
|
| 22 |
+
|
| 23 |
+
# LangChain ecosystem (working combination)
|
| 24 |
+
langchain==0.3.48
|
| 25 |
+
langchain-core==0.3.48
|
| 26 |
+
langchain-community>=0.3.14,<0.4.0
|
| 27 |
+
langchain-mcp-adapters>=0.2.0,<0.3.0
|
| 28 |
+
mcp>=1.0.0
|
| 29 |
+
langchain-mistralai==0.2.4
|
| 30 |
+
langchain-ibm==0.3.10
|
| 31 |
+
langgraph==0.3.34
|
| 32 |
+
|
| 33 |
+
# Local / custom modules
|
| 34 |
+
MainContentExtractor==0.0.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|