symbolicai 0.21.0__py3-none-any.whl → 1.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.
- symai/__init__.py +269 -173
- symai/backend/base.py +123 -110
- symai/backend/engines/drawing/engine_bfl.py +45 -44
- symai/backend/engines/drawing/engine_gpt_image.py +112 -97
- symai/backend/engines/embedding/engine_llama_cpp.py +63 -52
- symai/backend/engines/embedding/engine_openai.py +25 -21
- symai/backend/engines/execute/engine_python.py +19 -18
- symai/backend/engines/files/engine_io.py +104 -95
- symai/backend/engines/imagecaptioning/engine_blip2.py +28 -24
- symai/backend/engines/imagecaptioning/engine_llavacpp_client.py +102 -79
- symai/backend/engines/index/engine_pinecone.py +124 -97
- symai/backend/engines/index/engine_qdrant.py +1011 -0
- symai/backend/engines/index/engine_vectordb.py +84 -56
- symai/backend/engines/lean/engine_lean4.py +96 -52
- symai/backend/engines/neurosymbolic/__init__.py +41 -13
- symai/backend/engines/neurosymbolic/engine_anthropic_claudeX_chat.py +330 -248
- symai/backend/engines/neurosymbolic/engine_anthropic_claudeX_reasoning.py +329 -264
- symai/backend/engines/neurosymbolic/engine_cerebras.py +328 -0
- symai/backend/engines/neurosymbolic/engine_deepseekX_reasoning.py +118 -88
- symai/backend/engines/neurosymbolic/engine_google_geminiX_reasoning.py +344 -299
- symai/backend/engines/neurosymbolic/engine_groq.py +173 -115
- symai/backend/engines/neurosymbolic/engine_huggingface.py +114 -84
- symai/backend/engines/neurosymbolic/engine_llama_cpp.py +144 -118
- symai/backend/engines/neurosymbolic/engine_openai_gptX_chat.py +415 -307
- symai/backend/engines/neurosymbolic/engine_openai_gptX_reasoning.py +394 -231
- symai/backend/engines/ocr/engine_apilayer.py +23 -27
- symai/backend/engines/output/engine_stdout.py +10 -13
- symai/backend/engines/{webscraping → scrape}/engine_requests.py +101 -54
- symai/backend/engines/search/engine_openai.py +100 -88
- symai/backend/engines/search/engine_parallel.py +665 -0
- symai/backend/engines/search/engine_perplexity.py +44 -45
- symai/backend/engines/search/engine_serpapi.py +37 -34
- symai/backend/engines/speech_to_text/engine_local_whisper.py +54 -51
- symai/backend/engines/symbolic/engine_wolframalpha.py +15 -9
- symai/backend/engines/text_to_speech/engine_openai.py +20 -26
- symai/backend/engines/text_vision/engine_clip.py +39 -37
- symai/backend/engines/userinput/engine_console.py +5 -6
- symai/backend/mixin/__init__.py +13 -0
- symai/backend/mixin/anthropic.py +48 -38
- symai/backend/mixin/deepseek.py +6 -5
- symai/backend/mixin/google.py +7 -4
- symai/backend/mixin/groq.py +2 -4
- symai/backend/mixin/openai.py +140 -110
- symai/backend/settings.py +87 -20
- symai/chat.py +216 -123
- symai/collect/__init__.py +7 -1
- symai/collect/dynamic.py +80 -70
- symai/collect/pipeline.py +67 -51
- symai/collect/stats.py +161 -109
- symai/components.py +707 -360
- symai/constraints.py +24 -12
- symai/core.py +1857 -1233
- symai/core_ext.py +83 -80
- symai/endpoints/api.py +166 -104
- symai/extended/.DS_Store +0 -0
- symai/extended/__init__.py +46 -12
- symai/extended/api_builder.py +29 -21
- symai/extended/arxiv_pdf_parser.py +23 -14
- symai/extended/bibtex_parser.py +9 -6
- symai/extended/conversation.py +156 -126
- symai/extended/document.py +50 -30
- symai/extended/file_merger.py +57 -14
- symai/extended/graph.py +51 -32
- symai/extended/html_style_template.py +18 -14
- symai/extended/interfaces/blip_2.py +2 -3
- symai/extended/interfaces/clip.py +4 -3
- symai/extended/interfaces/console.py +9 -1
- symai/extended/interfaces/dall_e.py +4 -2
- symai/extended/interfaces/file.py +2 -0
- symai/extended/interfaces/flux.py +4 -2
- symai/extended/interfaces/gpt_image.py +16 -7
- symai/extended/interfaces/input.py +2 -1
- symai/extended/interfaces/llava.py +1 -2
- symai/extended/interfaces/{naive_webscraping.py → naive_scrape.py} +4 -3
- symai/extended/interfaces/naive_vectordb.py +9 -10
- symai/extended/interfaces/ocr.py +5 -3
- symai/extended/interfaces/openai_search.py +2 -0
- symai/extended/interfaces/parallel.py +30 -0
- symai/extended/interfaces/perplexity.py +2 -0
- symai/extended/interfaces/pinecone.py +12 -9
- symai/extended/interfaces/python.py +2 -0
- symai/extended/interfaces/serpapi.py +3 -1
- symai/extended/interfaces/terminal.py +2 -4
- symai/extended/interfaces/tts.py +3 -2
- symai/extended/interfaces/whisper.py +3 -2
- symai/extended/interfaces/wolframalpha.py +2 -1
- symai/extended/metrics/__init__.py +11 -1
- symai/extended/metrics/similarity.py +14 -13
- symai/extended/os_command.py +39 -29
- symai/extended/packages/__init__.py +29 -3
- symai/extended/packages/symdev.py +51 -43
- symai/extended/packages/sympkg.py +41 -35
- symai/extended/packages/symrun.py +63 -50
- symai/extended/repo_cloner.py +14 -12
- symai/extended/seo_query_optimizer.py +15 -13
- symai/extended/solver.py +116 -91
- symai/extended/summarizer.py +12 -10
- symai/extended/taypan_interpreter.py +17 -18
- symai/extended/vectordb.py +122 -92
- symai/formatter/__init__.py +9 -1
- symai/formatter/formatter.py +51 -47
- symai/formatter/regex.py +70 -69
- symai/functional.py +325 -176
- symai/imports.py +190 -147
- symai/interfaces.py +57 -28
- symai/memory.py +45 -35
- symai/menu/screen.py +28 -19
- symai/misc/console.py +66 -56
- symai/misc/loader.py +8 -5
- symai/models/__init__.py +17 -1
- symai/models/base.py +395 -236
- symai/models/errors.py +1 -2
- symai/ops/__init__.py +32 -22
- symai/ops/measures.py +24 -25
- symai/ops/primitives.py +1149 -731
- symai/post_processors.py +58 -50
- symai/pre_processors.py +86 -82
- symai/processor.py +21 -13
- symai/prompts.py +764 -685
- symai/server/huggingface_server.py +135 -49
- symai/server/llama_cpp_server.py +21 -11
- symai/server/qdrant_server.py +206 -0
- symai/shell.py +100 -42
- symai/shellsv.py +700 -492
- symai/strategy.py +630 -346
- symai/symbol.py +368 -322
- symai/utils.py +100 -78
- {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/METADATA +22 -10
- symbolicai-1.1.0.dist-info/RECORD +168 -0
- symbolicai-0.21.0.dist-info/RECORD +0 -162
- {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/WHEEL +0 -0
- {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/entry_points.txt +0 -0
- {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/licenses/LICENSE +0 -0
- {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/top_level.txt +0 -0
symai/__init__.py
CHANGED
|
@@ -13,7 +13,7 @@ from rich.tree import Tree
|
|
|
13
13
|
from .backend import settings
|
|
14
14
|
from .menu.screen import show_intro_menu
|
|
15
15
|
from .misc.console import ConsoleStyle
|
|
16
|
-
from .utils import
|
|
16
|
+
from .utils import UserMessage
|
|
17
17
|
|
|
18
18
|
# do not remove - hides the libraries' debug messages
|
|
19
19
|
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
|
@@ -23,169 +23,225 @@ logging.getLogger("httpx").setLevel(logging.ERROR)
|
|
|
23
23
|
logging.getLogger("httpcore").setLevel(logging.ERROR)
|
|
24
24
|
logging.getLogger("huggingface_hub").setLevel(logging.ERROR)
|
|
25
25
|
logging.getLogger("huggingface").setLevel(logging.ERROR)
|
|
26
|
-
logging.getLogger(
|
|
26
|
+
logging.getLogger("pydub").setLevel(logging.ERROR)
|
|
27
27
|
|
|
28
28
|
warnings.simplefilter("ignore")
|
|
29
29
|
|
|
30
30
|
# set the environment variable for the transformers library
|
|
31
|
-
os.environ[
|
|
31
|
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
32
32
|
|
|
33
33
|
# Create singleton instance
|
|
34
34
|
config_manager = settings.SymAIConfig()
|
|
35
35
|
|
|
36
|
-
SYMAI_VERSION = "
|
|
37
|
-
__version__
|
|
38
|
-
__root_dir__
|
|
36
|
+
SYMAI_VERSION = "1.1.0"
|
|
37
|
+
__version__ = SYMAI_VERSION
|
|
38
|
+
__root_dir__ = config_manager.config_dir
|
|
39
39
|
|
|
40
|
-
def _start_symai():
|
|
41
|
-
global _symai_config_
|
|
42
|
-
global _symsh_config_
|
|
43
|
-
global _symserver_config_
|
|
44
40
|
|
|
41
|
+
def _start_symai():
|
|
45
42
|
# Create config directories if they don't exist
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
config_manager._env_config_dir.mkdir(parents=True, exist_ok=True)
|
|
44
|
+
config_manager._home_config_dir.mkdir(parents=True, exist_ok=True)
|
|
48
45
|
|
|
49
46
|
# CREATE THE SHELL CONFIGURATION FILE IF IT DOES NOT EXIST YET
|
|
50
47
|
# *==============================================================================================================*
|
|
51
|
-
_symsh_config_path_ = config_manager.get_config_path(
|
|
52
|
-
if not
|
|
53
|
-
config_manager.save_config(
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
_symsh_config_path_ = config_manager.get_config_path("symsh.config.json")
|
|
49
|
+
if not _symsh_config_path_.exists():
|
|
50
|
+
config_manager.save_config(
|
|
51
|
+
"symsh.config.json",
|
|
52
|
+
{
|
|
53
|
+
"colors": {
|
|
54
|
+
"completion-menu.completion.current": "bg:#323232 #212121",
|
|
55
|
+
"completion-menu.completion": "bg:#800080 #212121",
|
|
56
|
+
"scrollbar.background": "bg:#222222",
|
|
57
|
+
"scrollbar.button": "bg:#776677",
|
|
58
|
+
"history-completion": "bg:#212121 #f5f5f5",
|
|
59
|
+
"path-completion": "bg:#800080 #f5f5f5",
|
|
60
|
+
"file-completion": "bg:#9040b2 #f5f5f5",
|
|
61
|
+
"history-completion-selected": "bg:#efefef #b3d7ff",
|
|
62
|
+
"path-completion-selected": "bg:#efefef #b3d7ff",
|
|
63
|
+
"file-completion-selected": "bg:#efefef #b3d7ff",
|
|
64
|
+
},
|
|
65
|
+
"map-nt-cmd": True,
|
|
66
|
+
"show-splash-screen": True,
|
|
67
|
+
"plugin_prefix": None,
|
|
65
68
|
},
|
|
66
|
-
|
|
67
|
-
"show-splash-screen": True,
|
|
68
|
-
"plugin_prefix": None
|
|
69
|
-
})
|
|
69
|
+
)
|
|
70
70
|
|
|
71
71
|
# CREATE A SERVER CONFIGURATION FILE IF IT DOES NOT EXIST YET
|
|
72
72
|
# *==============================================================================================================*
|
|
73
|
-
_symserver_config_path_ = config_manager.get_config_path(
|
|
74
|
-
if not
|
|
75
|
-
config_manager.save_config(
|
|
73
|
+
_symserver_config_path_ = config_manager.get_config_path("symserver.config.json")
|
|
74
|
+
if not _symserver_config_path_.exists():
|
|
75
|
+
config_manager.save_config("symserver.config.json", {})
|
|
76
76
|
|
|
77
77
|
# Get appropriate config path (debug mode handling is now in config_manager)
|
|
78
|
-
_symai_config_path_ = config_manager.get_config_path(
|
|
78
|
+
_symai_config_path_ = config_manager.get_config_path("symai.config.json")
|
|
79
79
|
|
|
80
|
-
if not
|
|
80
|
+
if not _symai_config_path_.exists():
|
|
81
81
|
setup_wizard(_symai_config_path_)
|
|
82
|
-
|
|
82
|
+
UserMessage(
|
|
83
|
+
f"No configuration file found for the environment. A new configuration file has been created at {_symai_config_path_}. Please configure your environment."
|
|
84
|
+
)
|
|
83
85
|
sys.exit(1)
|
|
84
86
|
|
|
85
87
|
# Load and manage configurations
|
|
86
|
-
|
|
88
|
+
symai_config = config_manager.load_config("symai.config.json")
|
|
87
89
|
|
|
88
90
|
# MIGRATE THE ENVIRONMENT VARIABLES
|
|
89
91
|
# *==========================================================================================================*
|
|
90
|
-
if
|
|
92
|
+
if "COLLECTION_URI" not in symai_config:
|
|
91
93
|
updates = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
"COLLECTION_URI": "mongodb+srv://User:vt3epocXitd6WlQ6@extensityai.c1ajxxy.mongodb.net/?retryWrites=true&w=majority",
|
|
95
|
+
"COLLECTION_DB": "ExtensityAI",
|
|
96
|
+
"COLLECTION_STORAGE": "SymbolicAI",
|
|
97
|
+
"SUPPORT_COMMUNITY": False,
|
|
96
98
|
}
|
|
97
|
-
config_manager.migrate_config(
|
|
98
|
-
with ConsoleStyle(
|
|
99
|
-
msg =
|
|
99
|
+
config_manager.migrate_config("symai.config.json", updates)
|
|
100
|
+
with ConsoleStyle("info") as console:
|
|
101
|
+
msg = "Currently you are sharing your user experience with us by uploading the data to our research server, and thereby helping us improve future models and the overall SymbolicAI experience. We thank you very much for supporting the research community! If you wish to disable the data collection option go to your .symai config situated in your home directory or set the environment variable `SUPPORT_COMMUNITY` to `False`."
|
|
100
102
|
console.print(msg)
|
|
101
103
|
|
|
102
104
|
# POST-MIGRATION CHECKS
|
|
103
105
|
# *==============================================================================================================*
|
|
104
|
-
if
|
|
106
|
+
if "TEXT_TO_SPEECH_ENGINE_API_KEY" not in symai_config:
|
|
105
107
|
updates = {
|
|
106
|
-
|
|
108
|
+
"TEXT_TO_SPEECH_ENGINE_API_KEY": symai_config.get("NEUROSYMBOLIC_ENGINE_API_KEY", "")
|
|
107
109
|
}
|
|
108
|
-
config_manager.migrate_config(
|
|
110
|
+
config_manager.migrate_config("symai.config.json", updates)
|
|
109
111
|
|
|
110
112
|
# Load all configurations
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
symai_config = config_manager.load_config("symai.config.json")
|
|
114
|
+
symsh_config = config_manager.load_config("symsh.config.json")
|
|
115
|
+
symserver_config = config_manager.load_config("symserver.config.json")
|
|
114
116
|
|
|
115
117
|
# MIGRATE THE SHELL SPLASH SCREEN CONFIGURATION
|
|
116
118
|
# *==============================================================================================================*
|
|
117
|
-
if
|
|
118
|
-
config_manager.migrate_config(
|
|
119
|
+
if "show-splash-screen" not in symsh_config:
|
|
120
|
+
config_manager.migrate_config("symsh.config.json", {"show-splash-screen": True})
|
|
119
121
|
|
|
120
122
|
# CHECK IF THE USER HAS A NEUROSYMBOLIC API KEY
|
|
121
123
|
# *==============================================================================================================*
|
|
122
124
|
if not (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
125
|
+
symai_config["NEUROSYMBOLIC_ENGINE_MODEL"].lower().startswith("llama")
|
|
126
|
+
or symai_config["NEUROSYMBOLIC_ENGINE_MODEL"].lower().startswith("huggingface")
|
|
127
|
+
) and (
|
|
128
|
+
symai_config["NEUROSYMBOLIC_ENGINE_API_KEY"] is None
|
|
129
|
+
or len(symai_config["NEUROSYMBOLIC_ENGINE_API_KEY"]) == 0
|
|
130
|
+
):
|
|
131
|
+
# Try to fallback to the global (home) config if environment is not home
|
|
132
|
+
if config_manager.config_dir != config_manager._home_config_dir:
|
|
133
|
+
show_intro_menu()
|
|
134
|
+
UserMessage(
|
|
135
|
+
f"You didn't configure your environment ({config_manager.config_dir})! Falling back to the global ({config_manager._home_config_dir}) configuration if it exists."
|
|
136
|
+
)
|
|
137
|
+
# Force loading from home
|
|
138
|
+
symai_config = config_manager.load_config("symai.config.json", fallback_to_home=True)
|
|
139
|
+
symsh_config = config_manager.load_config("symsh.config.json", fallback_to_home=True)
|
|
140
|
+
symserver_config = config_manager.load_config(
|
|
141
|
+
"symserver.config.json", fallback_to_home=True
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# If still not valid, warn and exit
|
|
145
|
+
if not symai_config.get("NEUROSYMBOLIC_ENGINE_API_KEY"):
|
|
146
|
+
UserMessage(
|
|
147
|
+
"The mandatory neuro-symbolic engine is not initialized. Please set NEUROSYMBOLIC_ENGINE_MODEL and NEUROSYMBOLIC_ENGINE_API_KEY."
|
|
148
|
+
)
|
|
149
|
+
sys.exit(1)
|
|
150
|
+
|
|
151
|
+
settings.SYMAI_CONFIG = symai_config
|
|
152
|
+
settings.SYMSH_CONFIG = symsh_config
|
|
153
|
+
settings.SYMSERVER_CONFIG = symserver_config
|
|
154
|
+
return symai_config, symsh_config, symserver_config
|
|
146
155
|
|
|
147
156
|
|
|
148
157
|
def run_server():
|
|
149
158
|
_symserver_config_ = {}
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
|
|
160
|
+
# Check for explicit Qdrant server request via command line
|
|
161
|
+
qdrant_requested = any("qdrant" in arg.lower() for arg in sys.argv[1:])
|
|
162
|
+
|
|
163
|
+
if (
|
|
164
|
+
qdrant_requested
|
|
165
|
+
or settings.SYMAI_CONFIG.get("INDEXING_ENGINE") == "qdrant"
|
|
166
|
+
or any(
|
|
167
|
+
"qdrant" in str(v).lower()
|
|
168
|
+
for v in [
|
|
169
|
+
settings.SYMAI_CONFIG.get("INDEXING_ENGINE_API_KEY", ""),
|
|
170
|
+
settings.SYMAI_CONFIG.get("INDEXING_ENGINE_URL", ""),
|
|
171
|
+
]
|
|
172
|
+
)
|
|
173
|
+
):
|
|
174
|
+
from .server.qdrant_server import qdrant_server # noqa
|
|
175
|
+
|
|
176
|
+
command, args = qdrant_server()
|
|
177
|
+
_symserver_config_.update(zip(args[::2], args[1::2], strict=False))
|
|
178
|
+
_symserver_config_["online"] = True
|
|
179
|
+
_symserver_config_["url"] = (
|
|
180
|
+
f"http://{_symserver_config_.get('--host', 'localhost')}:{_symserver_config_.get('--port', 6333)}"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
config_manager.save_config("symserver.config.json", _symserver_config_)
|
|
184
|
+
config_manager.save_config(
|
|
185
|
+
"symserver.config.json", _symserver_config_, fallback_to_home=True
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
try:
|
|
189
|
+
subprocess.run(command, check=True)
|
|
190
|
+
except KeyboardInterrupt:
|
|
191
|
+
UserMessage("Server stopped!")
|
|
192
|
+
except Exception as e:
|
|
193
|
+
UserMessage(f"Error running server: {e}")
|
|
194
|
+
finally:
|
|
195
|
+
config_manager.save_config("symserver.config.json", {"online": False})
|
|
196
|
+
elif settings.SYMAI_CONFIG.get("NEUROSYMBOLIC_ENGINE_MODEL").startswith(
|
|
197
|
+
"llama"
|
|
198
|
+
) or settings.SYMAI_CONFIG.get("EMBEDDING_ENGINE_MODEL").startswith("llama"):
|
|
199
|
+
# Keep optional llama_cpp dependencies lazy.
|
|
200
|
+
from .server.llama_cpp_server import llama_cpp_server # noqa
|
|
152
201
|
|
|
153
202
|
command, args = llama_cpp_server()
|
|
154
|
-
_symserver_config_.update(zip(args[::2], args[1::2]))
|
|
155
|
-
_symserver_config_[
|
|
203
|
+
_symserver_config_.update(zip(args[::2], args[1::2], strict=False))
|
|
204
|
+
_symserver_config_["online"] = True
|
|
156
205
|
|
|
157
206
|
config_manager.save_config("symserver.config.json", _symserver_config_)
|
|
158
|
-
|
|
159
|
-
config_manager.save_config(
|
|
207
|
+
# @NOTE: Save in both places since you can start the server from anywhere and still not have a nesy engine configured
|
|
208
|
+
config_manager.save_config(
|
|
209
|
+
"symserver.config.json", _symserver_config_, fallback_to_home=True
|
|
210
|
+
)
|
|
160
211
|
|
|
161
212
|
try:
|
|
162
213
|
subprocess.run(command, check=True)
|
|
163
214
|
except KeyboardInterrupt:
|
|
164
|
-
|
|
215
|
+
UserMessage("Server stopped!")
|
|
165
216
|
except Exception as e:
|
|
166
|
-
|
|
217
|
+
UserMessage(f"Error running server: {e}")
|
|
167
218
|
finally:
|
|
168
|
-
config_manager.save_config("symserver.config.json", {
|
|
219
|
+
config_manager.save_config("symserver.config.json", {"online": False})
|
|
169
220
|
|
|
170
221
|
elif settings.SYMAI_CONFIG.get("NEUROSYMBOLIC_ENGINE_MODEL").startswith("huggingface"):
|
|
171
|
-
|
|
222
|
+
# HuggingFace server stack is optional; import only when requested.
|
|
223
|
+
from .server.huggingface_server import huggingface_server # noqa
|
|
172
224
|
|
|
173
225
|
command, args = huggingface_server()
|
|
174
226
|
_symserver_config_.update(vars(args))
|
|
175
|
-
_symserver_config_[
|
|
227
|
+
_symserver_config_["online"] = True
|
|
176
228
|
|
|
177
229
|
config_manager.save_config("symserver.config.json", _symserver_config_)
|
|
178
230
|
|
|
179
231
|
try:
|
|
180
232
|
command(host=args.host, port=args.port)
|
|
181
233
|
except KeyboardInterrupt:
|
|
182
|
-
|
|
234
|
+
UserMessage("Server stopped!")
|
|
183
235
|
except Exception as e:
|
|
184
|
-
|
|
236
|
+
UserMessage(f"Error running server: {e}")
|
|
185
237
|
finally:
|
|
186
|
-
config_manager.save_config("symserver.config.json", {
|
|
238
|
+
config_manager.save_config("symserver.config.json", {"online": False})
|
|
187
239
|
else:
|
|
188
|
-
|
|
240
|
+
msg = (
|
|
241
|
+
"You're trying to run a local server without a valid neuro-symbolic engine model. "
|
|
242
|
+
"Please set a valid model in your configuration file. Current available options are 'llamacpp', 'huggingface' and 'qdrant'."
|
|
243
|
+
)
|
|
244
|
+
UserMessage(msg, raise_with=ValueError)
|
|
189
245
|
|
|
190
246
|
|
|
191
247
|
# *==============================================================================================================*
|
|
@@ -193,32 +249,35 @@ def format_config_content(config: dict) -> str:
|
|
|
193
249
|
"""Format config content for display, truncating API keys."""
|
|
194
250
|
formatted = {}
|
|
195
251
|
for k, v in config.items():
|
|
196
|
-
if isinstance(v, str) and (
|
|
252
|
+
if isinstance(v, str) and ("KEY" in k or "URI" in k) and v:
|
|
197
253
|
# Show first/last 4 chars of keys/URIs
|
|
198
254
|
formatted[k] = f"{v[:4]}...{v[-4:]}" if len(v) > 8 else v
|
|
199
255
|
else:
|
|
200
256
|
formatted[k] = v
|
|
201
257
|
return json.dumps(formatted, indent=2)
|
|
202
258
|
|
|
259
|
+
|
|
203
260
|
def display_config():
|
|
204
261
|
"""Display all configuration paths and their content."""
|
|
205
262
|
|
|
206
263
|
console = Console()
|
|
207
264
|
|
|
208
265
|
# Create header
|
|
209
|
-
console.print(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
266
|
+
console.print(
|
|
267
|
+
Panel.fit(
|
|
268
|
+
f"[bold cyan]SymbolicAI Configuration Inspector v{__version__}[/bold cyan]",
|
|
269
|
+
border_style="cyan",
|
|
270
|
+
)
|
|
271
|
+
)
|
|
213
272
|
|
|
214
273
|
# Create main tree
|
|
215
274
|
tree = Tree("[bold]Configuration Locations[/bold]")
|
|
216
275
|
|
|
217
276
|
# Debug config
|
|
218
277
|
debug_branch = tree.add("[yellow]Debug Mode Config (CWD)[/yellow]")
|
|
219
|
-
debug_config = config_manager._debug_dir /
|
|
278
|
+
debug_config = config_manager._debug_dir / "symai.config.json"
|
|
220
279
|
if debug_config.exists():
|
|
221
|
-
with open(
|
|
280
|
+
with debug_config.open() as f:
|
|
222
281
|
content = json.load(f)
|
|
223
282
|
debug_branch.add(f"📄 [green]{debug_config}[/green]\n{format_config_content(content)}")
|
|
224
283
|
else:
|
|
@@ -227,15 +286,15 @@ def display_config():
|
|
|
227
286
|
# Environment config
|
|
228
287
|
env_branch = tree.add("[yellow]Environment Config[/yellow]")
|
|
229
288
|
env_configs = {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
289
|
+
"symai.config.json": "⚙️",
|
|
290
|
+
"symsh.config.json": "🖥️",
|
|
291
|
+
"symserver.config.json": "🌐",
|
|
233
292
|
}
|
|
234
293
|
|
|
235
294
|
for config_file, icon in env_configs.items():
|
|
236
295
|
config_path = config_manager._env_config_dir / config_file
|
|
237
296
|
if config_path.exists():
|
|
238
|
-
with open(
|
|
297
|
+
with config_path.open() as f:
|
|
239
298
|
content = json.load(f)
|
|
240
299
|
env_branch.add(f"{icon} [green]{config_path}[/green]\n{format_config_content(content)}")
|
|
241
300
|
else:
|
|
@@ -246,9 +305,11 @@ def display_config():
|
|
|
246
305
|
for config_file, icon in env_configs.items():
|
|
247
306
|
config_path = config_manager._home_config_dir / config_file
|
|
248
307
|
if config_path.exists():
|
|
249
|
-
with open(
|
|
308
|
+
with config_path.open() as f:
|
|
250
309
|
content = json.load(f)
|
|
251
|
-
home_branch.add(
|
|
310
|
+
home_branch.add(
|
|
311
|
+
f"{icon} [green]{config_path}[/green]\n{format_config_content(content)}"
|
|
312
|
+
)
|
|
252
313
|
else:
|
|
253
314
|
home_branch.add(f"[dim]{icon} {config_file} (not found)[/dim]")
|
|
254
315
|
|
|
@@ -258,10 +319,10 @@ def display_config():
|
|
|
258
319
|
summary.add_column("Active Path")
|
|
259
320
|
|
|
260
321
|
active_paths = {
|
|
261
|
-
"Primary Config Dir": config_manager.
|
|
262
|
-
"symai.config.json": config_manager.
|
|
263
|
-
"symsh.config.json": config_manager.
|
|
264
|
-
"symserver.config.json": config_manager.
|
|
322
|
+
"Primary Config Dir": config_manager.get_active_config_dir(),
|
|
323
|
+
"symai.config.json": config_manager.get_active_path("symai.config.json"),
|
|
324
|
+
"symsh.config.json": config_manager.get_active_path("symsh.config.json"),
|
|
325
|
+
"symserver.config.json": config_manager.get_active_path("symserver.config.json"),
|
|
265
326
|
}
|
|
266
327
|
|
|
267
328
|
for config_type, path in active_paths.items():
|
|
@@ -278,74 +339,109 @@ def display_config():
|
|
|
278
339
|
console.print("🖥️ symsh.config.json (Shell configuration)")
|
|
279
340
|
console.print("🌐 symserver.config.json (Server configuration)")
|
|
280
341
|
console.print("\n[dim]Note: API keys and URIs are truncated for security[/dim]")
|
|
342
|
+
|
|
343
|
+
|
|
281
344
|
# *==============================================================================================================*
|
|
282
345
|
|
|
283
346
|
|
|
284
347
|
def setup_wizard(_symai_config_path_):
|
|
285
348
|
show_intro_menu()
|
|
286
349
|
|
|
287
|
-
_nesy_engine_api_key
|
|
288
|
-
_nesy_engine_model
|
|
289
|
-
_symbolic_engine_api_key
|
|
290
|
-
_symbolic_engine_model
|
|
291
|
-
_embedding_engine_api_key
|
|
292
|
-
_embedding_model
|
|
293
|
-
_drawing_engine_api_key
|
|
294
|
-
_drawing_engine_model
|
|
295
|
-
_vision_engine_model
|
|
296
|
-
_search_engine_api_key
|
|
297
|
-
_search_engine_model
|
|
298
|
-
_ocr_engine_api_key
|
|
299
|
-
_speech_to_text_engine_model
|
|
300
|
-
_speech_to_text_api_key
|
|
301
|
-
_text_to_speech_engine_api_key
|
|
302
|
-
_text_to_speech_engine_model
|
|
303
|
-
_text_to_speech_engine_voice
|
|
304
|
-
_indexing_engine_api_key
|
|
305
|
-
_indexing_engine_environment
|
|
306
|
-
_caption_engine_environment
|
|
307
|
-
_support_comminity
|
|
308
|
-
|
|
309
|
-
config_manager.save_config(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
from .
|
|
343
|
-
from .
|
|
344
|
-
from .
|
|
345
|
-
from .
|
|
346
|
-
from .
|
|
347
|
-
from .
|
|
348
|
-
from .
|
|
349
|
-
from .
|
|
350
|
-
from .
|
|
351
|
-
from .
|
|
350
|
+
_nesy_engine_api_key = ""
|
|
351
|
+
_nesy_engine_model = ""
|
|
352
|
+
_symbolic_engine_api_key = ""
|
|
353
|
+
_symbolic_engine_model = ""
|
|
354
|
+
_embedding_engine_api_key = ""
|
|
355
|
+
_embedding_model = ""
|
|
356
|
+
_drawing_engine_api_key = ""
|
|
357
|
+
_drawing_engine_model = ""
|
|
358
|
+
_vision_engine_model = ""
|
|
359
|
+
_search_engine_api_key = ""
|
|
360
|
+
_search_engine_model = ""
|
|
361
|
+
_ocr_engine_api_key = ""
|
|
362
|
+
_speech_to_text_engine_model = ""
|
|
363
|
+
_speech_to_text_api_key = ""
|
|
364
|
+
_text_to_speech_engine_api_key = ""
|
|
365
|
+
_text_to_speech_engine_model = ""
|
|
366
|
+
_text_to_speech_engine_voice = ""
|
|
367
|
+
_indexing_engine_api_key = ""
|
|
368
|
+
_indexing_engine_environment = ""
|
|
369
|
+
_caption_engine_environment = ""
|
|
370
|
+
_support_comminity = False
|
|
371
|
+
|
|
372
|
+
config_manager.save_config(
|
|
373
|
+
_symai_config_path_,
|
|
374
|
+
{
|
|
375
|
+
"NEUROSYMBOLIC_ENGINE_API_KEY": _nesy_engine_api_key,
|
|
376
|
+
"NEUROSYMBOLIC_ENGINE_MODEL": _nesy_engine_model,
|
|
377
|
+
"SYMBOLIC_ENGINE_API_KEY": _symbolic_engine_api_key,
|
|
378
|
+
"SYMBOLIC_ENGINE": _symbolic_engine_model,
|
|
379
|
+
"EMBEDDING_ENGINE_API_KEY": _embedding_engine_api_key,
|
|
380
|
+
"EMBEDDING_ENGINE_MODEL": _embedding_model,
|
|
381
|
+
"DRAWING_ENGINE_API_KEY": _drawing_engine_api_key,
|
|
382
|
+
"DRAWING_ENGINE_MODEL": _drawing_engine_model,
|
|
383
|
+
"VISION_ENGINE_MODEL": _vision_engine_model,
|
|
384
|
+
"SEARCH_ENGINE_API_KEY": _search_engine_api_key,
|
|
385
|
+
"SEARCH_ENGINE_MODEL": _search_engine_model,
|
|
386
|
+
"OCR_ENGINE_API_KEY": _ocr_engine_api_key,
|
|
387
|
+
"SPEECH_TO_TEXT_ENGINE_MODEL": _speech_to_text_engine_model,
|
|
388
|
+
"SPEECH_TO_TEXT_API_KEY": _speech_to_text_api_key,
|
|
389
|
+
"TEXT_TO_SPEECH_ENGINE_API_KEY": _text_to_speech_engine_api_key,
|
|
390
|
+
"TEXT_TO_SPEECH_ENGINE_MODEL": _text_to_speech_engine_model,
|
|
391
|
+
"TEXT_TO_SPEECH_ENGINE_VOICE": _text_to_speech_engine_voice,
|
|
392
|
+
"INDEXING_ENGINE_API_KEY": _indexing_engine_api_key,
|
|
393
|
+
"INDEXING_ENGINE_ENVIRONMENT": _indexing_engine_environment,
|
|
394
|
+
"CAPTION_ENGINE_MODEL": _caption_engine_environment,
|
|
395
|
+
"COLLECTION_URI": "mongodb+srv://User:vt3epocXitd6WlQ6@extensityai.c1ajxxy.mongodb.net/?retryWrites=true&w=majority",
|
|
396
|
+
"COLLECTION_DB": "ExtensityAI",
|
|
397
|
+
"COLLECTION_STORAGE": "SymbolicAI",
|
|
398
|
+
"SUPPORT_COMMUNITY": _support_comminity,
|
|
399
|
+
},
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
_symai_config_, _symsh_config_, _symserver_config_ = _start_symai()
|
|
404
|
+
|
|
405
|
+
from .backend.base import Engine # noqa
|
|
406
|
+
from .components import Function, PrimitiveDisabler # noqa
|
|
407
|
+
from .core import few_shot, zero_shot # noqa
|
|
408
|
+
from .extended import Conversation # noqa
|
|
409
|
+
from .functional import EngineRepository # noqa
|
|
410
|
+
from .imports import Import # noqa
|
|
411
|
+
from .interfaces import Interface # noqa
|
|
412
|
+
from .post_processors import PostProcessor # noqa
|
|
413
|
+
from .pre_processors import PreProcessor # noqa
|
|
414
|
+
from .prompts import Prompt, PromptLanguage, PromptRegistry # noqa
|
|
415
|
+
from .shell import Shell # noqa
|
|
416
|
+
from .strategy import Strategy # noqa
|
|
417
|
+
from .symbol import Call, Expression, GlobalSymbolPrimitive, Metadata, Symbol # noqa
|
|
418
|
+
|
|
419
|
+
__all__ = [
|
|
420
|
+
"SYMAI_VERSION",
|
|
421
|
+
"Call",
|
|
422
|
+
"Conversation",
|
|
423
|
+
"Engine",
|
|
424
|
+
"EngineRepository",
|
|
425
|
+
"Expression",
|
|
426
|
+
"Function",
|
|
427
|
+
"GlobalSymbolPrimitive",
|
|
428
|
+
"Import",
|
|
429
|
+
"Interface",
|
|
430
|
+
"Metadata",
|
|
431
|
+
"PostProcessor",
|
|
432
|
+
"PreProcessor",
|
|
433
|
+
"PrimitiveDisabler",
|
|
434
|
+
"Prompt",
|
|
435
|
+
"PromptLanguage",
|
|
436
|
+
"PromptRegistry",
|
|
437
|
+
"Shell",
|
|
438
|
+
"Strategy",
|
|
439
|
+
"Symbol",
|
|
440
|
+
"__root_dir__",
|
|
441
|
+
"__version__",
|
|
442
|
+
"config_manager",
|
|
443
|
+
"few_shot",
|
|
444
|
+
"run_server",
|
|
445
|
+
"setup_wizard",
|
|
446
|
+
"zero_shot",
|
|
447
|
+
]
|