-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
run_bundle.py
78 lines (64 loc) · 2.19 KB
/
run_bundle.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def post_install():
# if "_internal.zip" exists, unzip and remove
import os
if os.path.exists("_internal.zip"):
import zipfile
print("\nDecompressing internal binaries...\n")
with zipfile.ZipFile("_internal.zip", 'r') as zip_ref:
zip_ref.extractall("_internal")
os.remove("_internal.zip")
def run_bundle():
print("\nImporting dependencies, this may take a while...\n")
# dependencies to bundle
import ansio
import bs4
import docker
import duckduckgo_search
import faiss
from flask import Flask
import flask_basicauth
import inputimeout
import langchain.embeddings
import langchain_anthropic
import langchain_community
import langchain_google_genai
import langchain_groq
import langchain_huggingface
import langchain_mistralai
import langchain_ollama
import langchain_openai
import lxml_html_clean
import emoji
from emoji import unicode_codes
import markdown
import newspaper
import paramiko
import pypdf
import dotenv
import sentence_transformers
from tiktoken import model, registry
from tiktoken_ext import openai_public
import unstructured
import unstructured_client
import webcolors
# but do not bundle project files, these are to be imported at runtime
import sys
import os
import importlib.util
# Add the project_files directory to the Python path
project_files_dir = os.path.join(os.path.dirname(sys.executable), 'agent-zero-files')
sys.path.insert(0, project_files_dir)
# Dynamically load the 'run_ui' module
module_name = "run_ui"
module_path = os.path.join(project_files_dir, f"{module_name}.py")
# Load the module at runtime
spec = importlib.util.spec_from_file_location(module_name, module_path)
if spec and spec.loader:
run_ui = importlib.util.module_from_spec(spec)
spec.loader.exec_module(run_ui)
# Now you can call the function in the dynamically imported module
run_ui.run() # Call the 'run' function from run_ui
else:
raise Exception(f"Could not load {module_name} from {module_path}")
# post_install()
run_bundle()