diff --git a/symbolicai-main/symbolicai-main/.gitbook.yaml b/symbolicai-main/symbolicai-main/.gitbook.yaml
deleted file mode 100644
index b591b5208e97744512725a5dd8cd50651c7bbe90..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/.gitbook.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-root: symbolicai/docs/source/
-
-structure:
- readme: INTRODUCTION.md
- summary: SUMMARY.md
diff --git a/symbolicai-main/symbolicai-main/.github/FUNDING.yml b/symbolicai-main/symbolicai-main/.github/FUNDING.yml
deleted file mode 100644
index 3efd81fdb00cbed499bb300bc1ce24e1641cdeea..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/.github/FUNDING.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-# These are supported funding model platforms
-
-github: [extensityAI] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
-patreon: # Replace with a single Patreon username
-open_collective: # Replace with a single Open Collective username
-ko_fi: # Replace with a single Ko-fi username
-tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
-community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
-liberapay: # Replace with a single Liberapay username
-issuehunt: # Replace with a single IssueHunt username
-otechie: # Replace with a single Otechie username
-lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
-custom: ['https://www.paypal.com/donate/?hosted_button_id=WCWP5D2QWZXFQ'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/symbolicai-main/symbolicai-main/.gitignore b/symbolicai-main/symbolicai-main/.gitignore
deleted file mode 100644
index d3bbbad9d5ae62d2132f6b73ca58766fd0ae9ac2..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/.gitignore
+++ /dev/null
@@ -1,163 +0,0 @@
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
-# C extensions
-*.so
-
-# Distribution / packaging
-.Python
-build/
-docs/_build/
-docs/.doctrees/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-wheels/
-pip-wheel-metadata/
-share/python-wheels/
-*.egg-info/
-.installed.cfg
-*.egg
-MANIFEST
-
-# PyInstaller
-# Usually these files are written by a python script from a template
-# before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
-.nox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*.cover
-*.py,cover
-.hypothesis/
-.pytest_cache/
-
-# Translations
-*.mo
-*.pot
-
-# Django stuff:
-*.log
-local_settings.py
-db.sqlite3
-db.sqlite3-journal
-
-# Flask stuff:
-instance/
-.webassets-cache
-
-# Scrapy stuff:
-.scrapy
-
-# Sphinx documentation
-docs/_build/
-
-# PyBuilder
-target/
-
-# Jupyter Notebook
-.ipynb_checkpoints
-
-# IPython
-profile_default/
-ipython_config.py
-
-# pyenv
-.python-version
-
-# pipenv
-# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
-# However, in case of collaboration, if having platform-specific dependencies or dependencies
-# having no cross-platform support, pipenv may install dependencies that don't work, or not
-# install all needed dependencies.
-#Pipfile.lock
-
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
-__pypackages__/
-
-# Celery stuff
-celerybeat-schedule
-celerybeat.pid
-
-# SageMath parsed files
-*.sage.py
-
-# Environments
-.env
-.venv
-env/
-venv/
-ENV/
-env.bak/
-venv.bak/
-
-# Spyder project settings
-.spyderproject
-.spyproject
-
-# Rope project settings
-.ropeproject
-
-# mkdocs documentation
-/site
-
-# mypy
-.mypy_cache/
-.dmypy.json
-dmypy.json
-
-# Pyre type checker
-.pyre/
-
-results/
-symai.config.json
-.DS_Store
-._.DS_Store
-**/.DS_Store
-**/._.DS_Store
-
-
-# ignore all files in the symai/extended/packages/ directory
-notebooks/demos/**/*
-.virtual_documents/notebooks
-notebooks/.virtual_documents
-outputs/
-demos/
-wandb/
-tmp/
-dist/
-bin/
-.idea
-scripts
-SymbolicAI_Installer_**.*
-entitlements.plist
-favicon.ico
-icon.ico
-icon.icns
-release_**/*
-packages/ExtensityAI/LightRAG-symai
-sympkg
-symsh
-.bash_history
-.conversation_state
diff --git a/symbolicai-main/symbolicai-main/.symai/symsh.config.json b/symbolicai-main/symbolicai-main/.symai/symsh.config.json
deleted file mode 100644
index 83759621706925dbc144d8b9f962fbdee1b93f9d..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/.symai/symsh.config.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "colors": {
- "completion-menu.completion.current": "bg:#323232 #212121",
- "completion-menu.completion": "bg:#800080 #212121",
- "scrollbar.background": "bg:#222222",
- "scrollbar.button": "bg:#776677",
- "history-completion": "bg:#212121 #f5f5f5",
- "path-completion": "bg:#800080 #f5f5f5",
- "file-completion": "bg:#9040b2 #f5f5f5",
- "history-completion-selected": "bg:#efefef #b3d7ff",
- "path-completion-selected": "bg:#efefef #b3d7ff",
- "file-completion-selected": "bg:#efefef #b3d7ff"
- },
- "map-nt-cmd": true,
- "show-splash-screen": true
-}
\ No newline at end of file
diff --git a/symbolicai-main/symbolicai-main/CITATION.cff b/symbolicai-main/symbolicai-main/CITATION.cff
deleted file mode 100644
index 32770ed85cb2db0f91a6f0bc904df1043aebf1cd..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/CITATION.cff
+++ /dev/null
@@ -1,12 +0,0 @@
-cff-version: 1.2.0
-message: "If you use this software, please cite it as below."
-authors:
-- family-names: "Dinu"
- given-names: "Marius-Constantin"
- orcid: "https://orcid.org/my-orcid?orcid=0000-0002-7518-3337"
-editors:
-- family-names: "Leoveanu-Condrei"
- given-names: "Claudiu"
-title: "SymbolicAI: A Neuro-Symbolic Perspective on Large Language Models (LLMs)"
-date-released: 2022-11-30
-url: "https://github.com/Xpitfire/symbolicai"
diff --git a/symbolicai-main/symbolicai-main/Dockerfile b/symbolicai-main/symbolicai-main/Dockerfile
deleted file mode 100644
index 6f667f1a3fb9918da476a4f0b5498e58411dbdc7..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/Dockerfile
+++ /dev/null
@@ -1,49 +0,0 @@
-# syntax=docker/dockerfile:1
-FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-devel
-
-LABEL symai.image.authors="extensity.ai" \
- symai.image.vendor="ExtensityAI" \
- symai.image.title="SymbolicAI" \
- symai.image.description="SymbolicAI: Compositional Differentiable Programming Library" \
- symai.image.source="https://github.com/ExtensityAI/symbolicai.git" \
- symai.image.revision="${VCS_REF}" \
- symai.image.created="${BUILD_DATE}" \
- symai.image.documentation="https://symbolicai.readthedocs.io/en/latest/README.html"
-LABEL symai.dependencies.versions.torch="2.0.1"
-LABEL symai.dependencies.versions.cuda="11.7"
-ARG DEBIAN_FRONTEND=noninteractive
-
-# NVIDIA key migration
-RUN apt-key del 7fa2af80
-RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
-RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64/7fa2af80.pub
-# Update the base image
-RUN apt update && apt upgrade -y
-
-# Install symai
-
-## Install dependencies
-RUN apt install -y curl sudo nano git htop netcat wget unzip tmux apt-utils cmake build-essential libgl1-mesa-glx libglib2.0-0
-
-## Upgrade pip
-RUN pip3 install --upgrade pip
-
-# Install nvm and pm2
-RUN curl -o install_nvm.sh https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh && \
- echo 'fabc489b39a5e9c999c7cab4d281cdbbcbad10ec2f8b9a7f7144ad701b6bfdc7 install_nvm.sh' | sha256sum --check && \
- bash install_nvm.sh
-
-RUN bash -c "source $HOME/.nvm/nvm.sh && \
- # use node 16
- nvm install 16 && \
- # install pm2
- npm install --location=global pm2"
-
-RUN mkdir -p /root/.symai/install
-COPY . /root/.symai/install
-RUN cd /root/.symai/install && python3 -m pip install ".[all]"
-
-# Increase ulimit to 1,000,000
-RUN prlimit --pid=$PPID --nofile=1000000
-
-EXPOSE 8999
diff --git a/symbolicai-main/symbolicai-main/MANIFEST.in b/symbolicai-main/symbolicai-main/MANIFEST.in
deleted file mode 100644
index d78ef472486146943c19b054fc9bc3c7a7addc59..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/MANIFEST.in
+++ /dev/null
@@ -1,4 +0,0 @@
-global-exclude test_*.py
-include symai/**/*
-include symai/backend/driver/*
-exclude **/*.pyc
\ No newline at end of file
diff --git a/symbolicai-main/symbolicai-main/README.md b/symbolicai-main/symbolicai-main/README.md
deleted file mode 100644
index b6e2905b87c11790aa2d623089d7eb4eaa7d0057..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/README.md
+++ /dev/null
@@ -1,371 +0,0 @@
-# **SymbolicAI: A neuro-symbolic perspective on LLMs**
-
-
-
-
-## What is SymbolicAI?
-
-SymbolicAI is a **neuro-symbolic** framework, combining classical Python programming with the differentiable, programmable nature of LLMs in a way that actually feels natural in Python.
-It's built to not stand in the way of your ambitions.
-It's easily extensible and customizable to your needs by virtue of its modular design.
-It's quite easy to [write your own engine](https://extensityai.gitbook.io/symbolicai/engines/custom_engine), [host locally](https://extensityai.gitbook.io/symbolicai/engines/local_engine) an engine of your choice, or interface with tools like [web search](https://extensityai.gitbook.io/symbolicai/engines/search_engine) or [image generation](https://extensityai.gitbook.io/symbolicai/engines/drawing_engine).
-To keep things concise in this README, we'll introduce two key concepts that define SymbolicAI: **primitives** and **contracts**.
-
-### Primitives
-At the core of SymbolicAI are `Symbol` objects—each one comes with a set of tiny, composable operations that feel like native Python.
-```python
-from symai import Symbol
-```
-
-`Symbol` comes in **two flavours**:
-
-1. **Syntactic** – behaves like a normal Python value (string, list, int ‐ whatever you passed in).
-2. **Semantic** – is wired to the neuro-symbolic engine and therefore *understands* meaning and
- context.
-
-Why is syntactic the default?
-Because Python operators (`==`, `~`, `&`, …) are overloaded in `symai`.
-If we would immediately fire the engine for *every* bitshift or comparison, code would be slow and could produce surprising side-effects.
-Starting syntactic keeps things safe and fast; you opt-in to semantics only where you need them.
-
-#### How to switch to the semantic view
-
-1. **At creation time**
-
- ```python
- S = Symbol("Cats are adorable", semantic=True) # already semantic
- print("feline" in S) # => True
- ```
-
-2. **On demand with the `.sem` projection** – the twin `.syn` flips you back:
-
- ```python
- S = Symbol("Cats are adorable") # default = syntactic
- print("feline" in S.sem) # => True
- print("feline" in S) # => False
- ```
-
-3. Invoking **dot-notation operations**—such as `.map()` or any other semantic function—automatically switches the symbol to semantic mode:
-
- ```python
- S = Symbol(['apple', 'banana', 'cherry', 'cat', 'dog'])
- print(S.map('convert all fruits to vegetables'))
- # => ['carrot', 'broccoli', 'spinach', 'cat', 'dog']
- ```
-
-Because the projections return the *same underlying object* with just a different behavioural coat, you can weave complex chains of syntactic and semantic operations on a single symbol. Think of them as your building blocks for semantic reasoning. Right now, we support a wide range of primitives; check out the docs [here](https://extensityai.gitbook.io/symbolicai/features/primitives), but here's a quick snack:
-
-| Primitive/Operator | Category | Syntactic | Semantic | Description |
-|--------------------|-----------------|:---------:|:--------:|-------------|
-| `==` | Comparison | ✓ | ✓ | Tests for equality. Syntactic: literal match. Semantic: fuzzy/conceptual equivalence (e.g. 'Hi' == 'Hello'). |
-| `+` | Arithmetic | ✓ | ✓ | Syntactic: numeric/string/list addition. Semantic: meaningful composition, blending, or conceptual merge. |
-| `&` | Logical/Bitwise | ✓ | ✓ | Syntactic: bitwise/logical AND. Semantic: logical conjunction, inference, e.g., context merge. |
-| `symbol[index] = value` | Iteration | ✓ | ✓ | Set item or slice. |
-| `.startswith(prefix)` | String Helper | ✓ | ✓ | Check if a string starts with given prefix (in both modes). |
-| `.choice(cases, default)` | Pattern Matching| | ✓ | Select best match from provided cases. |
-| `.foreach(condition, apply)`| Execution Control | | ✓ | Apply action to each element. |
-| `.cluster(**clustering_kwargs?)` | Data Clustering | | ✓ | Cluster data into groups semantically. (uses sklearn's DBSCAN)|
-| `.similarity(other, metric?, normalize?)` | Embedding | | ✓ | Compute similarity between embeddings. |
-| ... | ... | ...| ... | ... |
-
-### Contracts
-
-They say LLMs hallucinate—but your code can't afford to. That's why SymbolicAI brings **Design by Contract** principles into the world of LLMs. Instead of relying solely on post-hoc testing, contracts help build correctness directly into your design, everything packed into a decorator that will operate on your defined data models and validation constraints:
-```python
-from symai import Expression
-from symai.strategy import contract
-from symai.models import LLMDataModel # Compatible with Pydantic's BaseModel
-from pydantic import Field, field_validator
-
-# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
-# Data models ▬
-# – clear structure + rich Field descriptions power ▬
-# validation, automatic prompt templating & remedies ▬
-# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
-class DataModel(LLMDataModel):
- some_field: some_type = Field(description="very descriptive field", and_other_supported_options_here="...")
-
- @field_validator('some_field')
- def validate_some_field(cls, v):
- # Custom basic validation logic can be added here too besides pre/post
- valid_opts = ['A', 'B', 'C']
- if v not in valid_opts:
- raise ValueError(f'Must be one of {valid_opts}, got "{v}".')
- return v
-
-# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
-# The contracted expression class ▬
-# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
-@contract(
- # ── Remedies ─────────────────────────────────────────── #
- pre_remedy=True, # Try to fix bad inputs automatically
- post_remedy=True, # Try to fix bad LLM outputs automatically
- accumulate_errors=True, # Feed history of errors to each retry
- verbose=True, # Nicely displays progress in terminal
- remedy_retry_params=dict(tries=3, delay=0.4, max_delay=4.0,
- jitter=0.15, backoff=1.8, graceful=False),
-)
-class Agent(Expression):
- #
- # High-level behaviour:
- # *. `prompt` – a *static* description of what the LLM must do (mandatory)
- # 1. `pre` – sanity-check inputs (optional)
- # 2. `act` – mutate state (optional)
- # 3. LLM – generate expected answer (handled by SymbolicAI engine)
- # 4. `post` – ensure answer meets semantic rules (optional)
- # 5. `forward` (mandatory)
- # • if contract succeeded → return type validated LLM object
- # • else → graceful fallback answer
- # ...
-```
-
-Because we don't want to bloat this README file with long Python snippets, learn more about contracts [here](https://deepwiki.com/ExtensityAI/symbolicai/7.1-contract-validation-system) and [here](https://extensityai.gitbook.io/symbolicai/features/contracts).
-
-## Installation
-
-### Core Features
-
-To get started with SymbolicAI, you can install it using pip:
-
-```bash
-pip install symbolicai
-```
-
-#### Setting up a neurosymbolic API Key
-
-Before using SymbolicAI, you need to set up API keys for the various engines. Currently, SymbolicAI supports the following neurosymbolic engines through API: OpenAI, Anthropic. We also support {doc}`local neurosymbolic engines Cybersecurity Consolidation and the Equifax Settlement
-The upcoming year is likely to see a wave of cybersecurity consolidation, according to Jay Chaudhry, the CEO of Zscaler. This could be a major boon for stocks with high profit margins, which may rally by more than 50%. Consumers may also benefit from the Equifax settlement, receiving payments to help protect their online identities.
-However, it is important to understand the risks associated with using password managers to protect your online identity. Password managers can be a useful tool, but they can also create a single point of failure, meaning if someone were to gain access to your password manager, they would have access to all of your passwords. Therefore, it is important to do your research before deciding to use one.
-The Technology Executive Council's opening keynote on Monday, December 12th 2022, will discuss the intersection of finance, technology and national security. A few days prior, on Saturday, December 10th 2022, a Cyber Report was released noting that LinkedIn has a problem with fake accounts and is actively trying to fix it. On Sunday, December 11th 2022, Huawei announced that it had licensed 5G patents to a rival as U.S. sanctions have forced the Chinese giant to seek out new revenue.
-Wednesday, November 30th 2022, saw CrowdStrike stock go down on earnings, but Morgan Stanley advised to buy the dip.
-Monday, November 28th 2022, a discussion was held on the biggest risks of utilizing fitness trackers to monitor health.
-Friday, November 25th 2022, Fundstrat's Tom Lee spoke about how Bitcoin still makes sense for certain investors, and the same day the new iPhone 14 and iOS upgrade was released, including significant changes to cybersecurity.
-On Tuesday, November 22nd 2022, Chainalysis' CEO Michael Gronager spoke about protecting customers from bad actors in the crypto space.
-Monday, November 21st 2022, DraftKings declared that there was no evidence that their systems had been breached following a report of a hack. On the same day, a discussion was held on how BlackBerry had moved away from their iconic cellphones to focus on cybersecurity.
-Friday, November 18th 2022, Cohesity's CEO Sanjay Poonen discussed how cloud, data and security remain strong for software.
-Sunday, November 20th 2022, the White House's cybersecurity team discussed the potential threat posed by China's TikTok.
-Finally, on Friday, November 25th 2022, Palo Alto's Overtime was discussed.
-Beats recently announced that it had exceeded fourth quarter earnings estimates and that it had agreed to acquire Cider Security. As part of its ongoing expansion, Beats has also recently added CNBC on Peacock with an exclusive CNBC Panel.
-In addition to its digital products, Beats also offers news releases, closed captioning, corrections, and information about CNBC, internships, and its site map. Beats also provides users with ad choices, career opportunities, help, and contact news tips.
-Beats provides a great way for users to stay informed about the latest news and technology trends.
-We offer the following opportunities:
- -
-
-## 📈 Interface for Query and Response Inspection
-
-SymbolicAI is a data-driven framework by design. This implies that we can gather data from API interactions while delivering the requested responses. For rapid, dynamic adaptations or prototyping, we can swiftly integrate user-desired behavior into existing prompts. Moreover, we can log user queries and model predictions to make them accessible for post-processing. Consequently, we can enhance and tailor the model's responses based on real-world data.
-
-In the example below, we demonstrate how to use an `Output` expression to pass a handler function and access the model's input prompts and predictions. These can be utilized for data collection and subsequent fine-tuning stages. The handler function supplies a dictionary and presents keys for `input` and `output` values. The content can then be sent to a data pipeline for additional processing.
-
-```python
-sym = Symbol('Hello World!')
-def handler(res):
- input_ = res['input']
- output = res['output']
-expr = Output(expr=sym.translate,
- handler=handler,
- verbose=True)
-res = expr('German')
-```
-
-Since we used verbose, the console print of the `Output` expression is also visible:
-
-```bash
-Input: (['Translate the following text into German:\n\nHello World!'],)
-Expression:
-
-A Sequence expression can hold multiple expressions evaluated at runtime.
-
-## Expression Types
-
-### Sequence Expressions
-Here is an example of defining a Sequence expression:
-
-```python
-# First import all expressions
-from symai.components import *
-# Define a sequence of expressions
-Sequence(
- Clean(),
- Translate(),
- Outline(),
- Compose('Compose news:'),
-)
-```
-
-### Stream expressions
-
-As previously mentioned, we can create contextualized prompts to define the behavior of operations on our neural engine. However, this limits the available context size due to GPT-3 Davinci's context length constraint of 4097 tokens. This issue can be addressed using the `Stream` processing expression, which opens a data stream and performs chunk-based operations on the input stream.
-
-A Stream expression can be wrapped around other expressions. For example, the chunks can be processed with a `Sequence` expression that allows multiple chained operations in a sequential manner. Here is an example of defining a Stream expression:
-
-```python
-Stream(Sequence(
- Clean(),
- Translate(),
- Outline(),
- Embed()
-))
-```
-
-The example above opens a stream, passes a `Sequence` object which cleans, translates, outlines, and embeds the input. Internally, the stream operation estimates the available model context size and breaks the long input text into smaller chunks, which are passed to the inner expression. The returned object type is a `generator`.
-
-This approach has the drawback of processing chunks independently, meaning there is no shared context or information among chunks. To address this issue, the `Cluster` expression can be used, where the independent chunks are merged based on their similarity, as illustrated in the following figure:
-
-
-
-In the illustrated example, all individual chunks are merged by clustering the information within each chunk. It consolidates contextually related information, merging them meaningfully. The clustered information can then be labeled by streaming through the content of each cluster and extracting the most relevant labels, providing interpretable node summaries.
-
-The full example is shown below:
-
-```python
-stream = Stream(Sequence(
- Clean(),
- Translate(),
- Outline(),
-))
-sym = Symbol('
-
-The colors indicate logical groups of data processing steps. `Yellow` represents input and output data, `blue` shows places where one can customize or prepare the input of the engine, `green` indicates post-processing steps of the engine response, `red` displays the application of constraints (including attempted casting of the `return type signature` if specified in the decorated method), and `grey` denotes the custom method defining all properties, thus having access to all the previously mentioned objects.
-
-To conclude this section, here is an example of how to write a custom Japanese name generator using our `@ai.zero_shot` decorator:
-
-```python
-import symai as ai
-class Demo(ai.Symbol):
- @ai.few_shot(prompt="Generate Japanese names: ",
- examples=ai.Prompt(
- ["愛子", "和花", "一郎", "和枝"]
- ),
- limit=2,
- constraints=[lambda x: len(x) > 1])
- def generate_japanese_names(self) -> list:
- return ['愛子', '和花'] # dummy implementation
-```
-
-If the neural computation engine cannot compute the desired outcome, it will revert to the `default` implementation or default value. If no default implementation or value is found, the method call will raise an exception.
-
-## Prompt Design
-
-The `Prompt` class is used to perform all the above operations. Acting as a container for information required to define a specific operation, the `Prompt` class also serves as the base class for all other Prompt classes.
-
-Here's an example of defining a `Prompt` to enforce the neural computation engine to compare two values:
-
-```python
-class CompareValues(ai.Prompt):
- def __init__(self) -> ai.Prompt:
- super().__init__([
- "4 > 88 =>False",
- "-inf < 0 =>True",
- "inf > 0 =>True",
- "4 > 3 =>True",
- "1 < 'four' =>True",
- ...
- ])
-```
-
-When calling the `<=` operation on two Symbols, the neural computation engine evaluates the symbols in the context of the `CompareValues` prompt.
-
-```python
-res = ai.Symbol(1) <= ai.Symbol('one')
-```
-
-This statement evaluates to `True` since the fuzzy compare operation conditions the engine to compare the two Symbols based on their semantic meaning.
-
-```bash
-:[Output]:
-True
-```
-
-In general, the semantics of Symbol operations may vary depending on the context hierarchy of the expression class and the operations used. To better illustrate this, we display our conceptual prompt design in the following figure:
-
-
-
-The figure illustrates the hierarchical prompt design as a container for information provided to the neural computation engine to define a task-specific operation. The `yellow` and `green` highlighted boxes indicate mandatory string placements, dashed boxes represent optional placeholders, and the `red` box marks the starting point of model prediction.
-
-Three main prompt designs are considered: `Context-based Prompts`, `Operational Prompts`, and `Templates`. Prompts can be curated either by inheritance or composition. For example, `Static Context` can be defined by inheriting the `Expression` class and overriding the `static_context` property. An `Operation` and `Template` prompt can be created by providing a `PreProcessor` to modify input data.
-
-Each prompt concept is explained in more detail below:
-
-- `Context-based Prompts (Static, Dynamic, and Payload)` are considered optional and can be defined either statically (by subclassing the Expression class and overriding the `static_context` property) or at runtime (by updating the `dynamic_context` property or passing `payload` kwargs to a method). As an example of using the `payload` kwargs via method signature:
-
- ```python
- # creating a query to ask if an issue was resolved or not
- sym = Symbol("
-
-We adopt a divide-and-conquer approach, breaking down complex problems into smaller, manageable tasks. We use the expressiveness and flexibility of LLMs to evaluate these sub-problems. By re-combining the results of these operations, we can solve the broader, more complex problem.
-
-In time, and with sufficient data, we can gradually transition from general-purpose LLMs with `zero` and `few-shot` learning capabilities to specialized, fine-tuned models designed to solve specific problems. This strategy enables the design of operations with fine-tuned, task-specific behavior.
-
-## Core Concepts
-
-1. **Symbols**: All data objects are treated as symbols, with natural language as the primary interface for interaction.
-2. **Operations**: Contextualized functions that manipulate symbols and return new objects.
-3. **Expressions**: Non-terminal symbols that can be further evaluated, allowing for complex computational graphs.
-4. **Engines**: Various backends (e.g., GPT-3, WolframAlpha, CLIP) that power different types of computations and transformations.
-
-##
More fun facts!
-
-SymbolicAI is fundamentally inspired by the [`neuro-symbolic programming paradigm`](https://arxiv.org/abs/2210.05050).
-
-**Neuro-symbolic programming** is an artificial intelligence and cognitive computing paradigm that combines the strengths of deep neural networks and symbolic reasoning.
-
-**Deep neural networks** are machine learning algorithms inspired by the structure and function of biological neural networks. They excel in tasks such as image recognition and natural language processing. However, they struggle with tasks that necessitate explicit reasoning, like long-term planning, problem-solving, and understanding causal relationships.
-
-**Symbolic reasoning** uses formal languages and logical rules to represent knowledge, enabling tasks such as planning, problem-solving, and understanding causal relationships. While symbolic reasoning systems excel in tasks requiring explicit reasoning, they fall short in tasks demanding pattern recognition or generalization, like image recognition or natural language processing.
-
-**Neuro-symbolic programming** aims to merge the strengths of both neural networks and symbolic reasoning, creating AI systems capable of handling various tasks. This combination is achieved by using neural networks to extract information from data and utilizing symbolic reasoning to make inferences and decisions based on that data. Another approach is for symbolic reasoning to guide the neural networks' generative process and increase interpretability.
-
-**Embedded accelerators for LLMs** will likely be ubiquitous in future computation platforms, including wearables, smartphones, tablets, and notebooks. These devices will incorporate models similar to GPT-3, ChatGPT, OPT, or Bloom.
-
-
-
-LLMs are expected to perform a wide range of computations, like natural language understanding and decision-making. Additionally, neuro-symbolic computation engines will learn how to tackle unseen tasks and resolve complex problems by querying various data sources for solutions and executing logical statements on top.
-To ensure the content generated aligns with our objectives, it is crucial to develop methods for instructing, steering, and controlling the generative processes of machine learning models. As a result, our approach works to enable active and transparent flow control of these generative processes.
-
-
-
-The figure above depicts this generative process as shifting the probability mass of an input stream toward an output stream in a contextualized manner. With properly designed conditions and expressions, you can validate and guide the behavior towards a desired outcome or repeat expressions that fail to meet requirements. Our approach consists of defining a set of _fuzzy_ operations to manipulate the data stream and condition LLMs to align with our goals. We regard all data objects – such as strings, letters, integers, and arrays – as symbols and view natural language as the primary interface for interaction. See the following figure:
-
-
-
-As long as our goals can be expressed through natural language, LLMs can be used for neuro-symbolic computations.
-Consequently, we develop operations that manipulate these symbols to construct new symbols. Each symbol can be interpreted as a statement, and multiple statements can be combined to formulate a logical expression.
-
-By combining statements together, we can build causal relationship functions and complete computations, transcending reliance purely on inductive approaches. The resulting computational stack resembles a neuro-symbolic computation engine at its core, facilitating the creation of new applications in tandem with established frameworks.
-
-## Future Directions
-
-- Meta-learning semantic concepts on top of neuro-symbolic expressions
-- Self-evolving and self-healing API
-- Integration with reinforcement learning
-- Advancement in prompt design and value alignment methods
-
-SymbolicAI opens up new possibilities for creating applications that can perform self-analysis and self-repair, pushing the boundaries of what's possible with LLMs and neuro-symbolic computation.
\ No newline at end of file
diff --git a/symbolicai-main/symbolicai-main/docs/source/LICENSE b/symbolicai-main/symbolicai-main/docs/source/LICENSE
deleted file mode 100644
index 6d3f4b756de16265dadb746bebd023a4a92eaeec..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/LICENSE
+++ /dev/null
@@ -1,32 +0,0 @@
-License
-=======
-
-BSD 3-Clause License
-
-Copyright (c) 2024, ExtensityAI FlexCo.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-* Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/symbolicai-main/symbolicai-main/docs/source/QUICKSTART.md b/symbolicai-main/symbolicai-main/docs/source/QUICKSTART.md
deleted file mode 100644
index a635791fd9a35dc27703a7f4a384bc35d314ecf7..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/QUICKSTART.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# Quick Start Guide
-
-This guide will help you get started with SymbolicAI, demonstrating basic usage and key features.
-
-**Note**: the most accurate documentation is the _code_, so be sure to check out the tests. Look for the `mandatory` mark since those are the features that were tested and are guaranteed to work.
-
-For more detailed information about usage, refer to the materials available [here](https://extensityai.gitbook.io/symbolicai/features/contracts) and [here](https://extensityai.gitbook.io/symbolicai/features/primitives).
-
-To start, import the library by using:
-
-```python
-from symai import Symbol
-```
-
-## Creating and Manipulating Symbols
-
-Our `Symbolic API` is based on object-oriented and compositional design patterns. The `Symbol` class serves as the base class for all functional operations, and in the context of symbolic programming (fully resolved expressions), we refer to it as a terminal symbol. The Symbol class contains helpful operations that can be interpreted as expressions to manipulate its content and evaluate new Symbols `
-
-Similar to word2vec, we aim to perform contextualized operations on different symbols. However, as opposed to operating in vector space, we work in the natural language domain. This provides us the ability to perform arithmetic on words, sentences, paragraphs, etc., and verify the results in a human-readable format.
-
-The following examples display how to evaluate such an expression using a string representation:
-
-```python
-# Word analogy
-S = Symbol('King - Man + Women').interpret()
-print(S) # Output: Queen
-```
-
-### Dynamic Casting
-
-We can also subtract sentences from one another, where our operations condition the neural computation engine to evaluate the Symbols by their best effort. In the subsequent example, it identifies that the word `enemy` is present in the sentence, so it deletes it and replaces it with the word `friend` (which is added):
-
-```python
-# Sentence manipulation
-S = Symbol('Hello my enemy').sem - 'enemy' + 'friend'
-print(S) # Output: Hello my friend
-```
-
-Additionally, the API performs dynamic casting when data types are combined with a Symbol object. If an overloaded operation of the Symbol class is employed, the Symbol class can automatically cast the second object to a Symbol. This is a convenient way to perform operations between `Symbol` objects and other data types, such as strings, integers, floats, lists, etc., without cluttering the syntax.
-
-### Probabilistic Programming
-
-In this example, we perform a fuzzy comparison between two numerical objects. The `Symbol` variant is an approximation of `numpy.pi`. Despite the approximation, the fuzzy equals `==` operation still successfully compares the two values and returns `True`.
-
-```python
-# Fuzzy comparison
-# # Fuzzy comparison
-S = Symbol('3.14159...', semantic=True)
-print(S == 'π') # Output: True
-```
-
-### 🧠 Causal Reasoning
-
-The main goal of our framework is to enable reasoning capabilities on top of the statistical inference of Language Models (LMs). As a result, our `Symbol` objects offers operations to perform deductive reasoning expressions. One such operation involves defining rules that describe the causal relationship between symbols. The following example demonstrates how the `&` operator is overloaded to compute the logical implication of two symbols.
-
-```python
-S1 = Symbol('The horn only sounds on Sundays.', semantic=True)
-S2 = Symbol('I hear the horn.')
-res = S1 & S2 # Therefore, it is Sunday.
-```
-
-### 🪜 Next Steps
-Now, there are tools like DeepWiki that provide better documentation than we could ever write, and we don’t want to compete with that; we'll correct it where it's plain wrong. Please go read SymbolicAI's DeepWiki [page](https://deepwiki.com/ExtensityAI/symbolicai/). There's a lot of interesting stuff in there. Last but not least, check out our [paper](https://arxiv.org/abs/2402.00854) that describes the framework in detail. If you like watching videos, we have a series of tutorials that you can find [here](https://extensityai.gitbook.io/symbolicai/tutorials/video_tutorials).
diff --git a/symbolicai-main/symbolicai-main/docs/source/SUMMARY.md b/symbolicai-main/symbolicai-main/docs/source/SUMMARY.md
deleted file mode 100644
index 7adc8e9c3f8f1b2e20d380ca4cf0086dab40051c..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/SUMMARY.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Summary
-
-* [Introduction](INTRODUCTION.md)
-* [Installation](INSTALLATION.md)
-* [Quick Start Guide](QUICKSTART.md)
-
-## Engines
-* [Neuro-Symbolic Engine](ENGINES/neurosymbolic_engine.md)
-* [CLIP Engine](ENGINES/clip_engine.md)
-* [Custom Engine](ENGINES/custom_engine.md)
-* [Drawing Engine](ENGINES/drawing_engine.md)
-* [File Engine](ENGINES/file_engine.md)
-* [Indexing Engine](ENGINES/indexing_engine.md)
-* [Local Engine](ENGINES/local_engine.md)
-* [OCR Engine](ENGINES/ocr_engine.md)
-* [Search Engine](ENGINES/search_engine.md)
-* [Speech Engine](ENGINES/speech_engine.md)
-* [Symbolic Engine](ENGINES/symbolic_engine.md)
-* [Webcrawler Engine](ENGINES/webcrawler_engine.md)
-
-## Features
-* [Contracts](FEATURES/contracts.md)
-* [Primitives](FEATURES/primitives.md)
-* [Operations](FEATURES/operations.md)
-* [Expressions](FEATURES/expressions.md)
-* [Error Handling](FEATURES/error_handling.md)
-* [Module Import](FEATURES/import.md)
-
-## Tutorials
-* [Chatbot Tutorial](TUTORIALS/chatbot.md)
-* [Handling Large Contexts](TUTORIALS/context.md)
-* [SQL Data Query](TUTORIALS/data_query.md)
-* [Video Tutorials](TUTORIALS/video_tutorials.md)
-
-## Tools
-* [Chatbot CLI](TOOLS/chatbot.md)
-* [Package Manager](TOOLS/packages.md)
-* [Shell](TOOLS/shell.md)
-
-## License
-* [License](LICENSE)
diff --git a/symbolicai-main/symbolicai-main/docs/source/TOOLS/chatbot.md b/symbolicai-main/symbolicai-main/docs/source/TOOLS/chatbot.md
deleted file mode 100644
index 1a45787704e0d809cb284640c022816cdfbbf7cb..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/TOOLS/chatbot.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Chatbot
-
----
-
-## ⚠️ Outdated or Deprecated Documentation ⚠️
-This documentation is outdated and may not reflect the current state of the SymbolicAI library. This page might be revived or deleted entirely as we continue our development. We recommend using more modern tools that infer the documentation from the code itself, such as [DeepWiki](https://deepwiki.com/ExtensityAI/symbolicai). This will ensure you have the most accurate and up-to-date information and give you a better picture of the current state of the library.
-
----
-
-You can engage in a basic conversation with `Symbia`, a chatbot that uses `SymbolicAI` to detect the content of your request and switch between different contextual modes to answer your questions. These modes include search engines, speech engines, and more. To start the chatbot, simply run:
-
-```bash
-$> symchat
-```
-
-This will launch a chatbot interface:
-
-```bash
-Symbia: Hi there! I'm Symbia, your virtual assistant. How may I help you?
-$>
-```
-
-To exit the conversation, type `exit`, `quit`, or press `Ctrl+C`.
-You can also load our chatbot `SymbiaChat` into a jupyter notebook and process step-wise requests.
diff --git a/symbolicai-main/symbolicai-main/docs/source/TOOLS/packages.md b/symbolicai-main/symbolicai-main/docs/source/TOOLS/packages.md
deleted file mode 100644
index b92b1f695c9d3ef4dadf0fc6413d8ea2c718727e..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/TOOLS/packages.md
+++ /dev/null
@@ -1,143 +0,0 @@
-# Packages
-
-## 📦 Package Manager
-
-We provide a package manager called `sympkg` that allows you to manage extensions from the command line. With `sympkg`, you can install, remove, list installed packages, or update a module.
-
-To use `sympkg`, follow the steps below:
-
-1. Open your terminal or PowerShell.
-2. Run the following command: `sympkg
-If we repeat this process, we now get a way of building up a hierarchical cluster with labels as entry points to allow information retrieval from our new data structure.
-To make manners more concrete, lets take a look at how to build up a news generator. Let us first start by importing some pre-defined string constants. These constants are used to define how the text is processed and how we desire the output to be formatted.
-
-## News Generator
-
-```python
-from examples.news import HEADER_STYLE_DESCRIPTION, HTML_TEMPLATE, HTML_STREAM_STYLE_DESCRIPTION
-```
-
-We sub-class the `Expression` class and define the `__init__` implementation. Similar to PyTorch we can define the graph in the `__init__` method and then call the `forward` method to compute the result. Afterwards, the data from the web URL is streamed through a `Sequence` of operations. This cleans the text from all the clutter such as `\n`, `\t`, etc. and then extracts the news from the text.
-The news are then filtered and re-composed. The resulting news texts are then clustered and the clusters are labeled. The labeled clusters are then recombined to return a rendered HTML format.
-
-```python
-class News(Expression):
- """The `News` class sub-classes `Expression` and provides a way to fetch and render news from a given url. It uses a `Stream` object to process the news data, with a sequence of `Clean`, `Translate`, `Outline`, and `Compose` expressions.
- It also defines a `Style` for the header, and a `Symbol` for the HTML templates.
- """
- def __init__(self, url: str, pattern: str, filters: List[Expression] = [], render: bool = False, **kwargs):
- """The `News` class constructor requires three arguments - `url`, `pattern` and `filters`.
- * `url` is a `str` containing the url to fetch the news from.
- * `pattern` is a `str` containing the name of the search key to be found on the web page.
- * `filters` is a `List[Expression]` containing any additional filters that should be applied to the news data.
- It defaults to an empty list if not specified.
- The `News` class also has an optional `render` argument which is a `bool` indicating whether the news should be rendered. It defaults to `False` if not specified.
- """
- super().__init__(**kwargs)
- self.url = url
- self.pattern = pattern
- self.render_ = render
- self.crawler = Interface('selenium')
- filters = filters if isinstance(filters, List) or isinstance(filters, tuple) else [filters]
- self.data_stream = Stream(Sequence(
- Clean(),
- Translate(),
- Outline(),
- *filters,
- Compose(f'Compose news paragraphs. Combine only facts that belong topic-wise together:\n'),
- ))
- self.header_style = Style(description=HEADER_STYLE_DESCRIPTION,
- libraries=['https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css',
- 'https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js',
- 'https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js'])
-
- self.html_template = Symbol(HTML_TEMPLATE)
- self.html_template_seq = Template()
- self.html_stream = Stream(
- Sequence(
- self.html_template_seq,
- Style(description=HTML_STREAM_STYLE_DESCRIPTION)
- )
- )
-
- def render(self, sym: Symbol) -> Symbol:
- """The `render` method takes a `Symbol` as an argument and returns a `Symbol` containing the rendered news.
- It first sets the `html_template_seq` property of the `html_stream` to the result of applying the `header_style` to the `html_template`.
- It then iterates through the `data_stream` and collects the strings resulting from each expression.
- These strings are combined into a single `Symbol` object which is then clustered.
- Finally, the `render` method applies the `html_template` to the clustered `Symbol` and returns the result.
- """
- tmp = self.header_style(self.html_template)
- self.html_template_seq.template_ = str(tmp)
- res = '\n'.join([str(s) for s in self.html_stream(sym)])
- res = Symbol(str(tmp).replace('{{placeholder}}', res))
- return res
-
- def forward(self) -> Symbol:
- """The `forward` method is used to fetch and process the news data.
- It first calls the `fetch` method with the `url` and `pattern` arguments.
- It then iterates through the `data_stream` and collects the `Symbol` object resulting from each expression.
- These `Symbol` objects are then combined into a single `Symbol` object which is then mapped.
- If `render` is `False`, the mapped `Symbol` is returned. Otherwise, the `render` method is called with the `Symbol` and the resulting `Symbol` is returned.
- """
- res = self.crawler(url=self.url, pattern=self.pattern)
- vals = []
- for news in self.data_stream(res):
- vals.append(str(news))
- res = Symbol(vals).cluster()
- sym = res.map()
- if not self.render_:
- return sym
- return self.render(sym)
-```
-
-Here you can try the news generator:
-```python
-# crawling the website and creating an own website based on its facts
-news = News(url='https://www.cnbc.com/cybersecurity/',
- pattern='cnbc',
- filters=ExcludeFilter('sentences about subscriptions, licensing, newsletter'),
- render=True)
-```
-
-Since the generative process will evaluate multiple expression, we can use the `Trace` and `Log` classes to keep track of what is happening.
-
-```python
-expr = Log(Trace(news))
-res = expr()
-os.makedirs('results', exist_ok=True)
-path = os.path.abspath('results/news.html')
-res.save(path, replace=False)
-```
-
-## Streaming over a PDF File
-
-Another example is to read in a PDF file and extract the text from it to create a website based on its content.
-
-```python
-from ..examples.paper import Paper
-```
-
-The process is fairly similar to the news generator. We first read in the PDF file and then stream the text through a sequence of operations. The text is then cleaned and the sentences are extracted. The sentences are then clustered and labeled. The labeled clusters are then recombined to return a rendered HTML format.
-
-```python
-paper = Paper(path='examples/paper.pdf')
-expr = Log(Trace(paper))
-res = expr(slice=(1, 1))
-os.makedirs('results', exist_ok=True)
-path = os.path.abspath('results/news.html')
-res.save(path, replace=False)
-```
diff --git a/symbolicai-main/symbolicai-main/docs/source/TUTORIALS/data_query.md b/symbolicai-main/symbolicai-main/docs/source/TUTORIALS/data_query.md
deleted file mode 100644
index 5e41bdb84c0a75d158f3a73fade963d201710207..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/TUTORIALS/data_query.md
+++ /dev/null
@@ -1,121 +0,0 @@
-# Querying Data with SQL
-
----
-
-## ⚠️ Outdated or Deprecated Documentation ⚠️
-This documentation is outdated and may not reflect the current state of the SymbolicAI library. This page might be revived or deleted entirely as we continue our development. We recommend using more modern tools that infer the documentation from the code itself, such as [DeepWiki](https://deepwiki.com/ExtensityAI/symbolicai). This will ensure you have the most accurate and up-to-date information and give you a better picture of the current state of the library.
-
----
-
-Click here for [interactive notebook](https://github.com/ExtensityAI/symbolicai/blob/main/notebooks/Queries.ipynb)
-
-```python
-import os
-import warnings
-warnings.filterwarnings('ignore')
-print(os.getcwd())
-from symai import *
-from IPython.display import display
-from examples.sql import SQL
-sql = SQL()
-```
-
-The `SQL` expression is defined and passes as a global context the syntax of the SQL language. The SQL expression is then used to generate queries based on the given context. We can then use the generated queries to get data from a database.
-The following query is sent to the neural computation engine and creates a query based on the given context:
-```python
-val = None
-def _fun(x):
- global val
- val = x
-Symbol._metadata.input_handler = _fun
-```
-
-```python
-Symbol('I have this class').translate('German')
-```
-
-```python
-q = sql('Select all users above the age of 30 from the Members table.');
-display(q) # SELECT * FROM Members WHERE age > 30
-```
-
-We can now try to further manipulate the result by asking the model to incorporate additional information, such as filtering to a specific time range:
-
-```python
-res = q << 'and limit the query to the last 10 minutes'
-display(res) # SELECT * FROM Members WHERE age > 30 AND timestamp > NOW() - INTERVAL 10 MINUTE
-```
-
-We can also try to remove unwanted fields from the generated query. Notice how the model tries to remove not only the given statement but attributes associated with them:
-
-```python
-res -= ' AND ...'
-display(res) # SELECT * FROM Members WHERE age > 30
-```
-
-And we can now even convert our query to other familiar domain specific languages, such as `SQL` or `ActiveRecord`:
-
-```python
-sql_res = res.convert("ActiveRecord")
-display(sql_res) # Members.where("age > ?", 30)
-```
-
-To wrap things up, we might want to go back full circle and ask the model to generate again the explanation based on the given query:
-
-```python
-answer_doc = res.query("What does this query do?")
-display(answer_doc)
-# The given SQL query retrieves all records from a table named `Members` where two conditions are met:
-# 1. The `age` column of a member record must be greater than 30.
-# 2. The `timestamp` column of a member record must be more recent than (or within)
-# the last 10 minutes from the current time. More specifically: - `SELECT *` indicates that it will
-# fetch all columns for the qualifying rows. - `FROM Members` specifies the table from which to fetch
-# the data. - `WHERE` introduces the conditions to filter which rows should be returned. - `age > 30`
-# filters the records to only include those where the age column value is greater than 30. - `AND`
-# combines multiple conditions, meaning a record must meet all the specified conditions to be included.
-# - `timestamp > NOW() - INTERVAL 10 MINUTE` checks for records with a timestamp within the last 10
-# minutes. `NOW()` is a function that returns the current datetime. `INTERVAL 10 MINUTE` specifies a
-# time interval of 10 minutes. By subtracting this interval from the current time, the query creates a
-# datetime value that is 10 minutes before now. The condition `timestamp >` selects all records where
-# the `timestamp` is more recent than that calculated time. This query would be useful for identifying
-# active, older members (above 30 years old) who have engaged with the system or performed an action
-# that updates their `timestamp` within the last 10 minutes.
-```
-
-Ask it in natural language to modify the query:
-
-```python
-answer = res.query("How can you limit the number of results to 30 for an SQL query?")
-display(answer)
-# To limit the number of results to 30 for an SQL query, you can use the `LIMIT` clause in your SQL
-# statement. The `LIMIT` clause restricts the number of rows returned by the query. Here's how you modify
-# your given SQL query to limit the results to 30: ```sql SELECT * FROM Members WHERE age > 30 LIMIT 30;```
-# This query will retrieve a maximum of 30 records from the 'Members' table where the 'age' column value is greater than 30.
-```
-
-Even translate the explanation to a different language on the fly:
-
-```python
-locale = Symbol(answer_doc).translate('German')
-display(locale)
-```
-
-Fixing the query on the fly if something goes wrong or the user quickly wants to adapt a query:
-
-```python
-sql.adapt(context="""Explanation: Never allow SELECT *, always use LIMIT to a max of x <= 50 entries, where x is the user specified limit.""")
-```
-
-```python
-res = sql('Select all users above the age of 30 from the Members table.')
-display(res) # SELECT * FROM Members WHERE age > 30 LIMIT 50
-```
-
-```python
-sql.clear()
-```
-
-```python
-res = sql('Select all users above the age of 30 from the Members table.')
-display(res) # SELECT * FROM Members WHERE age > 30
-```
diff --git a/symbolicai-main/symbolicai-main/docs/source/TUTORIALS/video_tutorials.md b/symbolicai-main/symbolicai-main/docs/source/TUTORIALS/video_tutorials.md
deleted file mode 100644
index 6676c015b98015e6b160e666b61da7a2da4eebda..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/docs/source/TUTORIALS/video_tutorials.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Video Tutorials
-
----
-
-## ⚠️ Outdated or Deprecated Documentation ⚠️
-This documentation is outdated and may not reflect the current state of the SymbolicAI library. This page might be revived or deleted entirely as we continue our development. We recommend using more modern tools that infer the documentation from the code itself, such as [DeepWiki](https://deepwiki.com/ExtensityAI/symbolicai). This will ensure you have the most accurate and up-to-date information and give you a better picture of the current state of the library.
-
----
-
-| Date | Title | Video |
-| ---- | ---- | ---- |
-| 2nd Dec. 2023 | Use ChatGPT and off-the-shelf RAG on Terminal/Command Prompt/Shell | [](https://youtu.be/RJ6i_b91nQE?si=jZR4LJRZQZVAm4MA) |
-| 21st Nov. 2023 | Virtual Persona from Documents, Multi-Agent Chat, Text-to-Speech to hear your Personas | [](https://www.youtube.com/watch?v=-o2315T9348) |
-| 1st Aug. 2023 | Automatic Retrieval Augmented Generation, Multimodal Inputs, User Packages | [](https://www.youtube.com/watch?v=0AqB6SEvRqo) |
-| 22nd July 2023 | ChatBot In-Depth Demonstration (Tool Use and Iterative Processing) | [](https://www.youtube.com/watch?v=R46SskmmrCE) |
-| 1st July 2023 | Symbols, Operations, Expressions, LLM-based functions! | [](https://www.youtube.com/watch?v=Ch9ygW62A34) |
-| 9th June 2023 | The future is neuro-symbolic: Expressiveness of ChatGPT and generalizability of symbols | [](https://www.youtube.com/watch?v=RW_7JdXvbRA) |
diff --git a/symbolicai-main/symbolicai-main/environment.yml b/symbolicai-main/symbolicai-main/environment.yml
deleted file mode 100644
index b5508008cad524b16fd334c611fa33284bad5609..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/environment.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-name: symai
-
-channels:
- - default
- - conda-forge
- - pytorch
- - nvidia
-
-dependencies:
- - python
- - setuptools
- - toml
- - natsort
- - numpy
- - tqdm
- - python-box
- - scikit-learn
- - pytorch
- - pytorch-cuda
- - torchvision
- - torchaudio
- - pyyaml
- - transformers
- - openai
- - pypdf
- - ipython
- - beautifulsoup4
- - selenium
- - rpyc
- - accelerate
- - sentencepiece
- - webdriver-manager
- - pandas
- - tika
- - pip
- - paramiko # For SSH protocol operations
- - docker-py # Docker SDK for Python
-
- - pip:
- - sympy
- - symbolicai[all]
diff --git a/symbolicai-main/symbolicai-main/examples/contracts.ipynb b/symbolicai-main/symbolicai-main/examples/contracts.ipynb
deleted file mode 100644
index ebf7db0a71509684c34664e02c3809385f066449..0000000000000000000000000000000000000000
--- a/symbolicai-main/symbolicai-main/examples/contracts.ipynb
+++ /dev/null
@@ -1,599 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "a72df661-ea3c-4cd8-9eab-ce9ca4c87ab8",
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/futurisold/miniconda3/envs/symai/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
- " from .autonotebook import tqdm as notebook_tqdm\n"
- ]
- }
- ],
- "source": [
- "# ──────────────────────────────────────────────────────────────\n",
- "# Standard library │\n",
- "# ──────────────────────────────────────────────────────────────\n",
- "from typing import List, Optional\n",
- "\n",
- "from pydantic import Field\n",
- "\n",
- "# ──────────────────────────────────────────────────────────────\n",
- "# SymbolicAI core │\n",
- "# ──────────────────────────────────────────────────────────────\n",
- "from symai import Expression # Base class for your LLM “operators”\n",
- "from symai.models import LLMDataModel # Thin Pydantic wrapper w/ LLM hints\n",
- "from symai.strategy import contract # The Design-by-Contract decorator"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "id": "817cc004-2782-4239-9ffd-27f634e00cee",
- "metadata": {},
- "outputs": [],
- "source": [
- "# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n",
- "# 1. Data models ▬\n",
- "# – clear structure + rich Field descriptions power ▬\n",
- "# validation, automatic prompt templating & remedies ▬\n",
- "# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n",
- "\n",
- "class Document(LLMDataModel):\n",
- " \"\"\"Represents an entire document in the tiny in-memory corpus.\"\"\"\n",
- " id: str = Field(description=\"Unique identifier of the document.\")\n",
- " content: str = Field(description=\"The full raw text of the document.\")\n",
- "\n",
- "\n",
- "class DocSnippet(LLMDataModel):\n",
- " \"\"\"\n",
- " Exact passage taken *verbatim* from a Document.\n",
- " We store the `doc_id` so the answer can cite its source.\n",
- " \"\"\"\n",
- " doc_id: str = Field(description=\"ID of the document the snippet comes from.\")\n",
- " snippet: str = Field(description=\"A short excerpt supporting the answer.\")\n",
- "\n",
- "\n",
- "class MultiDocQAInput(LLMDataModel):\n",
- " \"\"\"\n",
- " The *input* to the contract call:\n",
- " • the user’s natural-language question\n",
- " • the corpus it may answer from\n",
- " • a caller-specified upper bound on how many snippets can be cited\n",
- " \"\"\"\n",
- " query: str = Field(description=\"User question in plain English.\")\n",
- " documents: List[Document] = Field(description=\"Corpus to search for answers.\")\n",
- " max_snippets: Optional[int] = Field(\n",
- " default=3,\n",
- " ge=1,\n",
- " le=10,\n",
- " description=\"Max number of snippets the agent may cite (defaults to 3).\",\n",
- " )\n",
- "\n",
- "\n",
- "class IntermediateRetrieved(LLMDataModel):\n",
- " \"\"\"\n",
- " Returned by `act()`: lightweight retrieval result that will be fed to\n",
- " the LLM so it can see relevant sentences without scanning whole docs.\n",
- " \"\"\"\n",
- " query: str = Field(description=\"The original question from the user.\")\n",
- " top_docs: List[Document] = Field(description=\"Top-k most relevant documents.\")\n",
- " selected_sentences: List[str] = Field(\n",
- " description=\"Sentences deemed most relevant to the query.\"\n",
- " )\n",
- " target_snippet_count: int = Field(\n",
- " description=\"Upper bound on evidence snippets (copied from input).\"\n",
- " )\n",
- "\n",
- "\n",
- "class AnswerWithEvidence(LLMDataModel):\n",
- " \"\"\"\n",
- " Final object returned to the **caller** (and validated by `post`).\n",
- " \"\"\"\n",
- " answer: str = Field(description=\"Concise, stand-alone answer.\")\n",
- " evidence: List[DocSnippet] = Field(description=\"Cited supporting passages.\")\n",
- " coverage_score: float = Field(\n",
- " ge=0.0,\n",
- " le=1.0,\n",
- " description=(\n",
- " \"LLM-estimated fraction of answer that is directly supported by the \"\n",
- " \"evidence (0 = no support, 1 = fully supported).\"\n",
- " ),\n",
- " )\n",
- "\n",
- "# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n",
- "# 2. The contracted class ▬\n",
- "# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n",
- "@contract(\n",
- " # ── Remedies ─────────────────────────────────────────── #\n",
- " pre_remedy=True, # Try to fix bad inputs automatically\n",
- " post_remedy=True, # Try to fix bad LLM outputs automatically\n",
- " accumulate_errors=True, # Feed history of errors to each retry\n",
- " verbose=True, # Log internal steps (see `symai.strategy` logger)\n",
- " remedy_retry_params=dict(tries=3, delay=0.4, max_delay=4.0,\n",
- " jitter=0.15, backoff=1.8, graceful=False),\n",
- ")\n",
- "class MultiDocQAgent(Expression):\n",
- " \"\"\"\n",
- " High-level behaviour:\n",
- " 1. `pre` – sanity-check query & docs\n",
- " 2. `act` – *retrieve* relevant sentences, mutate state\n",
- " 3. LLM – generate AnswerWithEvidence (handled by SymbolicAI engine)\n",
- " 4. `post` – ensure answer & evidence meet semantic rules\n",
- " 5. `forward`\n",
- " • if contract succeeded → return validated LLM object\n",
- " • else → graceful fallback answer\n",
- " \"\"\"\n",
- "\n",
- " # ───────────────────────── init ───────────────────────── #\n",
- " def __init__(self, min_coverage: float = 0.55, *args, **kwargs):\n",
- " super().__init__(*args, **kwargs)\n",
- " self.min_coverage = min_coverage # threshold for `post`\n",
- " self.interaction_log: list[dict] = [] # keeps a history of queries\n",
- "\n",
- " # ───────────────────────── prompt ─────────────────────── #\n",
- " @property\n",
- " def prompt(self) -> str:\n",
- " \"\"\"\n",
- " A *static* description of what the LLM must do.\n",
- " Braces {{like_this}} will be replaced with fields from\n",
- " the object produced by `_validate_input`/`_act`.\n",
- " \"\"\"\n",
- " return (\n",
- " \"You are an expert research assistant.\\n\"\n",
- " \"Given a QUESTION and a set of RELEVANT_SENTENCES, write a concise \"\n",
- " \"answer. Cite every passage you use exactly as `(Doc ╭──────────────────────────────────────────────────── Prompt ─────────────────────────────────────────────────────╮\n", - "│ │\n", - "│ You are an expert research assistant. │\n", - "│ Given a QUESTION and a set of RELEVANT_SENTENCES, write a concise answer. Cite every passage you use exactly │\n", - "│ as `(Doc <ID>)`. Respond with a JSON object that fits the AnswerWithEvidence schema. │\n", - "│ │\n", - "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", - "\n" - ], - "text/plain": [ - "\u001b[36m╭─\u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m Prompt \u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230mYou are an expert research assistant.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230mGiven a QUESTION and a set of RELEVANT_SENTENCES, write a concise answer. Cite every passage you use exactly\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230mas `(Doc
╭────────────────────────────────────────── Input data model ───────────────────────────────────────────╮\n", - "│ │\n", - "│ [[Schema]] │\n", - "│ - \"query\" (string, required): The original question from the user. │\n", - "│ - \"top_docs\" (array of nested object (Document), required): Top-k most relevant documents. │\n", - "│ - Nested fields: │\n", - "│ - \"id\" (string, required): Unique identifier of the document. │\n", - "│ - \"content\" (string, required): The full raw text of the document. │\n", - "│ - \"selected_sentences\" (array of string, required): Sentences deemed most relevant to the query. │\n", - "│ - \"target_snippet_count\" (integer, required): Upper bound on evidence snippets (copied from input). │\n", - "│ │\n", - "│ [[Definitions]] │\n", - "│ - Document: │\n", - "│ - \"id\" (string, required): Unique identifier of the document. │\n", - "│ - \"content\" (string, required): The full raw text of the document. │\n", - "│ │\n", - "╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", - "\n" - ], - "text/plain": [ - "\u001b[36m╭─\u001b[0m\u001b[36m─────────────────────────────────────────\u001b[0m\u001b[36m Input data model \u001b[0m\u001b[36m──────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m[[Schema]]\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"query\" (string, required): The original question from the user.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"top_docs\" (array of nested object (Document), required): Top-k most relevant documents.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - Nested fields:\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"id\" (string, required): Unique identifier of the document.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"content\" (string, required): The full raw text of the document.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"selected_sentences\" (array of string, required): Sentences deemed most relevant to the query.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"target_snippet_count\" (integer, required): Upper bound on evidence snippets (copied from input).\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m[[Definitions]]\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- Document:\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"id\" (string, required): Unique identifier of the document.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"content\" (string, required): The full raw text of the document.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
╭─────────────────────────────────────────────── Output data model ───────────────────────────────────────────────╮\n", - "│ │\n", - "│ [[Schema]] │\n", - "│ - \"answer\" (string, required): Concise, stand-alone answer. │\n", - "│ - \"evidence\" (array of nested object (DocSnippet), required): Cited supporting passages. │\n", - "│ - Nested fields: │\n", - "│ - \"doc_id\" (string, required): ID of the document the snippet comes from. │\n", - "│ - \"snippet\" (string, required): A short excerpt supporting the answer. │\n", - "│ - \"coverage_score\" (number, required): LLM-estimated fraction of answer that is directly supported by the │\n", - "│ evidence (0 = no support, 1 = fully supported). │\n", - "│ │\n", - "│ [[Definitions]] │\n", - "│ - DocSnippet: │\n", - "│ - \"doc_id\" (string, required): ID of the document the snippet comes from. │\n", - "│ - \"snippet\" (string, required): A short excerpt supporting the answer. │\n", - "│ │\n", - "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", - "\n" - ], - "text/plain": [ - "\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────\u001b[0m\u001b[36m Output data model \u001b[0m\u001b[36m──────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m[[Schema]]\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"answer\" (string, required): Concise, stand-alone answer.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"evidence\" (array of nested object (DocSnippet), required): Cited supporting passages.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - Nested fields:\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"doc_id\" (string, required): ID of the document the snippet comes from.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"snippet\" (string, required): A short excerpt supporting the answer.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- \"coverage_score\" (number, required): LLM-estimated fraction of answer that is directly supported by the \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230mevidence (0 = no support, 1 = fully supported).\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m[[Definitions]]\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m- DocSnippet:\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"doc_id\" (string, required): ID of the document the snippet comes from.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m - \"snippet\" (string, required): A short excerpt supporting the answer.\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m\u001b[38;2;240;238;230m \u001b[0m\u001b[36m│\u001b[0m\n", - "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[32m2025-06-26 18:35:50.420\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36mforward\u001b[0m:\u001b[36m305\u001b[0m - \u001b[1mPrepared 3 remedy seeds for validation attempts…\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.422\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36mforward\u001b[0m:\u001b[36m310\u001b[0m - \u001b[1mAttempt 1/3: Attempting validation…\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.422\u001b[0m | \u001b[32m\u001b[1mSUCCESS \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36mforward\u001b[0m:\u001b[36m360\u001b[0m - \u001b[32m\u001b[1mValidation completed successfully!\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.425\u001b[0m | \u001b[32m\u001b[1mSUCCESS \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36m_validate_output\u001b[0m:\u001b[36m461\u001b[0m - \u001b[32m\u001b[1mType successfully created!\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.426\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36m_validate_output\u001b[0m:\u001b[36m464\u001b[0m - \u001b[1mValidating post-conditions with remedy...\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.427\u001b[0m | \u001b[32m\u001b[1mSUCCESS \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36m_validate_output\u001b[0m:\u001b[36m472\u001b[0m - \u001b[32m\u001b[1mPost-condition validation successful!\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.427\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36mwrapped_forward\u001b[0m:\u001b[36m596\u001b[0m - \u001b[1mExecuting original forward method...\u001b[0m\n", - "\u001b[32m2025-06-26 18:35:50.429\u001b[0m | \u001b[32m\u001b[1mSUCCESS \u001b[0m | \u001b[36msymai.strategy\u001b[0m:\u001b[36mwrapped_forward\u001b[0m:\u001b[36m624\u001b[0m - \u001b[32m\u001b[1mContract validation successful!\u001b[0m\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Answer:\n", - " Vector databases are useful for semantic search because they store embeddings of documents and allow for the quick retrieval of text that is semantically similar to a query vector, which enables high-quality semantic search (Doc B2).\n", - "\n", - "Coverage: 1.0\n", - "\n", - "Evidence:\n", - " • (Doc B2) Vector databases store embeddings of documents.\n", - " • (Doc B2) They let users quickly retrieve text that is semantically similar to a query vector, enabling high-quality semantic search.\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n" - ], - "text/plain": [ - "\n", - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
Contract Execution Summary (1 Forward Calls) \n", - "┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┓\n", - "┃ Operation ┃ Count ┃ Total Time (s) ┃ Mean (s) ┃ Std Dev (s) ┃ Min (s) ┃ Max (s) ┃ % of Total ┃\n", - "┡━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━┩\n", - "│ Input Validation │ 1 │ 0.000 │ 0.000 │ 0.000 │ 0.000 │ 0.000 │ 0.0% │\n", - "│ Act Execution │ 1 │ 0.000 │ 0.000 │ 0.000 │ 0.000 │ 0.000 │ 0.0% │\n", - "│ Output Validation │ 1 │ 3.392 │ 3.392 │ 0.000 │ 3.392 │ 3.392 │ 99.9% │\n", - "│ Forward Execution │ 1 │ 0.000 │ 0.000 │ 0.000 │ 0.000 │ 0.000 │ 0.0% │\n", - "│ Overhead │ 1 │ 0.005 │ 0.005 │ 0.000 │ 0.000 │ 0.000 │ 0.1% │\n", - "│ Total Execution │ N/A │ 3.397 │ 3.397 │ 0.000 │ 3.397 │ 3.397 │ 100.0% │\n", - "└───────────────────┴───────┴────────────────┴──────────┴─────────────┴─────────┴─────────┴────────────┘\n", - "\n" - ], - "text/plain": [ - "\u001b[3m Contract Execution Summary (1 Forward Calls) \u001b[0m\n", - "┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┓\n", - "┃\u001b[1m \u001b[0m\u001b[1mOperation \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mCount\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mTotal Time (s)\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mMean (s)\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mStd Dev (s)\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mMin (s)\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mMax (s)\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m% of Total\u001b[0m\u001b[1m \u001b[0m┃\n", - "┡━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━┩\n", - "│\u001b[36m \u001b[0m\u001b[36mInput Validation \u001b[0m\u001b[36m \u001b[0m│\u001b[34m \u001b[0m\u001b[34m 1\u001b[0m\u001b[34m \u001b[0m│\u001b[32m \u001b[0m\u001b[32m 0.000\u001b[0m\u001b[32m \u001b[0m│\u001b[33m \u001b[0m\u001b[33m 0.000\u001b[0m\u001b[33m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.000\u001b[0m\u001b[35m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 0.000\u001b[0m\u001b[31m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 0.000\u001b[0m\u001b[31m \u001b[0m│\u001b[36m \u001b[0m\u001b[36m 0.0%\u001b[0m\u001b[36m \u001b[0m│\n", - "│\u001b[36m \u001b[0m\u001b[36mAct Execution \u001b[0m\u001b[36m \u001b[0m│\u001b[34m \u001b[0m\u001b[34m 1\u001b[0m\u001b[34m \u001b[0m│\u001b[32m \u001b[0m\u001b[32m 0.000\u001b[0m\u001b[32m \u001b[0m│\u001b[33m \u001b[0m\u001b[33m 0.000\u001b[0m\u001b[33m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.000\u001b[0m\u001b[35m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 0.000\u001b[0m\u001b[31m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 0.000\u001b[0m\u001b[31m \u001b[0m│\u001b[36m \u001b[0m\u001b[36m 0.0%\u001b[0m\u001b[36m \u001b[0m│\n", - "│\u001b[36m \u001b[0m\u001b[36mOutput Validation\u001b[0m\u001b[36m \u001b[0m│\u001b[34m \u001b[0m\u001b[34m 1\u001b[0m\u001b[34m \u001b[0m│\u001b[32m \u001b[0m\u001b[32m 3.392\u001b[0m\u001b[32m \u001b[0m│\u001b[33m \u001b[0m\u001b[33m 3.392\u001b[0m\u001b[33m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.000\u001b[0m\u001b[35m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 3.392\u001b[0m\u001b[31m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 3.392\u001b[0m\u001b[31m \u001b[0m│\u001b[36m \u001b[0m\u001b[36m 99.9%\u001b[0m\u001b[36m \u001b[0m│\n", - "│\u001b[36m \u001b[0m\u001b[36mForward Execution\u001b[0m\u001b[36m \u001b[0m│\u001b[34m \u001b[0m\u001b[34m 1\u001b[0m\u001b[34m \u001b[0m│\u001b[32m \u001b[0m\u001b[32m 0.000\u001b[0m\u001b[32m \u001b[0m│\u001b[33m \u001b[0m\u001b[33m 0.000\u001b[0m\u001b[33m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.000\u001b[0m\u001b[35m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 0.000\u001b[0m\u001b[31m \u001b[0m│\u001b[31m \u001b[0m\u001b[31m 0.000\u001b[0m\u001b[31m \u001b[0m│\u001b[36m \u001b[0m\u001b[36m 0.0%\u001b[0m\u001b[36m \u001b[0m│\n", - "│\u001b[1;34m \u001b[0m\u001b[1;34mOverhead \u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 1\u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 0.005\u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 0.005\u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 0.000\u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 0.000\u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 0.000\u001b[0m\u001b[1;34m \u001b[0m│\u001b[1;34m \u001b[0m\u001b[1;34m 0.1%\u001b[0m\u001b[1;34m \u001b[0m│\n", - "│\u001b[1;35m \u001b[0m\u001b[1;35mTotal Execution \u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m N/A\u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m 3.397\u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m 3.397\u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m 0.000\u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m 3.397\u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m 3.397\u001b[0m\u001b[1;35m \u001b[0m│\u001b[1;35m \u001b[0m\u001b[1;35m 100.0%\u001b[0m\u001b[1;35m \u001b[0m│\n", - "└───────────────────┴───────┴────────────────┴──────────┴─────────────┴─────────┴─────────┴────────────┘\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n" - ], - "text/plain": [ - "\n", - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n", - "# 3. Mini-demo (only executed when you run the file directly)\n", - "# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n", - "# ── tiny “corpus” ─────────────────────────────────────── #\n", - "docs = [\n", - " Document(\n", - " id=\"A1\",\n", - " content=(\n", - " \"Symbolic AI combines formal logic with modern machine learning. \"\n", - " \"It allows transparent reasoning and explicit knowledge \"\n", - " \"representation while still benefiting from statistical models.\"\n", - " ),\n", - " ),\n", - " Document(\n", - " id=\"B2\",\n", - " content=(\n", - " \"Vector databases store embeddings of documents. They let users \"\n", - " \"quickly retrieve text that is semantically similar to a query \"\n", - " \"vector, enabling high-quality semantic search.\"\n", - " ),\n", - " ),\n", - " Document(\n", - " id=\"C3\",\n", - " content=(\n", - " \"Hybrid search merges sparse keyword techniques and dense vector \"\n", - " \"similarity, improving recall and precision, especially for \"\n", - " \"domain-specific collections.\"\n", - " ),\n", - " ),\n", - "]\n", - "\n", - "# ── create agent instance ─────────────────────────────── #\n", - "agent = MultiDocQAgent(min_coverage=0.6)\n", - "\n", - "# ── ask a question ────────────────────────────────────── #\n", - "question = \"Why are vector databases useful for semantic search?\"\n", - "result = agent(\n", - " input=MultiDocQAInput(\n", - " query=question,\n", - " documents=docs,\n", - " max_snippets=2, # caller sets stricter evidence limit\n", - " )\n", - ")\n", - "\n", - "# ── result ───────────────────────––––––––––––––––––––––– #\n", - "print(\"\\nAnswer:\\n\", result.answer)\n", - "print(\"\\nCoverage:\", result.coverage_score)\n", - "print(\"\\nEvidence:\")\n", - "for ev in result.evidence:\n", - " print(f\" • (Doc {ev.doc_id}) {ev.snippet}\")\n", - "\n", - "agent.contract_perf_stats();" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "65f28a95-1069-4581-8485-26d8215cdb7f", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/symbolicai-main/symbolicai-main/examples/primitives.ipynb b/symbolicai-main/symbolicai-main/examples/primitives.ipynb deleted file mode 100644 index 3575b547dc09395dd16cf5935fa19c57331a0d3d..0000000000000000000000000000000000000000 --- a/symbolicai-main/symbolicai-main/examples/primitives.ipynb +++ /dev/null @@ -1,2253 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Primitives Cheat-Sheet - SymbolicAI\n", - "\n", - "> _Primitives are the atoms of the SymbolicAI API – small, orthogonal operations that can be freely combined to express very rich behaviour. Every `Symbol` automatically inherits them, so there is no import-gymnastics required: just create a symbol and start hacking._\n", - "\n", - "This notebook gives you a **hands-on overview** of the most useful primitives that ship with `symai`. All examples are *runnable* – execute the cells and play with them!\n", - "\n", - "> ❗️**NOTE**❗️We will focus mostly on the **semantic** behaviour of the primitives, but you can also use them in **syntactic** mode, which is the default. Syntactic mode behaves like a normal Python value, unless otherwise specified." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Setup and Installation\n", - "\n", - "First, let's install and import the necessary dependencies:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/futurisold/miniconda3/envs/symai/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "SymbolicAI imported successfully!\n" - ] - } - ], - "source": [ - "# Install SymbolicAI if not already installed\n", - "# !pip install symbolicai\n", - "\n", - "# Import the main Symbol class\n", - "from symai import Symbol\n", - "\n", - "print(\"SymbolicAI imported successfully!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Syntactic vs. Semantic Symbols\n", - "\n", - "`Symbol` comes in **two flavours**:\n", - "\n", - "1. **Syntactic** – behaves like a normal Python value (string, list, int ‐ whatever you passed in).\n", - "2. **Semantic** – is wired to the neuro-symbolic engine and therefore *understands* meaning and context.\n", - "\n", - "### How to switch to the semantic view" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Semantic symbol: Cats are adorable\n" - ] - } - ], - "source": [ - "# 1. At creation time\n", - "s = Symbol(\"Cats are adorable\", semantic=True) # already semantic\n", - "print(f\"Semantic symbol: {s}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Syntactic startswith 'Cats': True\n", - "Semantic startswith 'animal': True\n", - "Semantic 'feline' in s: True\n", - "Split result: Cats\n" - ] - } - ], - "source": [ - "# 2. On demand with the .sem projection – the twin .syn flips you back\n", - "s = Symbol(\"Cats are adorable\") # default = syntactic\n", - "\n", - "print(f\"Syntactic startswith 'Cats': {s.startswith('Cats')}\")\n", - "print(f\"Semantic startswith 'animal': {s.sem.startswith('animal')}\")\n", - "print(f\"Semantic 'feline' in s: {'feline' in s.sem}\")\n", - "\n", - "# Syntactic operator split, syntactic index\n", - "result = (s / \" \")[0]\n", - "print(f\"Split result: {result}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. Inversion and Negation" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: I am standing on the shoulders of giants.\n", - "Inverted: The giants are standing on my shoulders.\n" - ] - } - ], - "source": [ - "# Inversion (~)\n", - "s = Symbol(\"I am standing on the shoulders of giants.\", semantic=True)\n", - "inverted = ~s\n", - "print(f\"Original: {s}\")\n", - "print(f\"Inverted: {inverted}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: I am happy.\n", - "Negated: I am not happy.\n" - ] - } - ], - "source": [ - "# Negation (-)\n", - "s = Symbol(\"I am happy.\", semantic=True)\n", - "negated = -s\n", - "print(f\"Original: {s}\")\n", - "print(f\"Negated: {negated}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3. Comparison Operations\n", - "\n", - "### Equality (`==`) and Inequality (`!=`)\n", - "\n", - "The equality and inequality operators showcase one of the most powerful aspects of semantic symbols: **conceptual equivalence** rather than just literal matching." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'Hello there!' == 'Hi there!': True\n", - "'Goodbye friend!' == 'See you later!': True\n" - ] - } - ], - "source": [ - "# Semantic greeting comparison - understands meaning\n", - "greeting_sem = Symbol('Hello there!', semantic=True)\n", - "greeting_variant = 'Hi there!'\n", - "\n", - "print(f\"'{greeting_sem}' == '{greeting_variant}': {greeting_sem == greeting_variant}\")\n", - "\n", - "# Semantic farewell comparison\n", - "farewell_sem = Symbol('Goodbye friend!', semantic=True)\n", - "farewell_variant = 'See you later!'\n", - "\n", - "print(f\"'{farewell_sem}' == '{farewell_variant}': {farewell_sem == farewell_variant}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1, 2, 3] == [3, 2, 1] (semantic): False\n" - ] - } - ], - "source": [ - "# Works with lists too - semantic understanding\n", - "list_sem = Symbol([1, 2, 3], semantic=True)\n", - "list_different = Symbol([3, 2, 1], semantic=True)\n", - "\n", - "print(f\"[1, 2, 3] == [3, 2, 1] (semantic): {list_sem == list_different}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Contextual greeting comparison: True\n", - "Politeness level comparison: False\n" - ] - } - ], - "source": [ - "# Advanced Contextual Equality - Custom Context Comparison\n", - "greeting = Symbol('Hello, good morning!')\n", - "similar_greeting = 'Hi there, good day!'\n", - "\n", - "# Compare with specific greeting context\n", - "result = greeting.equals(similar_greeting, context='greeting context')\n", - "print(f\"Contextual greeting comparison: {result}\")\n", - "\n", - "# Compare with different contexts for nuanced evaluation\n", - "formal_greeting = Symbol('Good morning, sir.')\n", - "casual_greeting = 'Hey, what\\'s up?'\n", - "\n", - "# Context-aware politeness comparison\n", - "politeness_comparison = formal_greeting.equals(casual_greeting, context='politeness level')\n", - "print(f\"Politeness level comparison: {politeness_comparison}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4. Membership Operations\n", - "\n", - "### The `in` Operator - Semantic Containment" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'fruit' in 'apple banana cherry': True\n", - "'fruit' in ['apple', 'banana', 'cherry']: True\n" - ] - } - ], - "source": [ - "# Semantic string containment - understands concepts\n", - "str_sem = Symbol('apple banana cherry', semantic=True)\n", - "concept_search = 'fruit'\n", - "\n", - "print(f\"'{concept_search}' in '{str_sem}': {concept_search in str_sem}\")\n", - "\n", - "# Semantic list containment - conceptual understanding\n", - "list_sem = Symbol(['apple', 'banana', 'cherry'], semantic=True)\n", - "print(f\"'{concept_search}' in {list_sem.value}: {concept_search in list_sem}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'pet' in 'cat dog bird fish': True\n", - "'mammal' in 'cat dog bird fish': True\n", - "'vehicle' in 'cat dog bird fish': False\n" - ] - } - ], - "source": [ - "# More examples of semantic containment\n", - "animals_sem = Symbol('cat dog bird fish', semantic=True)\n", - "print(f\"'pet' in '{animals_sem}': {'pet' in animals_sem}\")\n", - "print(f\"'mammal' in '{animals_sem}': {'mammal' in animals_sem}\")\n", - "print(f\"'vehicle' in '{animals_sem}': {'vehicle' in animals_sem}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "text.contains('car'): True\n", - "mixed_data.contains('two'): True\n", - "mixed_data.contains(True): True\n" - ] - } - ], - "source": [ - "# Enhanced Semantic Containment - Multi-Type Support\n", - "text = Symbol('The vehicle moved quickly down the road')\n", - "print(f\"text.contains('car'): {text.contains('car')}\")\n", - "\n", - "# Containment with mixed data types\n", - "mixed_data = Symbol([1, 'two', 3.0, True])\n", - "print(f\"mixed_data.contains('two'): {mixed_data.contains('two')}\")\n", - "print(f\"mixed_data.contains(True): {mixed_data.contains(True)}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 5. Ordering and Comparison Operations\n", - "\n", - "### Greater Than (`>`) and Less Than (`<`) and Greater or Equal (`>=`) and Less or Equal (`<=`)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'enormous' > 'tiny': True\n", - "'cat' < 'dog': True\n" - ] - } - ], - "source": [ - "# Semantic size comparison - understands relative magnitude\n", - "large_sem = Symbol('enormous', semantic=True)\n", - "small_sem = Symbol('tiny', semantic=True)\n", - "\n", - "print(f\"'{large_sem}' > '{small_sem}': {large_sem > small_sem}\")\n", - "\n", - "# Semantic animal size comparison\n", - "cat_sem = Symbol('cat', semantic=True)\n", - "dog_sem = Symbol('dog', semantic=True)\n", - "\n", - "print(f\"'{cat_sem}' < '{dog_sem}': {cat_sem < dog_sem}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'freezing' < 'scorching': True\n", - "'fifty' > 45: True\n" - ] - } - ], - "source": [ - "# Temperature comparisons - semantic understanding of hot/cold\n", - "cold_sem = Symbol('freezing', semantic=True)\n", - "hot_sem = Symbol('scorching', semantic=True)\n", - "\n", - "print(f\"'{cold_sem}' < '{hot_sem}': {cold_sem < hot_sem}\")\n", - "\n", - "# Semantic number understanding\n", - "word_number = Symbol('fifty', semantic=True)\n", - "regular_number = 45\n", - "\n", - "print(f\"'{word_number}' > {regular_number}: {word_number > regular_number}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 6. Shift Operations - Semantic Inclusion\n", - "\n", - "### Left Shift (`<<`) and Right Shift (`>>`)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'data stream' << 'left': left data stream\n", - "'information flow' >> 'right': information right flow\n" - ] - } - ], - "source": [ - "# Left shift - prepend/include at the beginning\n", - "data_stream = Symbol('data stream', semantic=True)\n", - "left_direction = Symbol('left')\n", - "result = data_stream << left_direction\n", - "print(f\"'{data_stream}' << '{left_direction}': {result}\")\n", - "\n", - "# Right shift - append/include at the end\n", - "info_flow = Symbol('information flow', semantic=True)\n", - "right_direction = Symbol('right')\n", - "result = info_flow >> right_direction\n", - "print(f\"'{info_flow}' >> '{right_direction}': {result}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'high priority task' << 'urgent': urgent high priority task\n", - "'data processing' >> 'downstream': downstream data processing\n" - ] - } - ], - "source": [ - "# Priority and urgency - prepend urgent to task\n", - "priority_task = Symbol('high priority task', semantic=True)\n", - "urgency = Symbol('urgent')\n", - "result = priority_task << urgency\n", - "print(f\"'{priority_task}' << '{urgency}': {result}\")\n", - "\n", - "# Process flow - append downstream to processing\n", - "data_process = Symbol('data processing', semantic=True)\n", - "downstream = Symbol('downstream')\n", - "result = data_process >> downstream\n", - "print(f\"'{data_process}' >> '{downstream}': {result}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 7. Bitwise and Logical Operations\n", - "\n", - "### Bitwise AND (`&`) - Intersection and Logical Conjunction" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Logical inference: Therefore, it is Sunday.\n", - "Combined evidence: Therefore, there is strong evidence linking the suspect to the scene.\n" - ] - } - ], - "source": [ - "# Semantic logical conjunction - combining facts and rules\n", - "horn_rule = Symbol('The horn only sounds on Sundays.', semantic=True)\n", - "observation = Symbol('I hear the horn.')\n", - "conclusion = horn_rule & observation\n", - "print(f\"Logical inference: {conclusion}\")\n", - "\n", - "# Combining evidence\n", - "evidence1 = Symbol('The suspect was seen at the scene.', semantic=True)\n", - "evidence2 = Symbol('His fingerprints were found.')\n", - "combined_evidence = evidence1 & evidence2\n", - "print(f\"Combined evidence: {combined_evidence}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Bitwise OR (`|`) - Union and Logical Disjunction" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Multiple possibilities: Either it might rain today, or it could be sunny, or both.\n", - "Alternative outcomes: The meeting could be postponed or canceled, perhaps both.\n" - ] - } - ], - "source": [ - "# Semantic logical disjunction - alternative possibilities\n", - "option1 = Symbol('It might rain today.', semantic=True)\n", - "option2 = Symbol('It could be sunny.')\n", - "possibilities = option1 | option2\n", - "print(f\"Multiple possibilities: {possibilities}\")\n", - "\n", - "# Alternative scenarios\n", - "scenario1 = Symbol('The meeting could be postponed.', semantic=True)\n", - "scenario2 = Symbol('The meeting might be canceled.')\n", - "alternatives = scenario1 | scenario2\n", - "print(f\"Alternative outcomes: {alternatives}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Bitwise XOR (`^`) - Exclusive OR" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Exclusive alternative: It will either rain today or be sunny, but not both.\n", - "Mutually exclusive states: Either the door is open or the door is closed, but not both.\n" - ] - } - ], - "source": [ - "# Semantic exclusive choice - either/or scenarios\n", - "exclusive1 = Symbol('Either it will rain today.', semantic=True)\n", - "exclusive2 = Symbol('Or it will be sunny.')\n", - "either_or = exclusive1 ^ exclusive2\n", - "print(f\"Exclusive alternative: {either_or}\")\n", - "\n", - "# Contradictory statements\n", - "statement1 = Symbol('The door is open.', semantic=True)\n", - "statement2 = Symbol('The door is closed.')\n", - "contradiction = statement1 ^ statement2\n", - "print(f\"Mutually exclusive states: {contradiction}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 8. Arithmetic Operations\n", - "\n", - "### Addition (`+`) and Subtraction (`-`)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Text transformation: Hello my friend\n" - ] - } - ], - "source": [ - "enemy_text = Symbol('Hello my enemy', semantic=True)\n", - "result = enemy_text - 'enemy' + 'friend'\n", - "print(f\"Text transformation: {result}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Manipulation (`@`, `/`)" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Concatenated string: Hello my friend\n", - "Split string: ['Hello', 'my', 'friend']\n" - ] - } - ], - "source": [ - "# String concatenation with @\n", - "string = Symbol('Hello my ') @ 'friend'\n", - "print(f\"Concatenated string: {string}\")\n", - "\n", - "# String splitting with /\n", - "split_string = string / ' '\n", - "print(f\"Split string: {split_string}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 9. Indexing and Slicing Operations" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name query result: Alice\n", - "Identity query result: {'name': 'Alice', 'age': '30', 'city': 'NYC'}\n" - ] - } - ], - "source": [ - "# Semantic dictionary access - finds conceptually related keys\n", - "sym_person = Symbol({'name': 'Alice', 'age': 30, 'city': 'NYC'}, semantic=True)\n", - "name_result = sym_person['Return any names']\n", - "print(f\"Name query result: {name_result}\")\n", - "\n", - "identity_result = sym_person['identity']\n", - "print(f\"Identity query result: {identity_result}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Domestic animal result: ['cat', 'dog', 'bird', 'fish']\n", - "Primary color result: ['#FF0000', '#00FF00', '#0000FF']\n" - ] - } - ], - "source": [ - "# Semantic list access - finds conceptually matching items\n", - "sym_animals = Symbol(['cat', 'dog', 'bird', 'fish'], semantic=True)\n", - "pet_result = sym_animals['domestic animal']\n", - "print(f\"Domestic animal result: {pet_result}\")\n", - "\n", - "# Color matching example\n", - "sym_colors = Symbol({'red': '#FF0000', 'green': '#00FF00', 'blue': '#0000FF'}, semantic=True)\n", - "primary_color = sym_colors['primary color']\n", - "print(f\"Primary color result: {primary_color}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Modified weather data: {'temperature': 25, 'humidity': 60, 'pressure': 1013}\n" - ] - } - ], - "source": [ - "# Semantic dictionary modification - maps to conceptually similar keys\n", - "sym_weather = Symbol({'temperature': 20, 'humidity': 60, 'pressure': 1013}, semantic=True)\n", - "sym_weather['Change the temperature'] = 25\n", - "print(f\"Modified weather data: {sym_weather.value}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 10. Type Checking Operations\n", - "\n", - "### Semantic Type Validation (`isinstanceof`)" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Is 42 a number? True\n", - "Is 42 a string? False\n", - "Is list a list? False\n", - "Is True a logical value? True\n" - ] - } - ], - "source": [ - "# Basic semantic type checking\n", - "number_sym = Symbol(42)\n", - "print(f\"Is 42 a number? {number_sym.isinstanceof('number')}\")\n", - "print(f\"Is 42 a string? {number_sym.isinstanceof('string')}\")\n", - "\n", - "# Collection type checking\n", - "list_sym = Symbol(['apple', 'banana', 'cherry'])\n", - "print(f\"Is list a list? {list_sym.isinstanceof('list')}\")\n", - "\n", - "# Boolean/logical type checking\n", - "bool_sym = Symbol(True)\n", - "print(f\"Is True a logical value? {bool_sym.isinstanceof('logical value')}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Is dict person data? True\n", - "Is user_info a person? True\n" - ] - } - ], - "source": [ - "# Complex semantic type recognition\n", - "person_data = Symbol({'name': 'John', 'age': 30})\n", - "print(f\"Is dict person data? {person_data.isinstanceof('person data')}\")\n", - "\n", - "# More natural language type queries\n", - "user_info = Symbol({'name': 'Alice', 'age': 25, 'city': 'Wonderland'})\n", - "print(f\"Is user_info a person? {user_info.isinstanceof('person')}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 11. Basic Symbolic Manipulations\n", - "\n", - "### Expression Interpretation (`interpret`)" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Analogy result: Sun\n", - "Integration result: x³ + x² - 5x + C\n" - ] - } - ], - "source": [ - "# Symbolic reasoning and analogies\n", - "analogy = Symbol('gravity : Earth :: radiation : ?')\n", - "result = analogy.interpret()\n", - "print(f\"Analogy result: {result}\")\n", - "\n", - "# Mathematical expression interpretation\n", - "math_expr = Symbol(\"∫(3x² + 2x - 5)dx\")\n", - "solution = math_expr.interpret()\n", - "print(f\"Integration result: {solution}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x = -5: 'negative'.\n", - "x = 0: x is 'negative' if x < 0, 'zero' if x = 0, and 'positive' if x > 0.\n", - "x = 10: positive\n" - ] - } - ], - "source": [ - "# Conditional interpretation with different inputs\n", - "conditional = Symbol(\"If x < 0 then 'negative' else if x == 0 then 'zero' else 'positive'\")\n", - "\n", - "# Test with different values\n", - "print(f\"x = -5: {conditional.interpret('x = -5')}\")\n", - "print(f\"x = 0: {conditional.interpret('x = 0')}\")\n", - "print(f\"x = 10: {conditional.interpret('x = 10')}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "System solution: x = 7, y = 3\n", - "Philosophical insight: What caused the universe's initial event?\n" - ] - } - ], - "source": [ - "# System solving and constraints\n", - "system = Symbol(\"Find values for x and y where: x + y = 10, x - y = 4\")\n", - "solution = system.interpret()\n", - "print(f\"System solution: {solution}\")\n", - "\n", - "# Logical reasoning with philosophical questions\n", - "reasoning = Symbol('If every event has a cause, and the universe began with an event, what philosophical question arises?')\n", - "philosophical_insight = reasoning.interpret()\n", - "print(f\"Philosophical insight: {philosophical_insight}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Step 1: E² = (pc)² + (mc²)²\n", - "Step 2: E ≈ pc\n", - "Step 3: E² = (pc)² + (m₀c²)²\n", - "All accumulated results: 3 steps\n" - ] - } - ], - "source": [ - "# Accumulative interpretation\n", - "sym_accumulate = Symbol('Relativistic electron formula')\n", - "result1 = sym_accumulate.interpret(accumulate=True)\n", - "print(f\"Step 1: {result1}\")\n", - "\n", - "result2 = result1.interpret('Assume the momentum to be extremely large', accumulate=True)\n", - "print(f\"Step 2: {result2}\")\n", - "\n", - "result3 = result2.interpret('Expand the formula to account for both mass and momentum', accumulate=True)\n", - "print(f\"Step 3: {result3}\")\n", - "\n", - "# Get all accumulated results\n", - "all_results = sym_accumulate.get_results()\n", - "print(f\"All accumulated results: {len(all_results)} steps\")\n", - "\n", - "# Clear results\n", - "sym_accumulate.clear_results()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 12. Data Processing and Manipulation Operations\n", - "\n", - "### Text Cleaning and Normalization (`clean`)" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: This text has multiple spaces and\n", - "\n", - "extra newlines.\t\tAnd tabs.\n", - "Cleaned: This text has multiple spaces and extra newlines. And tabs.\n" - ] - } - ], - "source": [ - "sym_dirty = Symbol(\"This text has multiple spaces and\\n\\nextra newlines.\\t\\tAnd tabs.\")\n", - "cleaned = sym_dirty.clean()\n", - "print(f\"Original: {sym_dirty.value}\")\n", - "print(f\"Cleaned: {cleaned}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Content Summarization (`summarize`)" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original length: 322\n", - "Summarized:\n", - " Python is a high-level, interpreted programming language characterized by its dynamic semantics, built-in data structures, dynamic typing, and dynamic binding. These features make it highly suitable for Rapid Application Development and for use as a scripting or \"glue\" language to connect existing components.\n", - "Context-focused summary:\n", - " Python is an interpreted, high-level programming language known for its dynamic semantics. Its appeal for Rapid Application Development and its utility as a scripting or \"glue\" language stem from its high-level built-in data structures, dynamic typing, and dynamic binding.\n" - ] - } - ], - "source": [ - "sym_long = Symbol(\"Python is a high-level, interpreted programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.\")\n", - "summarized = sym_long.summarize()\n", - "print(f\"Original length: {len(sym_long.value)}\")\n", - "print(f\"Summarized:\\n {summarized}\")\n", - "\n", - "# With context for focused summarization\n", - "context_summarized = sym_long.summarize(context=\"Focus on Python's use in data science\")\n", - "print(f\"Context-focused summary:\\n {context_summarized}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Content Outlining (`outline`)" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Outline:\n", - " ['- Machine learning: subset of AI enabling computers to learn and improve from experience without explicit programming', '- Supervised learning: uses labeled training data to learn mapping function', '- Classification: predicts discrete class labels', '- Regression: predicts continuous numerical values', '- Unsupervised learning: finds hidden patterns in data without labeled examples']\n" - ] - } - ], - "source": [ - "sym_complex = Symbol(\"\"\"\n", - "# Introduction to Machine Learning\n", - "Machine learning is a subset of artificial intelligence that enables computers to learn and improve from experience without being explicitly programmed.\n", - "\n", - "## Supervised Learning\n", - "Supervised learning uses labeled training data to learn a mapping function.\n", - "\n", - "### Classification\n", - "Classification predicts discrete class labels.\n", - "\n", - "### Regression\n", - "Regression predicts continuous numerical values.\n", - "\n", - "## Unsupervised Learning\n", - "Unsupervised learning finds hidden patterns in data without labeled examples.\n", - "\"\"\")\n", - "\n", - "outlined = sym_complex.outline()\n", - "print(f\"Outline:\\n {outlined}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Content Filtering (`filter`)" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Exclude cats: Dogs are loyal pets. Hamsters are small pets.\n", - "Include only dogs: Dogs are loyal pets.\n" - ] - } - ], - "source": [ - "sym_mixed = Symbol(\"Dogs are loyal pets. Cats are independent pets. Hamsters are small pets.\")\n", - "\n", - "# Exclude content matching criteria (default behavior)\n", - "filtered_ex = sym_mixed.filter(criteria=\"Cats\")\n", - "print(f\"Exclude cats: {filtered_ex}\")\n", - "\n", - "# Include only content matching criteria\n", - "filtered_in = sym_mixed.filter(criteria=\"Dogs\", include=True)\n", - "print(f\"Include only dogs: {filtered_in}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Content Modification (`modify`)" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: The quick brown fox jumps over the lazy dog.\n", - "Modified: The fast brown fox jumps over the sleeping dog.\n" - ] - } - ], - "source": [ - "sym_original = Symbol(\"The quick brown fox jumps over the lazy dog.\")\n", - "changes = \"Change 'quick' to 'fast' and 'lazy' to 'sleeping'\"\n", - "modified = sym_original.modify(changes=changes)\n", - "print(f\"Original: {sym_original}\")\n", - "print(f\"Modified: {modified}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Text Replacement (`replace`)" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: Python is a programming language. Python is easy to learn.\n", - "Replaced: JavaScript is a programming language. JavaScript is easy to learn.\n" - ] - } - ], - "source": [ - "sym_replace = Symbol(\"Python is a programming language. Python is easy to learn.\")\n", - "replaced = sym_replace.replace(\"Python\", \"JavaScript\")\n", - "print(f\"Original: {sym_replace}\")\n", - "print(f\"Replaced: {replaced}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Content Removal (`remove`)" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: This text contains [unnecessary information] that should be removed.\n", - "Removed: This text contains that should be removed.\n" - ] - } - ], - "source": [ - "sym_extra = Symbol(\"This text contains [unnecessary information] that should be removed.\")\n", - "removed = sym_extra.remove(\"[unnecessary information] \")\n", - "print(f\"Original: {sym_extra}\")\n", - "print(f\"Removed: {removed}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Content Addition (`include`, `combine`)" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Included: This is the main content. This is additional information.\n", - "Combined: This is the main content. Second part of the content.\n" - ] - } - ], - "source": [ - "sym_base = Symbol(\"This is the main content.\")\n", - "\n", - "# Include additional information\n", - "included = sym_base.include(\"This is additional information.\")\n", - "print(f\"Included: {included}\")\n", - "\n", - "# Combine with other content\n", - "combined = sym_base.combine(\"Second part of the content.\")\n", - "print(f\"Combined: {combined}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Semantic Mapping (`map`)" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Vowel transformation: h2ll4 w4rld\n", - "Case transformation: prOgrAmmIng\n" - ] - } - ], - "source": [ - "# Transform characters in strings\n", - "text = Symbol(\"hello world\")\n", - "result = text.map('convert vowels to numbers: a=1, e=2, i=3, o=4, u=5')\n", - "print(f\"Vowel transformation: {result}\")\n", - "\n", - "# Transform case selectively\n", - "caps_text = Symbol(\"PROGRAMMING\")\n", - "result = caps_text.map('make consonants lowercase, keep vowels uppercase')\n", - "print(f\"Case transformation: {result}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Fruit to vegetable transformation: ['carrot', 'broccoli', 'spinach', 'cat', 'dog']\n", - "Dictionary transformation: `{'item1': 'carrot', 'item2': 'broccoli', 'item3': 'cat'}`\n" - ] - } - ], - "source": [ - "# Transform fruits to vegetables, leave animals unchanged\n", - "mixed_list = Symbol(['apple', 'banana', 'cherry', 'cat', 'dog'])\n", - "result = mixed_list.map('convert all fruits to vegetables')\n", - "print(f\"Fruit to vegetable transformation: {result}\")\n", - "\n", - "# Work with dictionaries - transforms values, preserves keys\n", - "fruit_dict = Symbol({'item1': 'apple', 'item2': 'banana', 'item3': 'cat'})\n", - "result = fruit_dict.map('convert fruits to vegetables')\n", - "print(f\"Dictionary transformation: {result}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Emotions to weather: ['sunny', 'rainy', 'stormy']\n", - "Type preserved:
| Name | \n", - "Age | \n", - "Department | \n", - "
|---|---|---|
| Alice | \n", - "28 | \n", - "Engineering | \n", - "
| Bob | \n", - "35 | \n", - "Marketing | \n", - "