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.
Files changed (134) hide show
  1. symai/__init__.py +269 -173
  2. symai/backend/base.py +123 -110
  3. symai/backend/engines/drawing/engine_bfl.py +45 -44
  4. symai/backend/engines/drawing/engine_gpt_image.py +112 -97
  5. symai/backend/engines/embedding/engine_llama_cpp.py +63 -52
  6. symai/backend/engines/embedding/engine_openai.py +25 -21
  7. symai/backend/engines/execute/engine_python.py +19 -18
  8. symai/backend/engines/files/engine_io.py +104 -95
  9. symai/backend/engines/imagecaptioning/engine_blip2.py +28 -24
  10. symai/backend/engines/imagecaptioning/engine_llavacpp_client.py +102 -79
  11. symai/backend/engines/index/engine_pinecone.py +124 -97
  12. symai/backend/engines/index/engine_qdrant.py +1011 -0
  13. symai/backend/engines/index/engine_vectordb.py +84 -56
  14. symai/backend/engines/lean/engine_lean4.py +96 -52
  15. symai/backend/engines/neurosymbolic/__init__.py +41 -13
  16. symai/backend/engines/neurosymbolic/engine_anthropic_claudeX_chat.py +330 -248
  17. symai/backend/engines/neurosymbolic/engine_anthropic_claudeX_reasoning.py +329 -264
  18. symai/backend/engines/neurosymbolic/engine_cerebras.py +328 -0
  19. symai/backend/engines/neurosymbolic/engine_deepseekX_reasoning.py +118 -88
  20. symai/backend/engines/neurosymbolic/engine_google_geminiX_reasoning.py +344 -299
  21. symai/backend/engines/neurosymbolic/engine_groq.py +173 -115
  22. symai/backend/engines/neurosymbolic/engine_huggingface.py +114 -84
  23. symai/backend/engines/neurosymbolic/engine_llama_cpp.py +144 -118
  24. symai/backend/engines/neurosymbolic/engine_openai_gptX_chat.py +415 -307
  25. symai/backend/engines/neurosymbolic/engine_openai_gptX_reasoning.py +394 -231
  26. symai/backend/engines/ocr/engine_apilayer.py +23 -27
  27. symai/backend/engines/output/engine_stdout.py +10 -13
  28. symai/backend/engines/{webscraping → scrape}/engine_requests.py +101 -54
  29. symai/backend/engines/search/engine_openai.py +100 -88
  30. symai/backend/engines/search/engine_parallel.py +665 -0
  31. symai/backend/engines/search/engine_perplexity.py +44 -45
  32. symai/backend/engines/search/engine_serpapi.py +37 -34
  33. symai/backend/engines/speech_to_text/engine_local_whisper.py +54 -51
  34. symai/backend/engines/symbolic/engine_wolframalpha.py +15 -9
  35. symai/backend/engines/text_to_speech/engine_openai.py +20 -26
  36. symai/backend/engines/text_vision/engine_clip.py +39 -37
  37. symai/backend/engines/userinput/engine_console.py +5 -6
  38. symai/backend/mixin/__init__.py +13 -0
  39. symai/backend/mixin/anthropic.py +48 -38
  40. symai/backend/mixin/deepseek.py +6 -5
  41. symai/backend/mixin/google.py +7 -4
  42. symai/backend/mixin/groq.py +2 -4
  43. symai/backend/mixin/openai.py +140 -110
  44. symai/backend/settings.py +87 -20
  45. symai/chat.py +216 -123
  46. symai/collect/__init__.py +7 -1
  47. symai/collect/dynamic.py +80 -70
  48. symai/collect/pipeline.py +67 -51
  49. symai/collect/stats.py +161 -109
  50. symai/components.py +707 -360
  51. symai/constraints.py +24 -12
  52. symai/core.py +1857 -1233
  53. symai/core_ext.py +83 -80
  54. symai/endpoints/api.py +166 -104
  55. symai/extended/.DS_Store +0 -0
  56. symai/extended/__init__.py +46 -12
  57. symai/extended/api_builder.py +29 -21
  58. symai/extended/arxiv_pdf_parser.py +23 -14
  59. symai/extended/bibtex_parser.py +9 -6
  60. symai/extended/conversation.py +156 -126
  61. symai/extended/document.py +50 -30
  62. symai/extended/file_merger.py +57 -14
  63. symai/extended/graph.py +51 -32
  64. symai/extended/html_style_template.py +18 -14
  65. symai/extended/interfaces/blip_2.py +2 -3
  66. symai/extended/interfaces/clip.py +4 -3
  67. symai/extended/interfaces/console.py +9 -1
  68. symai/extended/interfaces/dall_e.py +4 -2
  69. symai/extended/interfaces/file.py +2 -0
  70. symai/extended/interfaces/flux.py +4 -2
  71. symai/extended/interfaces/gpt_image.py +16 -7
  72. symai/extended/interfaces/input.py +2 -1
  73. symai/extended/interfaces/llava.py +1 -2
  74. symai/extended/interfaces/{naive_webscraping.py → naive_scrape.py} +4 -3
  75. symai/extended/interfaces/naive_vectordb.py +9 -10
  76. symai/extended/interfaces/ocr.py +5 -3
  77. symai/extended/interfaces/openai_search.py +2 -0
  78. symai/extended/interfaces/parallel.py +30 -0
  79. symai/extended/interfaces/perplexity.py +2 -0
  80. symai/extended/interfaces/pinecone.py +12 -9
  81. symai/extended/interfaces/python.py +2 -0
  82. symai/extended/interfaces/serpapi.py +3 -1
  83. symai/extended/interfaces/terminal.py +2 -4
  84. symai/extended/interfaces/tts.py +3 -2
  85. symai/extended/interfaces/whisper.py +3 -2
  86. symai/extended/interfaces/wolframalpha.py +2 -1
  87. symai/extended/metrics/__init__.py +11 -1
  88. symai/extended/metrics/similarity.py +14 -13
  89. symai/extended/os_command.py +39 -29
  90. symai/extended/packages/__init__.py +29 -3
  91. symai/extended/packages/symdev.py +51 -43
  92. symai/extended/packages/sympkg.py +41 -35
  93. symai/extended/packages/symrun.py +63 -50
  94. symai/extended/repo_cloner.py +14 -12
  95. symai/extended/seo_query_optimizer.py +15 -13
  96. symai/extended/solver.py +116 -91
  97. symai/extended/summarizer.py +12 -10
  98. symai/extended/taypan_interpreter.py +17 -18
  99. symai/extended/vectordb.py +122 -92
  100. symai/formatter/__init__.py +9 -1
  101. symai/formatter/formatter.py +51 -47
  102. symai/formatter/regex.py +70 -69
  103. symai/functional.py +325 -176
  104. symai/imports.py +190 -147
  105. symai/interfaces.py +57 -28
  106. symai/memory.py +45 -35
  107. symai/menu/screen.py +28 -19
  108. symai/misc/console.py +66 -56
  109. symai/misc/loader.py +8 -5
  110. symai/models/__init__.py +17 -1
  111. symai/models/base.py +395 -236
  112. symai/models/errors.py +1 -2
  113. symai/ops/__init__.py +32 -22
  114. symai/ops/measures.py +24 -25
  115. symai/ops/primitives.py +1149 -731
  116. symai/post_processors.py +58 -50
  117. symai/pre_processors.py +86 -82
  118. symai/processor.py +21 -13
  119. symai/prompts.py +764 -685
  120. symai/server/huggingface_server.py +135 -49
  121. symai/server/llama_cpp_server.py +21 -11
  122. symai/server/qdrant_server.py +206 -0
  123. symai/shell.py +100 -42
  124. symai/shellsv.py +700 -492
  125. symai/strategy.py +630 -346
  126. symai/symbol.py +368 -322
  127. symai/utils.py +100 -78
  128. {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/METADATA +22 -10
  129. symbolicai-1.1.0.dist-info/RECORD +168 -0
  130. symbolicai-0.21.0.dist-info/RECORD +0 -162
  131. {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/WHEEL +0 -0
  132. {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/entry_points.txt +0 -0
  133. {symbolicai-0.21.0.dist-info → symbolicai-1.1.0.dist-info}/licenses/LICENSE +0 -0
  134. {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 CustomUserWarning
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('pydub').setLevel(logging.ERROR)
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['TOKENIZERS_PARALLELISM'] = "false"
31
+ os.environ["TOKENIZERS_PARALLELISM"] = "false"
32
32
 
33
33
  # Create singleton instance
34
34
  config_manager = settings.SymAIConfig()
35
35
 
36
- SYMAI_VERSION = "0.21.0"
37
- __version__ = SYMAI_VERSION
38
- __root_dir__ = config_manager.config_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
- os.makedirs(config_manager._env_config_dir, exist_ok=True)
47
- os.makedirs(config_manager._home_config_dir, exist_ok=True)
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('symsh.config.json')
52
- if not os.path.exists(_symsh_config_path_):
53
- config_manager.save_config('symsh.config.json', {
54
- "colors": {
55
- "completion-menu.completion.current": "bg:#323232 #212121",
56
- "completion-menu.completion": "bg:#800080 #212121",
57
- "scrollbar.background": "bg:#222222",
58
- "scrollbar.button": "bg:#776677",
59
- "history-completion": "bg:#212121 #f5f5f5",
60
- "path-completion": "bg:#800080 #f5f5f5",
61
- "file-completion": "bg:#9040b2 #f5f5f5",
62
- "history-completion-selected": "bg:#efefef #b3d7ff",
63
- "path-completion-selected": "bg:#efefef #b3d7ff",
64
- "file-completion-selected": "bg:#efefef #b3d7ff"
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
- "map-nt-cmd": True,
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('symserver.config.json')
74
- if not os.path.exists(_symserver_config_path_):
75
- config_manager.save_config('symserver.config.json', {})
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('symai.config.json')
78
+ _symai_config_path_ = config_manager.get_config_path("symai.config.json")
79
79
 
80
- if not os.path.exists(_symai_config_path_):
80
+ if not _symai_config_path_.exists():
81
81
  setup_wizard(_symai_config_path_)
82
- CustomUserWarning(f'No configuration file found for the environment. A new configuration file has been created at {_symai_config_path_}. Please configure your environment.')
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
- _symai_config_ = config_manager.load_config('symai.config.json')
88
+ symai_config = config_manager.load_config("symai.config.json")
87
89
 
88
90
  # MIGRATE THE ENVIRONMENT VARIABLES
89
91
  # *==========================================================================================================*
90
- if 'COLLECTION_URI' not in _symai_config_:
92
+ if "COLLECTION_URI" not in symai_config:
91
93
  updates = {
92
- 'COLLECTION_URI': "mongodb+srv://User:vt3epocXitd6WlQ6@extensityai.c1ajxxy.mongodb.net/?retryWrites=true&w=majority",
93
- 'COLLECTION_DB': "ExtensityAI",
94
- 'COLLECTION_STORAGE': "SymbolicAI",
95
- 'SUPPORT_COMMUNITY': False
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('symai.config.json', updates)
98
- with ConsoleStyle('info') as console:
99
- 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`.'
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 'TEXT_TO_SPEECH_ENGINE_API_KEY' not in _symai_config_:
106
+ if "TEXT_TO_SPEECH_ENGINE_API_KEY" not in symai_config:
105
107
  updates = {
106
- 'TEXT_TO_SPEECH_ENGINE_API_KEY': _symai_config_.get('NEUROSYMBOLIC_ENGINE_API_KEY', '')
108
+ "TEXT_TO_SPEECH_ENGINE_API_KEY": symai_config.get("NEUROSYMBOLIC_ENGINE_API_KEY", "")
107
109
  }
108
- config_manager.migrate_config('symai.config.json', updates)
110
+ config_manager.migrate_config("symai.config.json", updates)
109
111
 
110
112
  # Load all configurations
111
- _symai_config_ = config_manager.load_config('symai.config.json')
112
- _symsh_config_ = config_manager.load_config('symsh.config.json')
113
- _symserver_config_ = config_manager.load_config('symserver.config.json')
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 'show-splash-screen' not in _symsh_config_:
118
- config_manager.migrate_config('symsh.config.json', {'show-splash-screen': True})
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
- _symai_config_['NEUROSYMBOLIC_ENGINE_MODEL'].lower().startswith('llama') or \
124
- _symai_config_['NEUROSYMBOLIC_ENGINE_MODEL'].lower().startswith('huggingface')) \
125
- and \
126
- (
127
- _symai_config_['NEUROSYMBOLIC_ENGINE_API_KEY'] is None or \
128
- len(_symai_config_['NEUROSYMBOLIC_ENGINE_API_KEY']) == 0):
129
- # Try to fallback to the global (home) config if environment is not home
130
- if config_manager.config_dir != config_manager._home_config_dir:
131
- show_intro_menu()
132
- CustomUserWarning(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.")
133
- # Force loading from home
134
- _symai_config_ = config_manager.load_config('symai.config.json', fallback_to_home=True)
135
- _symsh_config_ = config_manager.load_config('symsh.config.json', fallback_to_home=True)
136
- _symserver_config_ = config_manager.load_config('symserver.config.json', fallback_to_home=True)
137
-
138
- # If still not valid, warn and exit
139
- if not _symai_config_.get('NEUROSYMBOLIC_ENGINE_API_KEY'):
140
- CustomUserWarning('The mandatory neuro-symbolic engine is not initialized. Please set NEUROSYMBOLIC_ENGINE_MODEL and NEUROSYMBOLIC_ENGINE_API_KEY.')
141
- sys.exit(1)
142
-
143
- settings.SYMAI_CONFIG = _symai_config_
144
- settings.SYMSH_CONFIG = _symsh_config_
145
- settings.SYMSERVER_CONFIG = _symserver_config_
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
- if settings.SYMAI_CONFIG.get("NEUROSYMBOLIC_ENGINE_MODEL").startswith("llama") or settings.SYMAI_CONFIG.get("EMBEDDING_ENGINE_MODEL").startswith("llama"):
151
- from .server.llama_cpp_server import llama_cpp_server
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_['online'] = True
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
- #@NOTE: Save in both places since you can start the server from anywhere and still not have a nesy engine configured
159
- config_manager.save_config("symserver.config.json", _symserver_config_, fallback_to_home=True)
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
- print("Server stopped!")
215
+ UserMessage("Server stopped!")
165
216
  except Exception as e:
166
- print(f"Error running server: {e}")
217
+ UserMessage(f"Error running server: {e}")
167
218
  finally:
168
- config_manager.save_config("symserver.config.json", {'online': False})
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
- from .server.huggingface_server import huggingface_server
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_['online'] = True
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
- print("Server stopped!")
234
+ UserMessage("Server stopped!")
183
235
  except Exception as e:
184
- print(f"Error running server: {e}")
236
+ UserMessage(f"Error running server: {e}")
185
237
  finally:
186
- config_manager.save_config("symserver.config.json", {'online': False})
238
+ config_manager.save_config("symserver.config.json", {"online": False})
187
239
  else:
188
- raise CustomUserWarning("You're trying to run a local server without a valid neuro-symbolic engine model. Please set a valid model in your configuration file. Current available options are 'llamacpp' and 'huggingface'.")
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 ('KEY' in k or 'URI' in k) and v:
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(Panel.fit(
210
- f"[bold cyan]SymbolicAI Configuration Inspector v{__version__}[/bold cyan]",
211
- border_style="cyan"
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 / 'symai.config.json'
278
+ debug_config = config_manager._debug_dir / "symai.config.json"
220
279
  if debug_config.exists():
221
- with open(debug_config) as f:
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
- 'symai.config.json': '⚙️',
231
- 'symsh.config.json': '🖥️',
232
- 'symserver.config.json': '🌐'
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(config_path) as f:
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(config_path) as f:
308
+ with config_path.open() as f:
250
309
  content = json.load(f)
251
- home_branch.add(f"{icon} [green]{config_path}[/green]\n{format_config_content(content)}")
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.config_dir,
262
- "symai.config.json": config_manager.get_config_path('symai.config.json'),
263
- "symsh.config.json": config_manager.get_config_path('symsh.config.json'),
264
- "symserver.config.json": config_manager.get_config_path('symserver.config.json')
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 = False
308
-
309
- config_manager.save_config(_symai_config_path_, {
310
- "NEUROSYMBOLIC_ENGINE_API_KEY": _nesy_engine_api_key,
311
- "NEUROSYMBOLIC_ENGINE_MODEL": _nesy_engine_model,
312
- "SYMBOLIC_ENGINE_API_KEY": _symbolic_engine_api_key,
313
- "SYMBOLIC_ENGINE": _symbolic_engine_model,
314
- "EMBEDDING_ENGINE_API_KEY": _embedding_engine_api_key,
315
- "EMBEDDING_ENGINE_MODEL": _embedding_model,
316
- "DRAWING_ENGINE_API_KEY": _drawing_engine_api_key,
317
- "DRAWING_ENGINE_MODEL": _drawing_engine_model,
318
- "VISION_ENGINE_MODEL": _vision_engine_model,
319
- "SEARCH_ENGINE_API_KEY": _search_engine_api_key,
320
- "SEARCH_ENGINE_MODEL": _search_engine_model,
321
- "OCR_ENGINE_API_KEY": _ocr_engine_api_key,
322
- "SPEECH_TO_TEXT_ENGINE_MODEL": _speech_to_text_engine_model,
323
- "SPEECH_TO_TEXT_API_KEY": _speech_to_text_api_key,
324
- "TEXT_TO_SPEECH_ENGINE_API_KEY": _text_to_speech_engine_api_key,
325
- "TEXT_TO_SPEECH_ENGINE_MODEL": _text_to_speech_engine_model,
326
- "TEXT_TO_SPEECH_ENGINE_VOICE": _text_to_speech_engine_voice,
327
- "INDEXING_ENGINE_API_KEY": _indexing_engine_api_key,
328
- "INDEXING_ENGINE_ENVIRONMENT": _indexing_engine_environment,
329
- "CAPTION_ENGINE_MODEL": _caption_engine_environment,
330
- "COLLECTION_URI": "mongodb+srv://User:vt3epocXitd6WlQ6@extensityai.c1ajxxy.mongodb.net/?retryWrites=true&w=majority",
331
- "COLLECTION_DB": "ExtensityAI",
332
- "COLLECTION_STORAGE": "SymbolicAI",
333
- "SUPPORT_COMMUNITY": _support_comminity
334
- })
335
-
336
-
337
- _start_symai()
338
-
339
- from .backend.base import Engine
340
- from .components import Function, PrimitiveDisabler
341
- from .core import few_shot, zero_shot
342
- from .extended import Conversation
343
- from .functional import EngineRepository
344
- from .imports import Import
345
- from .interfaces import Interface
346
- from .post_processors import PostProcessor
347
- from .pre_processors import PreProcessor
348
- from .prompts import Prompt, PromptLanguage, PromptRegistry
349
- from .shell import Shell
350
- from .strategy import Strategy
351
- from .symbol import Call, Expression, GlobalSymbolPrimitive, Metadata, Symbol
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
+ ]