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/models/errors.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
from pydantic import BaseModel
|
|
2
|
-
|
|
3
1
|
class ExceptionWithUsage(Exception):
|
|
4
2
|
def __init__(self, message, usage):
|
|
5
3
|
super().__init__(message)
|
|
6
4
|
self.usage = usage
|
|
7
5
|
|
|
6
|
+
|
|
8
7
|
class TypeValidationError(Exception):
|
|
9
8
|
def __init__(self, prompt: str, result: str, violations: list[str], *args):
|
|
10
9
|
super().__init__(*args)
|
symai/ops/__init__.py
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from . import primitives as _primitives
|
|
2
|
+
|
|
3
|
+
__all__ = getattr(_primitives, "__all__", None) # noqa
|
|
4
|
+
if __all__ is None:
|
|
5
|
+
__all__ = [name for name in dir(_primitives) if not name.startswith("_")]
|
|
6
|
+
|
|
7
|
+
for _name in __all__:
|
|
8
|
+
globals()[_name] = getattr(_primitives, _name)
|
|
2
9
|
|
|
3
10
|
SYMBOL_PRIMITIVES = [
|
|
4
|
-
OperatorPrimitives,
|
|
5
|
-
IterationPrimitives,
|
|
6
|
-
ValueHandlingPrimitives,
|
|
7
|
-
StringHelperPrimitives,
|
|
8
|
-
CastingPrimitives,
|
|
9
|
-
ComparisonPrimitives,
|
|
10
|
-
ExpressionHandlingPrimitives,
|
|
11
|
-
DataHandlingPrimitives,
|
|
12
|
-
UniquenessPrimitives,
|
|
13
|
-
PatternMatchingPrimitives,
|
|
14
|
-
DictHandlingPrimitives,
|
|
15
|
-
QueryHandlingPrimitives,
|
|
16
|
-
ExecutionControlPrimitives,
|
|
17
|
-
TemplateStylingPrimitives,
|
|
18
|
-
DataClusteringPrimitives,
|
|
19
|
-
EmbeddingPrimitives,
|
|
20
|
-
IndexingPrimitives,
|
|
21
|
-
IOHandlingPrimitives,
|
|
22
|
-
PersistencePrimitives,
|
|
23
|
-
OutputHandlingPrimitives,
|
|
24
|
-
FineTuningPrimitives,
|
|
11
|
+
_primitives.OperatorPrimitives,
|
|
12
|
+
_primitives.IterationPrimitives,
|
|
13
|
+
_primitives.ValueHandlingPrimitives,
|
|
14
|
+
_primitives.StringHelperPrimitives,
|
|
15
|
+
_primitives.CastingPrimitives,
|
|
16
|
+
_primitives.ComparisonPrimitives,
|
|
17
|
+
_primitives.ExpressionHandlingPrimitives,
|
|
18
|
+
_primitives.DataHandlingPrimitives,
|
|
19
|
+
_primitives.UniquenessPrimitives,
|
|
20
|
+
_primitives.PatternMatchingPrimitives,
|
|
21
|
+
_primitives.DictHandlingPrimitives,
|
|
22
|
+
_primitives.QueryHandlingPrimitives,
|
|
23
|
+
_primitives.ExecutionControlPrimitives,
|
|
24
|
+
_primitives.TemplateStylingPrimitives,
|
|
25
|
+
_primitives.DataClusteringPrimitives,
|
|
26
|
+
_primitives.EmbeddingPrimitives,
|
|
27
|
+
_primitives.IndexingPrimitives,
|
|
28
|
+
_primitives.IOHandlingPrimitives,
|
|
29
|
+
_primitives.PersistencePrimitives,
|
|
30
|
+
_primitives.OutputHandlingPrimitives,
|
|
31
|
+
_primitives.FineTuningPrimitives,
|
|
25
32
|
]
|
|
33
|
+
|
|
34
|
+
del _name
|
|
35
|
+
del _primitives
|
symai/ops/measures.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
|
|
3
2
|
from scipy import linalg
|
|
4
3
|
|
|
4
|
+
from ..utils import UserMessage
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
|
|
7
8
|
"""Numpy implementation of the Frechet Distance.
|
|
@@ -31,19 +32,18 @@ def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
|
|
|
31
32
|
sigma1 = np.atleast_2d(sigma1)
|
|
32
33
|
sigma2 = np.atleast_2d(sigma2)
|
|
33
34
|
|
|
34
|
-
assert mu1.shape == mu2.shape,
|
|
35
|
-
|
|
36
|
-
assert sigma1.shape == sigma2.shape, \
|
|
37
|
-
'Training and test covariances have different dimensions'
|
|
35
|
+
assert mu1.shape == mu2.shape, "Training and test mean vectors have different lengths"
|
|
36
|
+
assert sigma1.shape == sigma2.shape, "Training and test covariances have different dimensions"
|
|
38
37
|
|
|
39
38
|
diff = mu1 - mu2
|
|
40
39
|
|
|
41
40
|
# Product might be almost singular
|
|
42
41
|
covmean, _ = linalg.sqrtm(sigma1.dot(sigma2), disp=False)
|
|
43
42
|
if not np.isfinite(covmean).all():
|
|
44
|
-
msg = (
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
msg = (
|
|
44
|
+
f"fid calculation produces singular product; adding {eps} to diagonal of cov estimates"
|
|
45
|
+
)
|
|
46
|
+
UserMessage(msg)
|
|
47
47
|
offset = np.eye(sigma1.shape[0]) * eps
|
|
48
48
|
covmean = linalg.sqrtm((sigma1 + offset).dot(sigma2 + offset))
|
|
49
49
|
|
|
@@ -51,15 +51,14 @@ def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
|
|
|
51
51
|
if np.iscomplexobj(covmean):
|
|
52
52
|
if not np.allclose(np.diagonal(covmean).imag, 0, atol=1e-3):
|
|
53
53
|
m = np.max(np.abs(covmean.imag))
|
|
54
|
-
|
|
54
|
+
UserMessage(f"Imaginary component {m}", raise_with=ValueError)
|
|
55
55
|
covmean = covmean.real
|
|
56
56
|
|
|
57
57
|
tr_covmean = np.trace(covmean)
|
|
58
|
-
|
|
59
|
-
return val
|
|
58
|
+
return diff.dot(diff) + np.trace(sigma1) + np.trace(sigma2) - 2 * tr_covmean
|
|
60
59
|
|
|
61
60
|
|
|
62
|
-
def calculate_mmd(x, y, kernel=
|
|
61
|
+
def calculate_mmd(x, y, kernel="rbf", kernel_mul=2.0, kernel_num=5, fix_sigma=None, eps=1e-9):
|
|
63
62
|
def gaussian_kernel(source, target, kernel_mul, kernel_num, fix_sigma):
|
|
64
63
|
n_samples = source.shape[0] + target.shape[0]
|
|
65
64
|
total = np.concatenate([source, target], axis=0)
|
|
@@ -67,28 +66,28 @@ def calculate_mmd(x, y, kernel='rbf', kernel_mul=2.0, kernel_num=5, fix_sigma=No
|
|
|
67
66
|
total1 = np.expand_dims(total, 1)
|
|
68
67
|
L2_distance = np.sum((total0 - total1) ** 2, axis=2)
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
bandwidth = fix_sigma
|
|
72
|
-
else:
|
|
73
|
-
bandwidth = np.sum(L2_distance) / (n_samples ** 2 - n_samples + eps)
|
|
69
|
+
bandwidth = fix_sigma or np.sum(L2_distance) / (n_samples**2 - n_samples + eps)
|
|
74
70
|
bandwidth /= kernel_mul ** (kernel_num // 2)
|
|
75
|
-
bandwidth_list = [bandwidth * (kernel_mul
|
|
76
|
-
kernel_val = [
|
|
71
|
+
bandwidth_list = [bandwidth * (kernel_mul**i) for i in range(kernel_num)]
|
|
72
|
+
kernel_val = [
|
|
73
|
+
np.exp(-L2_distance / (bandwidth_temp + eps)) for bandwidth_temp in bandwidth_list
|
|
74
|
+
]
|
|
77
75
|
return np.sum(kernel_val, axis=0)
|
|
78
76
|
|
|
79
77
|
def linear_mmd2(f_of_X, f_of_Y):
|
|
80
78
|
delta = f_of_X.mean(axis=0) - f_of_Y.mean(axis=0)
|
|
81
|
-
|
|
82
|
-
return loss
|
|
79
|
+
return np.dot(delta, delta.T)
|
|
83
80
|
|
|
84
|
-
if kernel ==
|
|
81
|
+
if kernel == "linear":
|
|
85
82
|
return linear_mmd2(x, y)
|
|
86
|
-
|
|
83
|
+
if kernel == "rbf":
|
|
87
84
|
batch_size = x.shape[0]
|
|
88
|
-
kernels = gaussian_kernel(
|
|
85
|
+
kernels = gaussian_kernel(
|
|
86
|
+
x, y, kernel_mul=kernel_mul, kernel_num=kernel_num, fix_sigma=fix_sigma
|
|
87
|
+
)
|
|
89
88
|
xx = np.mean(kernels[:batch_size, :batch_size])
|
|
90
89
|
yy = np.mean(kernels[batch_size:, batch_size:])
|
|
91
90
|
xy = np.mean(kernels[:batch_size, batch_size:])
|
|
92
91
|
yx = np.mean(kernels[batch_size:, :batch_size])
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
return xx + yy - xy - yx
|
|
93
|
+
return None
|