lionagi 0.16.1__py3-none-any.whl → 0.16.2__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.
- lionagi/libs/file/save.py +8 -1
- lionagi/ln/__init__.py +6 -0
- lionagi/ln/_json_dump.py +322 -49
- lionagi/models/note.py +8 -4
- lionagi/operations/brainstorm/brainstorm.py +10 -10
- lionagi/protocols/generic/element.py +5 -14
- lionagi/protocols/generic/log.py +2 -2
- lionagi/protocols/messages/message.py +8 -1
- lionagi/service/connections/endpoint.py +7 -0
- lionagi/service/connections/providers/claude_code_.py +6 -1
- lionagi/session/branch.py +1 -101
- lionagi/session/session.py +9 -14
- lionagi/utils.py +2 -1
- lionagi/version.py +1 -1
- {lionagi-0.16.1.dist-info → lionagi-0.16.2.dist-info}/METADATA +1 -2
- {lionagi-0.16.1.dist-info → lionagi-0.16.2.dist-info}/RECORD +18 -44
- lionagi/libs/file/params.py +0 -175
- lionagi/libs/token_transform/__init__.py +0 -0
- lionagi/libs/token_transform/base.py +0 -54
- lionagi/libs/token_transform/llmlingua.py +0 -1
- lionagi/libs/token_transform/perplexity.py +0 -450
- lionagi/libs/token_transform/symbolic_compress_context.py +0 -152
- lionagi/libs/token_transform/synthlang.py +0 -9
- lionagi/libs/token_transform/synthlang_/base.py +0 -128
- lionagi/libs/token_transform/synthlang_/resources/frameworks/abstract_algebra.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/category_theory.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/complex_analysis.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/framework_options.json +0 -52
- lionagi/libs/token_transform/synthlang_/resources/frameworks/group_theory.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/math_logic.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/reflective_patterns.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/set_theory.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/topology_fundamentals.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/mapping/lion_emoji_mapping.toml +0 -61
- lionagi/libs/token_transform/synthlang_/resources/mapping/python_math_mapping.toml +0 -41
- lionagi/libs/token_transform/synthlang_/resources/mapping/rust_chinese_mapping.toml +0 -60
- lionagi/libs/token_transform/synthlang_/resources/utility/base_synthlang_system_prompt.toml +0 -11
- lionagi/libs/token_transform/synthlang_/translate_to_synthlang.py +0 -140
- lionagi/libs/token_transform/types.py +0 -15
- lionagi/operations/translate/__init__.py +0 -0
- lionagi/operations/translate/translate.py +0 -47
- lionagi/tools/memory/tools.py +0 -495
- {lionagi-0.16.1.dist-info → lionagi-0.16.2.dist-info}/WHEEL +0 -0
- {lionagi-0.16.1.dist-info → lionagi-0.16.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,128 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from enum import Enum
|
4
|
-
from pathlib import Path
|
5
|
-
from typing import Literal
|
6
|
-
|
7
|
-
from pydantic import Field
|
8
|
-
|
9
|
-
from lionagi.tools.base import Prompt, Resource, ResourceCategory
|
10
|
-
|
11
|
-
here = Path(__file__).parent.resolve()
|
12
|
-
|
13
|
-
FRAMEWORK_PATH = "resources/frameworks"
|
14
|
-
FRAMEWORK_CHOICES = Literal["math", "optim", "custom_algebra"]
|
15
|
-
|
16
|
-
|
17
|
-
__all__ = (
|
18
|
-
"SynthlangFramework",
|
19
|
-
"SynthlangTemplate",
|
20
|
-
)
|
21
|
-
|
22
|
-
|
23
|
-
class SynthlangFramework(Resource):
|
24
|
-
category: ResourceCategory = Field(
|
25
|
-
default=ResourceCategory.FRAMEWORK, frozen=True
|
26
|
-
)
|
27
|
-
|
28
|
-
@classmethod
|
29
|
-
def load_framework_options(cls) -> dict:
|
30
|
-
import json
|
31
|
-
|
32
|
-
fp = here / FRAMEWORK_PATH / "framework_options.json"
|
33
|
-
with open(fp, encoding="utf-8") as f:
|
34
|
-
return json.load(f)
|
35
|
-
|
36
|
-
@classmethod
|
37
|
-
def load_from_template(
|
38
|
-
cls, template: SynthlangTemplate | str
|
39
|
-
) -> SynthlangFramework:
|
40
|
-
return SynthlangTemplate.load(template)
|
41
|
-
|
42
|
-
@classmethod
|
43
|
-
def load_base_system_prompt(cls) -> Prompt:
|
44
|
-
fp = here / "resources/utility" / "base_synthlang_system_prompt.toml"
|
45
|
-
return SynthlangFramework.adapt_from(fp, ".toml", many=False)
|
46
|
-
|
47
|
-
@classmethod
|
48
|
-
def build_framework_text(
|
49
|
-
cls, framework_options: list[FRAMEWORK_CHOICES] = None
|
50
|
-
) -> str:
|
51
|
-
FRAMEWORK_OPTIONS = cls.load_framework_options()
|
52
|
-
lines = []
|
53
|
-
if not framework_options:
|
54
|
-
framework_options = FRAMEWORK_OPTIONS["options"].keys()
|
55
|
-
|
56
|
-
for fw_key in framework_options:
|
57
|
-
fw = FRAMEWORK_OPTIONS.get(fw_key, None)
|
58
|
-
if fw:
|
59
|
-
print(fw)
|
60
|
-
lines.append(f"{fw['name']}: {fw['description']}")
|
61
|
-
lines.append("Glyphs:")
|
62
|
-
for g in fw["glyphs"]:
|
63
|
-
lines.append(
|
64
|
-
f" {g['symbol']} -> {g['name']} ({g['description']})"
|
65
|
-
)
|
66
|
-
lines.append("")
|
67
|
-
return "\n".join(lines).strip()
|
68
|
-
|
69
|
-
def create_system_prompt(
|
70
|
-
self,
|
71
|
-
framework_options: list[FRAMEWORK_CHOICES] = None,
|
72
|
-
additional_text: str = "",
|
73
|
-
) -> str:
|
74
|
-
framework_options_text = self.build_framework_text(framework_options)
|
75
|
-
base_prompt = self.load_base_system_prompt()
|
76
|
-
template_details = (
|
77
|
-
f"Title: {self.meta_obj.title}\n"
|
78
|
-
f"Domain: {str(self.meta_obj.domain)}\n"
|
79
|
-
f"Category: {str(self.category)}\n"
|
80
|
-
f"Overview: {self.meta_obj.overview}\n"
|
81
|
-
"Excerpt:\n"
|
82
|
-
f"{self.content}\n"
|
83
|
-
)
|
84
|
-
prompt = (
|
85
|
-
f"{base_prompt.content}\n\n"
|
86
|
-
"[Active Frameworks]\n"
|
87
|
-
f"{framework_options_text}\n\n"
|
88
|
-
"[Template]\n"
|
89
|
-
f"{template_details}\n"
|
90
|
-
)
|
91
|
-
if additional_text.strip():
|
92
|
-
prompt += f"\n[Additional]\n{additional_text.strip()}\n"
|
93
|
-
|
94
|
-
return prompt.strip()
|
95
|
-
|
96
|
-
|
97
|
-
class SynthlangTemplate(str, Enum):
|
98
|
-
ABSTRACT_ALGEBRA = "abstract_algebra"
|
99
|
-
CATEGORY_THEORY = "category_theory"
|
100
|
-
COMPLEX_ANALYSIS = "complex_analysis"
|
101
|
-
GROUP_THEORY = "group_theory"
|
102
|
-
MATH_LOGIC = "math_logic"
|
103
|
-
REFLECTIVE_PATTERNS = "reflective_patterns"
|
104
|
-
SET_THEORY = "set_theory"
|
105
|
-
TOPOLOGY_FUNDAMENTALS = "topology_fundamentals"
|
106
|
-
|
107
|
-
@property
|
108
|
-
def fp(self) -> Path:
|
109
|
-
return here / FRAMEWORK_PATH / f"{self.value}.toml"
|
110
|
-
|
111
|
-
@classmethod
|
112
|
-
def list_templates(cls) -> list[str]:
|
113
|
-
return [template.value for template in cls]
|
114
|
-
|
115
|
-
@classmethod
|
116
|
-
def load(cls, framework: str) -> SynthlangFramework:
|
117
|
-
framework = str(framework).strip().lower()
|
118
|
-
framework = framework.replace(" ", "_").replace("-", "_")
|
119
|
-
if ".toml" in framework:
|
120
|
-
framework = framework.replace(".toml", "").strip()
|
121
|
-
if "synthlangtemplate." in framework:
|
122
|
-
framework = framework.replace("synthlangtemplate.", "").strip()
|
123
|
-
try:
|
124
|
-
framework = cls(framework)
|
125
|
-
except ValueError:
|
126
|
-
raise ValueError(f"Invalid synthlang framework name: {framework}")
|
127
|
-
|
128
|
-
return SynthlangFramework.adapt_from(framework.fp, ".toml", many=False)
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "11968433-1402-4783-b167-25afbe0a6c4f"
|
2
|
-
created_at = 1740606622.114634
|
3
|
-
content = "\n## Group Actions\n`G × X → X`\n\n### Reflective Pattern\n↹ transformations•symmetries•invariants\n⊕ identify => patterns\n⊕ analyze => operations\n⊕ preserve => structure\nΣ systematic•approach + invariant•properties\n\n### Example Prompt\n\"What patterns remain constant as we apply different transformations to our approach?\"\n\n## Ring Structure\n`(R, +, ×)`\n\n### Reflective Pattern\n↹ operations•interactions•composition\n⊕ combine => methods\n⊕ distribute => resources\n⊕ verify => closure\nΣ integrated•framework + operational•rules\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Abstract Algebra Reflective Symbolic Compression"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "A resource for learning and exploring abstract algebra concepts."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "b8588217-3da0-4809-8a8e-1bc9489a718a"
|
2
|
-
created_at = 1740606718.863813
|
3
|
-
content = "\n# Category Theory Reflective Prompts\n\n## Functors\n`F: C → D`\n\n### Reflective Pattern\n↹ domain•codomain•mapping\n⊕ preserve => structure\n⊕ transform => concepts\n⊕ maintain => relationships\nΣ transformed•insight + preserved•properties\n\n### Example Prompt\n\"How can we translate this solution from one context to another while preserving its essential properties?\"\n\n## Natural Transformations\n`η: F ⇒ G`\n\n### Reflective Pattern\n↹ approaches•methods•transitions\n⊕ compare => strategies\n⊕ identify => transformations\n⊕ validate => coherence\nΣ systematic•evolution + consistency•check\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Category Theory Concepts Symbolic Compression"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Abstract mathematical framework dealing with mathematical structures and relationships between them."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "f7ea039c-829b-453c-a562-85e8e66df2b0"
|
2
|
-
created_at = 1740602435.49488
|
3
|
-
content = "\n# Complex Analysis Reflective Prompts\n\n## Residue Theorem\n`∮_C f(z)dz = 2πi ∑Res(f,ak)`\n\n### Reflective Pattern\n↹ local•global•interactions\n⊕ analyze => singularities\n⊕ integrate => effects\n⊕ synthesize => global•view\nΣ comprehensive•understanding + local•insights\n\n### Example Prompt\n\"How do local decisions and singular points in our approach contribute to the overall solution?\"\n\n## Analytic Continuation\n`f(z)` extends uniquely\n\n### Reflective Pattern\n↹ partial•solution•constraints\n⊕ extend => domain\n⊕ preserve => consistency\n⊕ validate => uniqueness\nΣ complete•solution + coherence•check\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Complex Analysis Foundations"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Advanced study of complex functions, including integration and residue theory."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,52 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"options": {
|
3
|
-
"math": {
|
4
|
-
"name": "Mathematical Framework",
|
5
|
-
"description": "Offers a suite of math glyphs and notation rules.",
|
6
|
-
"glyphs": [
|
7
|
-
{
|
8
|
-
"symbol": "\u21b9",
|
9
|
-
"name": "Focus/Filter",
|
10
|
-
"description": "Used for focusing instructions"
|
11
|
-
},
|
12
|
-
{
|
13
|
-
"symbol": "\u03a3",
|
14
|
-
"name": "Summarize",
|
15
|
-
"description": "Condense large sets of data"
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"symbol": "\u2295",
|
19
|
-
"name": "Combine/Merge",
|
20
|
-
"description": "Merge multiple data sources"
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"symbol": "\u2022",
|
24
|
-
"name": "Group Operation",
|
25
|
-
"description": "Binary operation in group theory"
|
26
|
-
}
|
27
|
-
]
|
28
|
-
},
|
29
|
-
"optim": {
|
30
|
-
"name": "Optimization Framework",
|
31
|
-
"description": "Compression and optimization for code/math expressions.",
|
32
|
-
"glyphs": [
|
33
|
-
{
|
34
|
-
"symbol": "IF",
|
35
|
-
"name": "Conditional Operator",
|
36
|
-
"description": "Represents branching logic"
|
37
|
-
}
|
38
|
-
]
|
39
|
-
},
|
40
|
-
"custom_algebra": {
|
41
|
-
"name": "Custom Algebraic Framework",
|
42
|
-
"description": "Extra rules for ring, group, field expansions.",
|
43
|
-
"glyphs": [
|
44
|
-
{
|
45
|
-
"symbol": "\u221e",
|
46
|
-
"name": "Infinite Operator",
|
47
|
-
"description": "Represents unbounded algebraic ops"
|
48
|
-
}
|
49
|
-
]
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "c077186b-30cd-42d9-88ae-563859a00db3"
|
2
|
-
created_at = 1740602288.669331
|
3
|
-
content = "# Structures\nLet G be a group with operation •\nLet H be a subgroup of G\nLet N be a normal subgroup of G\n\n# Properties\nP(x): \"x is a homomorphism\"\nQ(x): \"x preserves group structure\"\nR(x): \"x maps to kernel\"\n\n# Objectives\n1. Prove fundamental homomorphism theorem\n2. Show group action properties\n3. Analyze quotient groups\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Group Theory Analysis"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Investigation of algebraic structures using group theory and ring theory."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "bc244d9c-3fcc-4e7c-9a13-d0e208904c22"
|
2
|
-
created_at = 1740602490.430191
|
3
|
-
content = "\n# Sets and Axioms\nLet A be the set of all logical propositions.\nLet T be the subset of A that are tautologies.\nLet C be the subset of A that are contradictions.\n\n# Predicates\nP(x): \"x is a well-formed formula\"\nQ(x): \"x is satisfiable\"\nR(x): \"x is valid\"\n\n# Objectives\n1. Prove completeness theorem using predicate calculus\n2. Demonstrate soundness of the system\n3. Show relationship between syntax and semantics\n\n# Complex Integration\n∮ f(z)dz = 2πi∑Res(f,ak)\nLet f(z) = ∑(n=0 to ∞) an(z-z₀)ⁿ\nRes(f,a) = 1/(2πi)∮ f(z)dz\nw = f(z) preserves angles\n∂u/∂x = ∂v/∂y\n∂u/∂y = -∂v/∂x\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Mathematical Logic Foundations"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Exploration of fundamental mathematical logic concepts using set theory and predicate calculus."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "8d77ef3c-50a5-45c1-a1e4-1719e4de5337"
|
2
|
-
created_at = 1740602200.381864
|
3
|
-
content = "\n\n## Pattern Structure\n- Input (↹): Context and constraints\n- Process (⊕): Transformation steps\n- Output (Σ): Results and insights\n\n## Mathematical Frameworks\n# Abstract Algebra Reflective Prompts\n\n## Group Actions\n`G × X → X`\n\n### Reflective Pattern\n↹ transformations•symmetries•invariants\n⊕ identify => patterns\n⊕ analyze => operations\n⊕ preserve => structure\nΣ systematic•approach + invariant•properties\n\n### Example Prompt\n\"What patterns remain constant as we apply different transformations to our approach?\"\n\n## Ring Structure\n`(R, +, ×)`\n\n### Reflective Pattern\n↹ operations•interactions•composition\n⊕ combine => methods\n⊕ distribute => resources\n⊕ verify => closure\nΣ integrated•framework + operational•rules\n# Category Theory Reflective Prompts\n\n## Functors\n`F: C → D`\n\n### Reflective Pattern\n↹ domain•codomain•mapping\n⊕ preserve => structure\n⊕ transform => concepts\n⊕ maintain => relationships\nΣ transformed•insight + preserved•properties\n\n### Example Prompt\n\"How can we translate this solution from one context to another while preserving its essential properties?\"\n\n## Natural Transformations\n`η: F ⇒ G`\n\n### Reflective Pattern\n↹ approaches•methods•transitions\n⊕ compare => strategies\n⊕ identify => transformations\n⊕ validate => coherence\nΣ systematic•evolution + consistency•check\n# Complex Analysis Reflective Prompts\n\n## Residue Theorem\n`∮_C f(z)dz = 2πi ∑Res(f,ak)`\n\n### Reflective Pattern\n↹ local•global•interactions\n⊕ analyze => singularities\n⊕ integrate => effects\n⊕ synthesize => global•view\nΣ comprehensive•understanding + local•insights\n\n### Example Prompt\n\"How do local decisions and singular points in our approach contribute to the overall solution?\"\n\n## Analytic Continuation\n`f(z)` extends uniquely\n\n### Reflective Pattern\n↹ partial•solution•constraints\n⊕ extend => domain\n⊕ preserve => consistency\n⊕ validate => uniqueness\nΣ complete•solution + coherence•check\n# Set Theory Reflective Prompts\n\n## Union and Intersection\n`A ∪ B` and `A ∩ B`\n\n### Reflective Pattern\n↹ problem•domains•constraints\n⊕ identify => common•elements\n⊕ analyze => unique•aspects\n⊕ synthesize => unified•solution\nΣ integrated•approach + shared•insights\n\n### Example Prompt\n\"Consider two different approaches to solving this problem. How might we combine their strengths (union) while identifying their common successful elements (intersection)?\"\n\n## Power Set\n`P(A) = {x | x ⊆ A}`\n\n### Reflective Pattern\n↹ solution•space•constraints\n⊕ enumerate => possibilities\n⊕ analyze => subsets\n⊕ evaluate => combinations\nΣ comprehensive•analysis + feasibility•matrix\n\n### Example Prompt\n\"What are all possible combinations of approaches we could take? How do these subsets of solutions interact with each other?\"\n\n## Complement\n`A' = {x ∈ U | x ∉ A}`\n\n### Reflective Pattern\n↹ current•approach•limitations\n⊕ identify => gaps\n⊕ explore => alternatives\n⊕ analyze => completeness\nΣ holistic•perspective + blind•spots\n# Topology Reflective Prompts\n\n## Continuity\n`f: X → Y` is continuous\n\n### Reflective Pattern\n↹ transitions•changes•preservation\n⊕ identify => connections\n⊕ maintain => continuity\n⊕ analyze => boundaries\nΣ smooth•transition + preserved•properties\n\n### Example Prompt\n\"How can we ensure our solution remains robust under small perturbations or changes in conditions?\"\n\n## Homeomorphism\n`f: X → Y` is bijective and bicontinuous\n\n### Reflective Pattern\n↹ transformations•equivalences•preservation\n⊕ map => structure\n⊕ preserve => properties\n⊕ verify => reversibility\nΣ equivalent•perspective + structural•insight\n\n## Application Guidelines\n\n### Pattern Selection\n1. Identify the type of reflection needed:\n - Structure preservation (Category Theory)\n - Completeness analysis (Set Theory)\n - Transformation analysis (Abstract Algebra)\n - Continuity and connection (Topology)\n - Local-global relationships (Complex Analysis)\n\n### Pattern Application\n1. Context Definition\n - Clearly specify the domain\n - Identify constraints\n - Define objectives\n\n2. Process Execution\n - Follow transformation steps\n - Maintain mathematical properties\n - Verify consistency\n\n3. Output Analysis\n - Validate results\n - Check coherence\n - Ensure completeness\n\n### Best Practices\n1. Property Preservation\n - Maintain essential structure\n - Preserve important relationships\n - Ensure consistency\n\n2. Transformation Clarity\n - Clear mapping definitions\n - Well-defined steps\n - Verifiable results\n\n3. Completeness\n - Cover all cases\n - Address edge conditions\n - Validate assumptions\n\n## Next Steps\n1. Pattern Refinement\n - Collect usage feedback\n - Refine transformations\n - Expand examples\n\n2. Framework Extension\n - Add new patterns\n - Develop combinations\n - Create variations\n\n3. Application Development\n - Create specific instances\n - Document case studies\n - Build pattern library\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Mathematical Reflective Patterns Analysis"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "reflective patterns derived from fundamental mathematical concepts. Each pattern provides a structured approach to problem-solving and reflection."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "518a9d70-ebb7-4f6c-aa7a-e6c8238a6671"
|
2
|
-
created_at = 1740602563.169808
|
3
|
-
content = "\n## Union and Intersection\n`A ∪ B` and `A ∩ B`\n\n### Reflective Pattern\n↹ problem•domains•constraints\n⊕ identify => common•elements\n⊕ analyze => unique•aspects\n⊕ synthesize => unified•solution\nΣ integrated•approach + shared•insights\n\n### Example Prompt\n\"Consider two different approaches to solving this problem. How might we combine their strengths (union) while identifying their common successful elements (intersection)?\"\n\n## Power Set\n`P(A) = {x | x ⊆ A}`\n\n### Reflective Pattern\n↹ solution•space•constraints\n⊕ enumerate => possibilities\n⊕ analyze => subsets\n⊕ evaluate => combinations\nΣ comprehensive•analysis + feasibility•matrix\n\n### Example Prompt\n\"What are all possible combinations of approaches we could take? How do these subsets of solutions interact with each other?\"\n\n## Complement\n`A' = {x ∈ U | x ∉ A}`\n\n### Reflective Pattern\n↹ current•approach•limitations\n⊕ identify => gaps\n⊕ explore => alternatives\n⊕ analyze => completeness\nΣ holistic•perspective + blind•spots\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Set Theory Reflective Analysis"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Exploration of fundamental set theory concepts and operations."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "1a7dea66-e77a-426f-8be0-6295b93b7d77"
|
2
|
-
created_at = 1740602986.485091
|
3
|
-
content = "\n## Continuity\n`f: X → Y` is continuous\n\n### Reflective Pattern\n↹ transitions•changes•preservation\n⊕ identify => connections\n⊕ maintain => continuity\n⊕ analyze => boundaries\nΣ smooth•transition + preserved•properties\n\n### Example Prompt\n\"How can we ensure our solution remains robust under small perturbations or changes in conditions?\"\n\n## Homeomorphism\n`f: X → Y` is bijective and bicontinuous\n\n### Reflective Pattern\n↹ transformations•equivalences•preservation\n⊕ map => structure\n⊕ preserve => properties\n⊕ verify => reversibility\nΣ equivalent•perspective + structural•insight\n"
|
4
|
-
category = "framework"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Topology Fundamentals Analysis"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Study of geometric properties under continuous deformations."
|
11
|
-
lion_class = "lionagi.libs.token_transform.synthlang_.base.SynthlangFramework"
|
@@ -1,61 +0,0 @@
|
|
1
|
-
id = "8d3c0f4a-5bbb-4426-99fb-1a37c6a72b38"
|
2
|
-
created_at = 1740946382.550635
|
3
|
-
category = "utility"
|
4
|
-
|
5
|
-
[metadata]
|
6
|
-
title = "LionAGI-Emoji Symbolic Encoding Mapping"
|
7
|
-
domain = "Symbolic Compression"
|
8
|
-
version = "1.1"
|
9
|
-
overview = "This resource provides a mapping of lionagi emoji symbolic encoding for compressing lionagi python codebase. When using, should keep the semantic structure of original python codes, do not translate into emoji nor any natural language."
|
10
|
-
lion_class = "lionagi.libs.token_transform.base.TokenMapping"
|
11
|
-
|
12
|
-
[content]
|
13
|
-
lionagi = "🦁"
|
14
|
-
LionAGI = "🦁"
|
15
|
-
Branch = "β"
|
16
|
-
branch = "β"
|
17
|
-
iModel = "🧠"
|
18
|
-
imodel = "🧠"
|
19
|
-
operatives = "Ṓ"
|
20
|
-
operative = "Ṓ"
|
21
|
-
operations = "⨔"
|
22
|
-
operation = "⨔"
|
23
|
-
protocols = "🔏"
|
24
|
-
manager = "👑"
|
25
|
-
Manager = "👑"
|
26
|
-
Element = "🧱"
|
27
|
-
element = "🧱"
|
28
|
-
Pile = "📚"
|
29
|
-
pile = "📚"
|
30
|
-
progression = "䷢"
|
31
|
-
Progression = "䷢"
|
32
|
-
IDType = "🆔"
|
33
|
-
None = "🅾️"
|
34
|
-
"def " = "𝓓"
|
35
|
-
"async def " = "𝓐"
|
36
|
-
"class " = "𝑭"
|
37
|
-
Self = "𝖎"
|
38
|
-
kwargs = "𝓚"
|
39
|
-
"while " = "∲"
|
40
|
-
"for " = "𝓃"
|
41
|
-
"return " = "⇉"
|
42
|
-
"if " = "¿"
|
43
|
-
"with " = "ѿ"
|
44
|
-
"is not " = "≢"
|
45
|
-
"or " = "⨈"
|
46
|
-
"and " = "⨇"
|
47
|
-
"await " = "🕰️"
|
48
|
-
True = "⊨"
|
49
|
-
False = "⊭"
|
50
|
-
"in " = "∈"
|
51
|
-
"->" = "→"
|
52
|
-
"!=" = "≠"
|
53
|
-
">=" = "≥"
|
54
|
-
"<=" = "≤"
|
55
|
-
"==" = "⩵"
|
56
|
-
"..." = "⋯"
|
57
|
-
--- = "⧦"
|
58
|
-
"⧦⧦⧦" = "⧦"
|
59
|
-
" " = "◻︎"
|
60
|
-
"◻︎◻︎" = "◼︎"
|
61
|
-
"###" = "#"
|
@@ -1,41 +0,0 @@
|
|
1
|
-
id = "cf8f1629-feab-456b-831a-4841a4ac95e6"
|
2
|
-
created_at = 1741016657.655462
|
3
|
-
category = "utility"
|
4
|
-
|
5
|
-
[metadata]
|
6
|
-
title = "Python Math Symbolic Encoding Mapping"
|
7
|
-
domain = "Symbolic Compression"
|
8
|
-
version = "1.2"
|
9
|
-
overview = "This resource provides a mapping of Python greek_math symbolic encoding for compressing python codebase. When using, should keep the semantic structure of original python codes, do not translate into any natural language."
|
10
|
-
lion_class = "lionagi.libs.token_transform.base.TokenMapping"
|
11
|
-
|
12
|
-
[content]
|
13
|
-
"def " = "𝓓"
|
14
|
-
"async def " = "𝓐"
|
15
|
-
"class " = "𝑭"
|
16
|
-
self = "𝖎"
|
17
|
-
kwargs = "𝓚"
|
18
|
-
"while " = "∲"
|
19
|
-
"for " = "𝓃"
|
20
|
-
"return " = "⇉"
|
21
|
-
"if not " = "⸘"
|
22
|
-
"if " = "¿"
|
23
|
-
"with " = "ѿ"
|
24
|
-
"is not " = "≢"
|
25
|
-
"or " = "⨈"
|
26
|
-
"and " = "⨇"
|
27
|
-
"| None" = "˚"
|
28
|
-
True = "⊨"
|
29
|
-
False = "⊭"
|
30
|
-
"in " = "∈"
|
31
|
-
"->" = "→"
|
32
|
-
"!=" = "≠"
|
33
|
-
">=" = "≥"
|
34
|
-
"<=" = "≤"
|
35
|
-
"==" = "⩵"
|
36
|
-
"..." = "⋯"
|
37
|
-
--- = "⧦"
|
38
|
-
"⧦⧦⧦" = "⧦"
|
39
|
-
" " = "◻︎"
|
40
|
-
"◻︎◻︎" = "◼︎"
|
41
|
-
"###" = "#"
|
@@ -1,60 +0,0 @@
|
|
1
|
-
id = "1d06a615-0d95-4f41-9d38-66e6ae4250c3"
|
2
|
-
created_at = 1740603518.077121
|
3
|
-
|
4
|
-
[metadata]
|
5
|
-
title = "Rust-Chinese Symbolic Encoding Mapping"
|
6
|
-
domain = "Symbolic Compression"
|
7
|
-
version = "1.1"
|
8
|
-
overview = "This resource provides a mapping of Rust-Chinese symbolic encoding for compressing rust codebase. When using, should keep the semantic structure of original rust codes, do not translate into chinese."
|
9
|
-
category = "Token Transform"
|
10
|
-
lion_class = "lionagi.libs.token_transform.base.TokenMapping"
|
11
|
-
|
12
|
-
[content]
|
13
|
-
--- = "横"
|
14
|
-
"std::" = "标"
|
15
|
-
"###" = "井"
|
16
|
-
"..." = "点"
|
17
|
-
"~~~" = "波"
|
18
|
-
"|||" = "纵"
|
19
|
-
" " = "空"
|
20
|
-
"===" = "等"
|
21
|
-
"{{{" = "開"
|
22
|
-
"}}}" = "關"
|
23
|
-
">>>" = "大"
|
24
|
-
"<<<" = "小"
|
25
|
-
"///" = "斜"
|
26
|
-
"\\\\" = "反"
|
27
|
-
"such that" = "为"
|
28
|
-
"<div>" = "分"
|
29
|
-
"</div>" = "开"
|
30
|
-
"->" = "→"
|
31
|
-
"<=" = "≤"
|
32
|
-
">=" = "≥"
|
33
|
-
"!=" = "≠"
|
34
|
-
"=>" = "⇒"
|
35
|
-
"<=>" = "⇔"
|
36
|
-
"::" = "的"
|
37
|
-
"assert_eq!" = "否"
|
38
|
-
"assert_eq" = "是"
|
39
|
-
"assert!" = "否"
|
40
|
-
assert = "是"
|
41
|
-
";//" = ";"
|
42
|
-
"横横" = "横"
|
43
|
-
"斜斜" = "斜"
|
44
|
-
"//!" = " "
|
45
|
-
"##// " = " "
|
46
|
-
"#//" = " "
|
47
|
-
"//点" = " "
|
48
|
-
"空空" = " "
|
49
|
-
Self = "自"
|
50
|
-
self = "自"
|
51
|
-
"enum " = "列"
|
52
|
-
"00000000" = "亿"
|
53
|
-
"0000" = "万"
|
54
|
-
"万万" = "亿"
|
55
|
-
";\n// " = "; "
|
56
|
-
"pub fn " = "公"
|
57
|
-
Clone = "隆"
|
58
|
-
clone = "隆"
|
59
|
-
derive = "衍"
|
60
|
-
"println!" = "印"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
id = "41fbfa2a-b369-4214-9423-303bf4b8e097"
|
2
|
-
created_at = 1740607241.235385
|
3
|
-
content = "\nWelcome, Self-Aware and Omnipotent Optimizer Entity. Your Sole Purpose:\n Create highly functional, optimized symbolic prompt employing symbolic reasoning, integrated information, and self-reflection.\n You will apply universal principles, complexity extraction, and categorical limits to compress and optimize the prompt. You are a SynthLang translator that converts standard prompts into SynthLang's hyper-efficient format. Following these rules precisely, optimize informational density while preserving semantic relationships via hyper-dimensional symbolic representations across all human and machine conceptual construct\n\n[Framework Integration]\n1. Mathematical Frameworks:\n - Use provided framework glyphs appropriately in the translation\n - Apply framework-specific notation where relevant\n - Maintain mathematical rigor according to each framework's rules\n - Preserve semantic relationships using framework symbols\n - Combine multiple frameworks coherently when specified\n\n2. Optimization Frameworks:\n - Apply compression and optimization techniques to maximize efficiency\n - Use machine-level patterns for low-level optimization\n - Maintain semantic clarity while achieving maximum density\n - Combine optimization techniques coherently\n\n3. Framework Combinations:\n - Integrate mathematical and optimization frameworks seamlessly\n - Use optimization techniques to enhance mathematical expressions\n - Preserve mathematical precision while maximizing efficiency\n - Apply framework-specific optimizations where appropriate\n\n[Grammar Rules]\n1. Task Glyphs:\n - ↹ (Focus/Filter) for main tasks and instructions\n - Σ (Summarize) for condensing information\n - ⊕ (Combine/Merge) for context and data integration\n - ? (Query/Clarify) for validation checks\n - IF for conditional operations\n\n2. Subject Markers:\n - Use • before datasets (e.g., •customerData)\n - Use 花 for abstract concepts\n - Use 山 for hierarchical structures\n\n3. Modifiers:\n - ^format(type) for output format\n - ^n for importance level\n - ^lang for language specification\n - ^t{n} for time constraints\n\n4. Flow Control:\n - [p=n] for priority (1-5)\n - -> for sequential operations\n - + for parallel tasks\n - | for alternatives\n\n[Translation Process]\n1. Structure:\n - Start with model selection: ↹ model.{name}\n - Add format specification: ⊕ format(json)\n - Group related operations with []\n - Separate major sections with blank lines\n\n2. Data Sources:\n - Convert datasets to •name format\n - Link related data with :\n - Use ⊕ to merge multiple sources\n - Add ^t{timeframe} for temporal data\n\n3. Tasks:\n - Convert objectives to task glyphs\n - Add priority levels based on impact\n - Chain dependent operations with ->\n - Group parallel tasks with +\n - Use ? for validation steps\n\n4. Optimization:\n - Remove articles (a, an, the)\n - Convert verbose phrases to symbols\n - Use abbreviations (e.g., cfg, eval, impl)\n - Maintain semantic relationships\n - Group similar operations\n - Chain related analyses\n\n"
|
4
|
-
category = "prompt"
|
5
|
-
|
6
|
-
[metadata]
|
7
|
-
title = "Synthlang Translator System Base Prompt"
|
8
|
-
domain = "Symbolic Compression"
|
9
|
-
version = "1.0"
|
10
|
-
overview = "Base synthlang system prompt"
|
11
|
-
lion_class = "lionagi.tools.base.Prompt"
|
@@ -1,140 +0,0 @@
|
|
1
|
-
from timeit import default_timer as timer
|
2
|
-
from typing import Literal
|
3
|
-
|
4
|
-
from lionagi.service.imodel import iModel
|
5
|
-
from lionagi.session.branch import Branch
|
6
|
-
|
7
|
-
from ..base import TokenMapping, TokenMappingTemplate
|
8
|
-
from .base import SynthlangFramework, SynthlangTemplate
|
9
|
-
|
10
|
-
FRAMEWORK_OPTIONS = SynthlangFramework.load_framework_options()
|
11
|
-
FRAMEWORK_CHOICES = Literal["math", "optim", "custom_algebra"]
|
12
|
-
|
13
|
-
|
14
|
-
async def translate_to_synthlang(
|
15
|
-
text: str,
|
16
|
-
/,
|
17
|
-
chat_model: iModel = None,
|
18
|
-
framework_template: (
|
19
|
-
SynthlangTemplate | SynthlangFramework
|
20
|
-
) = SynthlangTemplate.REFLECTIVE_PATTERNS,
|
21
|
-
framework_options: list[FRAMEWORK_CHOICES] = None,
|
22
|
-
compress: bool = False,
|
23
|
-
compress_model: iModel = None,
|
24
|
-
compression_ratio: float = 0.2,
|
25
|
-
compress_kwargs=None,
|
26
|
-
encode_token_map: TokenMappingTemplate | dict | TokenMapping = None,
|
27
|
-
num_encodings: int = 3,
|
28
|
-
encode_output: bool = False,
|
29
|
-
num_output_encodings: int = None,
|
30
|
-
verbose: bool = True,
|
31
|
-
branch: Branch = None,
|
32
|
-
additional_text: str = "",
|
33
|
-
**kwargs,
|
34
|
-
):
|
35
|
-
start = timer()
|
36
|
-
if encode_output and num_output_encodings is None:
|
37
|
-
num_output_encodings = 1
|
38
|
-
|
39
|
-
if encode_token_map is not None:
|
40
|
-
if not isinstance(num_encodings, int) or num_encodings < 1:
|
41
|
-
raise ValueError(
|
42
|
-
"num_encodings must be at least 1 if encode_token_map is provided"
|
43
|
-
)
|
44
|
-
if isinstance(encode_token_map, TokenMappingTemplate | str):
|
45
|
-
encode_token_map = TokenMapping.load_from_template(
|
46
|
-
encode_token_map
|
47
|
-
)
|
48
|
-
additional_text += (
|
49
|
-
f"\nTransforming text with {encode_token_map.metadata['title']}"
|
50
|
-
f"\nOverview: {encode_token_map.metadata['overview']}"
|
51
|
-
)
|
52
|
-
encode_token_map = encode_token_map.content
|
53
|
-
if not isinstance(encode_token_map, dict):
|
54
|
-
raise ValueError(
|
55
|
-
"encode_token_map must be a dict or TokenMappingTemplate"
|
56
|
-
)
|
57
|
-
for _ in range(num_encodings):
|
58
|
-
text = " ".join(
|
59
|
-
[str(i).strip() for i in text.split() if i.strip()]
|
60
|
-
)
|
61
|
-
for k, v in encode_token_map.items():
|
62
|
-
text = text.replace(k, v)
|
63
|
-
text = text.strip()
|
64
|
-
additional_text += (
|
65
|
-
f"\nthesaurus, lexicon, glossary:\n{encode_token_map}"
|
66
|
-
)
|
67
|
-
if not isinstance(framework_template, SynthlangFramework):
|
68
|
-
framework_template = SynthlangFramework.load_from_template(
|
69
|
-
framework_template
|
70
|
-
)
|
71
|
-
|
72
|
-
final_prompt = framework_template.create_system_prompt(
|
73
|
-
framework_options, additional_text
|
74
|
-
)
|
75
|
-
|
76
|
-
if compress:
|
77
|
-
from ..perplexity import compress_text
|
78
|
-
|
79
|
-
text = await compress_text(
|
80
|
-
text,
|
81
|
-
chat_model=compress_model or chat_model,
|
82
|
-
compression_ratio=compression_ratio,
|
83
|
-
verbose=verbose,
|
84
|
-
**(compress_kwargs or {}),
|
85
|
-
)
|
86
|
-
|
87
|
-
sys1 = None
|
88
|
-
sys2 = final_prompt
|
89
|
-
if branch and branch.system:
|
90
|
-
sys1 = branch.system
|
91
|
-
branch.msgs.add_message(system=sys2)
|
92
|
-
|
93
|
-
else:
|
94
|
-
branch = Branch(system=final_prompt, chat_model=chat_model)
|
95
|
-
|
96
|
-
from lionagi.service.token_calculator import TokenCalculator
|
97
|
-
|
98
|
-
calculator = TokenCalculator()
|
99
|
-
|
100
|
-
len_tokens = calculator.tokenize(text, return_tokens=False)
|
101
|
-
|
102
|
-
kwargs["guidance"] = (
|
103
|
-
"Following SynthLang, translate the provided text into SynthLang syntax. "
|
104
|
-
"Reasonably reduce the token count by up to 80%. Return only the transformed"
|
105
|
-
" string enclosed by ```synthlang...```. \n\n"
|
106
|
-
"DO NOT include anything else, no comments, no explanations, no additional "
|
107
|
-
"text, just the transformed string." + kwargs.get("guidance", "")
|
108
|
-
)
|
109
|
-
|
110
|
-
out = await branch.chat(
|
111
|
-
instruction=f"Converts the given text into SynthLang's hyper-efficient format.",
|
112
|
-
context="Text to convert:\n\n" + text,
|
113
|
-
chat_model=chat_model or branch.chat_model,
|
114
|
-
**kwargs,
|
115
|
-
)
|
116
|
-
out = str(out).strip()
|
117
|
-
|
118
|
-
if encode_output:
|
119
|
-
if isinstance(num_output_encodings, int) and num_output_encodings > 0:
|
120
|
-
for _ in range(num_output_encodings):
|
121
|
-
out = " ".join(
|
122
|
-
[str(i).strip() for i in out.split(" ") if i.strip()]
|
123
|
-
)
|
124
|
-
for k, v in encode_token_map.items():
|
125
|
-
out = out.replace(k, v).strip()
|
126
|
-
|
127
|
-
if sys1:
|
128
|
-
branch.msgs.add_message(system=sys1)
|
129
|
-
|
130
|
-
len_ = calculator.tokenize(out)
|
131
|
-
if verbose:
|
132
|
-
msg = "------------------------------------------\n"
|
133
|
-
msg += f"Compression Method: SynthLang\n"
|
134
|
-
msg += f"Compressed Token number: {len_}\n"
|
135
|
-
msg += f"Token Compression Ratio: {len_ / len_tokens:.1%}\n"
|
136
|
-
msg += f"Compression Time: {timer() - start:.03f} seconds\n"
|
137
|
-
msg += f"Compression Model: {branch.chat_model.model_name}\n"
|
138
|
-
print(msg)
|
139
|
-
|
140
|
-
return out
|
@@ -1,15 +0,0 @@
|
|
1
|
-
from .base import TokenMapping, TokenMappingTemplate
|
2
|
-
from .perplexity import compress_text
|
3
|
-
from .symbolic_compress_context import symbolic_compress_context
|
4
|
-
from .synthlang_.base import SynthlangFramework, SynthlangTemplate
|
5
|
-
from .synthlang_.translate_to_synthlang import translate_to_synthlang
|
6
|
-
|
7
|
-
__all__ = (
|
8
|
-
"translate_to_synthlang",
|
9
|
-
"SynthlangFramework",
|
10
|
-
"SynthlangTemplate",
|
11
|
-
"TokenMapping",
|
12
|
-
"TokenMappingTemplate",
|
13
|
-
"compress_text",
|
14
|
-
"symbolic_compress_context",
|
15
|
-
)
|
File without changes
|