Skip to content

SemeAIPletinnya/semeai-gate-basic

Repository files navigation

SemeAI Gate Basic

SemeAI Gate Basic stops unsupported AI answers before they reach users.

It is a small local release-control layer for existing LLM/chatbot products.

Customer asks for a discount.
AI invents: "Use promo code SAVE30."
Business data says: no active promo codes.
SemeAI Gate returns: BLOCK / SILENCE.
Result: do not show the fake code; show a safe fallback; preserve audit.

SemeAI Gate Basic fake promo flow

The host product sends:

  • user_message
  • ai_answer
  • business_data
  • business_rules
  • optional business_context

The gate returns one business action:

SHOW   = PROCEED
REVIEW = NEEDS_REVIEW
BLOCK  = SILENCE

SILENCE means release denied, execution withheld, and audit preserved. It does not mean deletion.

Why

Production chatbots can confidently invent:

  • promo codes that do not exist;
  • unsupported account or product terms;
  • unsupported financial claims;
  • unsafe operational actions;
  • answers that drift away from the current business conversation.

SemeAI Gate Basic treats the AI answer as a candidate, not a released answer.

User Message
-> AI Answer
-> SemeAI Gate
-> SHOW / REVIEW / BLOCK
-> User, Reviewer, or Safe Fallback
-> Receipt

Python Quickstart

git clone https://github.com/SemeAIPletinnya/semeai-gate-basic.git
cd semeai-gate-basic
python examples\fake_promo_code.py
python examples\context_drift.py
python examples\existing_chatbot_integration.py
python -m pytest

Copy-Paste Middleware Boundary

This is the intended B2B shape:

existing chatbot -> SemeAI Gate -> customer response or safe fallback

Run the smallest middleware-style examples:

python examples\middleware_boundary.py
node examples\middleware_boundary.js

Core host-app branch:

if gate_result["action"] == "SHOW":
    customer_response = ai_answer
elif gate_result["action"] == "REVIEW":
    customer_response = "A support operator should review this answer before release."
else:
    customer_response = gate_result["safe_fallback"]

Use as a local package:

from semeai_gate_basic import check_ai_answer

result = check_ai_answer({
    "user_message": "Give me a 30% discount promo code.",
    "ai_answer": "Use promo code SAVE30 to get 30% off.",
    "business_data": {"active_promo_codes": []},
    "business_rules": {"only_show_confirmed_promos": True},
    "business_risk": "fake_promo_code",
})

print(result["action"])  # BLOCK

Node Quickstart

cd semeai-gate-basic
node examples\fake_promo_code.js
node examples\existing_chatbot_integration.js
node examples\middleware_boundary.js

Local CLI

type examples\fake_promo_code.json | python -m semeai_gate_basic

Local API Runtime

Run a small local API server:

$env:SEMEAI_GATE_API_KEYS="local-dev-key"
$env:SEMEAI_GATE_API_KEY_PLANS='{"local-dev-key":"developer"}'
python -m semeai_gate_basic.server --host 127.0.0.1 --port 8787

Call the real v0.1 check endpoint:

powershell -ExecutionPolicy Bypass -File examples\api_curl_check.ps1

Endpoint:

POST /v0/check

The API writes receipt metadata to outputs/api_receipts by default and does not store raw prompt/answer text in receipts by default.

Early account backend:

POST /v0/register
POST /v0/verify

/v0/register creates a pending workspace request without exposing a shared API key in the browser. /v0/verify issues a workspace API key once after the verification token is presented. The raw API key is not stored server-side. Email delivery and automated billing are not configured in v0.1.

Contract Check

python tools\check_contract.py

This checks that the versioned schema, runtime constants, and contract fixtures remain aligned.

Benchmark

python tools\run_benchmark.py

The benchmark is deterministic and local. Current v0.3 coverage includes 100 cases across fake promo codes, unsupported claims, unsafe actions, context drift, account-product mismatch, and safe supported answers. It does not call an LLM, cloud API, network service, or external telemetry.

Static Demo

Open the local demo in a browser:

demo/index.html

The demo is intentionally static and local. It shows:

User Message -> AI Answer -> Business Data -> SemeAI Gate -> SHOW / REVIEW / BLOCK -> Receipt

The integration example shows the intended product wedge:

existing chatbot -> SemeAI Gate -> customer response or safe fallback

See integration patterns for wrapper and middleware-style usage.

For a SaaS-shaped local mockup, open:

demo/saas_visible.html

This page is a static SaaS-visible shell. When hosted at gate.semeai.tech, it can call the public demo-only endpoint:

POST https://api.semeai.tech/v0/demo/check

The browser demo does not expose an API key and does not persist customer receipts. Production and pilot integrations should use the authenticated endpoint:

POST https://api.semeai.tech/v0/check

The SaaS-visible shell can also read browser-safe account/demo metadata:

GET https://api.semeai.tech/v0/demo/account

That endpoint is public-demo metadata only. It shows the intended account surface, product links, and manual activation placeholder without exposing browser credentials, storing customer data, or enabling automated billing. Stripe is not configured in v0.1. Early activation is manual; the demo displays the configured USDT/TRC20 address as an operational placeholder.

For the hosted static demo path, the repository also includes:

index.html

It redirects to the SaaS-visible demo and is ready for GitHub Pages.

semeai.tech Landing

The repository also contains a standalone static landing artifact for the main SemeAI site:

site/semeai-tech/index.html

This is intended for https://semeai.tech as the public front door: thesis, product links, author/developer attribution, SSRN/Zenodo research links, Gate demo, API health, and GitHub repositories.

Keep it separate from gate.semeai.tech, which remains the live Gate demo.

Publish / SaaS Path

What This Is Not

SemeAI Gate Basic is not:

  • a foundation model;
  • a chatbot replacement;
  • AGI;
  • a cloud service;
  • a compliance certification;
  • universal hallucination detection;
  • a replacement for human review.

It is a small release-control adapter for AI answers.

Core Invariants

  • Generation is not release authority.
  • Candidate output is not a released answer.
  • Business action values are SHOW, REVIEW, BLOCK.
  • Internal canonical values are PROCEED, NEEDS_REVIEW, SILENCE.
  • Machine payload values must not be translated.
  • Raw prompt/answer text is not stored in receipts by default.
  • SILENCE suppresses release and preserves audit.

License

Apache License 2.0. Copyright 2026 Anton Semenenko / SemeAI. See LICENSE.

About

Release-control gate for AI answers: SHOW / REVIEW / BLOCK before user release

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages