From 0e937a5ce58b10bf2df55375a8250e365e308dd5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 03:10:38 +0000 Subject: [PATCH 1/4] Initial plan From ee8ce7a9763646d80aab8ff12d07219ad3286c90 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 03:14:52 +0000 Subject: [PATCH 2/4] docs: add GitHub Pages documentation site Co-authored-by: Ki-Seki <60967965+Ki-Seki@users.noreply.github.com> --- .github/workflows/docs.yml | 40 ++++++++ docs/index.html | 196 +++++++++++++++++++++++++++++++++++++ docs/style.css | 194 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 4 files changed, 431 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docs.yml create mode 100644 docs/index.html create mode 100644 docs/style.css diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..c8bd954 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,40 @@ +name: Deploy docs to GitHub Pages + +on: + push: + branches: + - "main" + paths: + - "docs/**" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - uses: actions/checkout@v5 + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/ + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..b4d4f60 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,196 @@ + + + + + + GIMKit — Guided Infilling Modeling Toolkit + + + + +
+
+ + +
+
+ +
+ +
+
+

GIMKit

+

Guided Infilling Modeling Toolkit — precise structured text generation with language models.

+
+ PyPI Version + Supported Python versions + Supported Platforms +
+
+
+ +
+ +
+

Installation

+

Install GIMKit using pip:

+
pip install gimkit
+

For vLLM support, install with the optional dependency:

+
pip install gimkit[vllm]
+
+ +
+

Quick Start

+

Here's a simple example using the OpenAI backend:

+
from openai import OpenAI
+from gimkit import from_openai, guide as g
+
+# Initialize the client and model
+client = OpenAI()  # Uses OPENAI_API_KEY environment variable
+model = from_openai(client, model_name="gpt-4")
+
+# Create a query with masked tags
+result = model(f"Hello, {g(desc='a single word')}!", use_gim_prompt=True)
+print(result)  # Output: Hello, world!
+
+ +
+

Usage

+ +

Creating Masked Tags

+

Use the guide helper (imported as g) to create masked tags:

+
from gimkit import guide as g
+
+# Basic tag with description
+tag = g(name="greeting", desc="A friendly greeting")
+
+# Specialized tags
+name_tag   = g.person_name(name="user_name")
+email_tag  = g.e_mail(name="email")
+phone_tag  = g.phone_number(name="phone")
+word_tag   = g.single_word(name="word")
+
+# Selection from choices
+choice_tag = g.select(name="color", choices=["red", "green", "blue"])
+
+# Tag with regex constraint
+custom_tag = g(name="code", desc="A 4-digit code", regex=r"\d{4}")
+ +

Building Queries

+

Combine masked tags with text to build queries:

+
from gimkit import from_openai, guide as g
+from openai import OpenAI
+
+client = OpenAI()
+model = from_openai(client, model_name="gpt-4")
+
+query = f"""
+Name: {g.person_name(name="name")}
+Email: {g.e_mail(name="email")}
+Favorite color: {g.select(name="color", choices=["red", "green", "blue"])}
+"""
+
+result = model(query, use_gim_prompt=True)
+print(result)
+ +

Accessing Results

+

Access filled tags from the result:

+
result = model(query, use_gim_prompt=True)
+
+# Iterate over all tags
+for tag in result.tags:
+    print(f"{tag.name}: {tag.content}")
+
+# Access by name
+print(result.tags["name"].content)
+
+# Modify tag content
+result.tags["email"].content = "REDACTED"
+
+ +
+

API Reference

+ +

guide — Tag Builder

+

A singleton instance of Guide for creating masked tags. Import it as g by convention.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodDescription
g(name, desc, regex, content)Create a generic masked tag with optional attributes.
g.single_word(name)A single word without spaces (\S+).
g.select(name, choices)Choose one value from the given list of options.
g.datetime(name, require_date, require_time)A date and/or time string (e.g., 2023-10-05 14:30:00).
g.person_name(name)A person's name (e.g., John Doe, 张三).
g.phone_number(name)A phone number (e.g., +1-123-456-7890).
g.e_mail(name)An email address (e.g., alice@example.com).
+ +

from_openai — OpenAI Backend

+
from gimkit import from_openai
+from openai import OpenAI
+
+model = from_openai(client: OpenAI, model_name: str)
+

Returns a callable model that accepts a query string and returns a Result.

+ +

from_vllm / from_vllm_offline — vLLM Backends

+
from gimkit import from_vllm, from_vllm_offline
+

Adapters for vLLM server and offline inference. Requires pip install gimkit[vllm].

+
+ +
+

Design Philosophy

+
    +
  • Stable over feature — reliability and correctness are prioritized above new features.
  • +
  • Small open-source model first — designed to work well with small, freely available language models.
  • +
+
+ +
+
+ + + + + diff --git a/docs/style.css b/docs/style.css new file mode 100644 index 0000000..deedff3 --- /dev/null +++ b/docs/style.css @@ -0,0 +1,194 @@ +/* ── Reset & Base ─────────────────────────────────────────────────────────── */ +*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } + +:root { + --bg: #ffffff; + --surface: #f6f8fa; + --border: #d0d7de; + --text: #1f2328; + --muted: #57606a; + --accent: #0969da; + --accent-bg: #ddf4ff; + --code-bg: #f6f8fa; + --header-bg: #24292f; + --header-fg: #f0f6fc; + --radius: 6px; + --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; +} + +html { scroll-behavior: smooth; } + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.6; + color: var(--text); + background: var(--bg); +} + +/* ── Layout ───────────────────────────────────────────────────────────────── */ +.container { + max-width: 860px; + margin: 0 auto; + padding: 0 24px; +} + +/* ── Header ───────────────────────────────────────────────────────────────── */ +header { + background: var(--header-bg); + position: sticky; + top: 0; + z-index: 100; + border-bottom: 1px solid #444c56; +} + +.header-inner { + display: flex; + align-items: center; + justify-content: space-between; + height: 56px; +} + +.logo { + font-size: 1.2rem; + font-weight: 700; + color: var(--header-fg); + text-decoration: none; + letter-spacing: -0.3px; +} + +nav a { + color: #adbac7; + text-decoration: none; + margin-left: 20px; + font-size: 0.9rem; + transition: color 0.15s; +} + +nav a:hover { color: var(--header-fg); } + +/* ── Hero ─────────────────────────────────────────────────────────────────── */ +.hero { + background: var(--surface); + border-bottom: 1px solid var(--border); + padding: 64px 0 48px; + text-align: center; +} + +.hero h1 { + font-size: 3rem; + font-weight: 800; + letter-spacing: -1px; + margin-bottom: 16px; +} + +.hero .subtitle { + font-size: 1.15rem; + color: var(--muted); + max-width: 600px; + margin: 0 auto 24px; +} + +.badges { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; } +.badges img { height: 20px; } + +/* ── Content ──────────────────────────────────────────────────────────────── */ +.content { padding: 48px 24px; } + +section { margin-bottom: 56px; } +section:last-child { margin-bottom: 0; } + +h2 { + font-size: 1.6rem; + font-weight: 700; + margin-bottom: 16px; + padding-bottom: 8px; + border-bottom: 1px solid var(--border); +} + +h3 { + font-size: 1.1rem; + font-weight: 600; + margin: 28px 0 10px; + color: var(--text); +} + +p { margin-bottom: 12px; color: var(--muted); } + +ul { margin: 0 0 12px 24px; } +ul li { color: var(--muted); margin-bottom: 6px; } +ul li strong { color: var(--text); } + +/* ── Code ─────────────────────────────────────────────────────────────────── */ +code { + font-family: var(--font-mono); + font-size: 0.88em; + background: var(--code-bg); + border: 1px solid var(--border); + border-radius: 4px; + padding: 2px 6px; + color: var(--text); +} + +pre { + background: var(--code-bg); + border: 1px solid var(--border); + border-radius: var(--radius); + padding: 20px 24px; + overflow-x: auto; + margin: 12px 0 20px; +} + +pre code { + background: none; + border: none; + padding: 0; + font-size: 0.875rem; + line-height: 1.65; + color: var(--text); +} + +/* ── Table ────────────────────────────────────────────────────────────────── */ +table { + width: 100%; + border-collapse: collapse; + margin: 12px 0 20px; + font-size: 0.9rem; +} + +th, td { + text-align: left; + padding: 10px 14px; + border: 1px solid var(--border); +} + +th { + background: var(--surface); + font-weight: 600; + color: var(--text); +} + +td { color: var(--muted); } +td:first-child { color: var(--text); white-space: nowrap; } + +tr:nth-child(even) td { background: #fafbfc; } + +/* ── Footer ───────────────────────────────────────────────────────────────── */ +footer { + background: var(--surface); + border-top: 1px solid var(--border); + padding: 24px 0; + text-align: center; + font-size: 0.875rem; + color: var(--muted); +} + +footer a { color: var(--accent); text-decoration: none; } +footer a:hover { text-decoration: underline; } + +/* ── Responsive ───────────────────────────────────────────────────────────── */ +@media (max-width: 600px) { + .hero h1 { font-size: 2.2rem; } + nav a { margin-left: 12px; font-size: 0.82rem; } + pre { padding: 14px 16px; } +} diff --git a/pyproject.toml b/pyproject.toml index f32cb17..94e8119 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ vllm = [ [project.urls] Homepage = "https://github.com/SculptAI/GIMKit" -Documentation = "https://github.com/SculptAI/GIMKit" +Documentation = "https://sculptai.github.io/GIMKit" Repository = "https://github.com/SculptAI/GIMKit" Issues = "https://github.com/SculptAI/GIM/issues" From cacef03c4ef18663bcf37e1103f8ef8f7dabbaf6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 03:29:03 +0000 Subject: [PATCH 3/4] docs: replace plain HTML with MkDocs (Material theme) Co-authored-by: Ki-Seki <60967965+Ki-Seki@users.noreply.github.com> --- .github/workflows/docs.yml | 14 ++- =1.6.1 | 0 docs/api.md | 84 ++++++++++++++++ docs/index.html | 196 ------------------------------------- docs/index.md | 24 +++++ docs/installation.md | 25 +++++ docs/quickstart.md | 35 +++++++ docs/requirements.txt | 2 + docs/style.css | 194 ------------------------------------ docs/usage.md | 87 ++++++++++++++++ mkdocs.yml | 44 +++++++++ 11 files changed, 314 insertions(+), 391 deletions(-) create mode 100644 =1.6.1 create mode 100644 docs/api.md delete mode 100644 docs/index.html create mode 100644 docs/index.md create mode 100644 docs/installation.md create mode 100644 docs/quickstart.md create mode 100644 docs/requirements.txt delete mode 100644 docs/style.css create mode 100644 docs/usage.md create mode 100644 mkdocs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c8bd954..8b01fae 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -6,6 +6,7 @@ on: - "main" paths: - "docs/**" + - "mkdocs.yml" workflow_dispatch: permissions: @@ -27,13 +28,24 @@ jobs: steps: - uses: actions/checkout@v5 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install MkDocs + run: pip install -r docs/requirements.txt + + - name: Build docs + run: mkdocs build --strict + - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: docs/ + path: site/ - name: Deploy to GitHub Pages id: deployment diff --git a/=1.6.1 b/=1.6.1 new file mode 100644 index 0000000..e69de29 diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..3e27eb2 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,84 @@ +# API Reference + +## `guide` — Tag Builder + +A singleton instance of `Guide` for creating masked tags. Import it as `g` by convention: + +```python +from gimkit import guide as g +``` + +### Methods + +| Method | Description | +|---|---| +| `g(name, desc, regex, content)` | Create a generic masked tag with optional attributes. | +| `g.single_word(name)` | A single word without spaces (`\S+`). | +| `g.select(name, choices)` | Choose one value from the given list of options. | +| `g.datetime(name, require_date, require_time)` | A date and/or time string, e.g. `2023-10-05 14:30:00`. | +| `g.person_name(name)` | A person's name, e.g. *John Doe*, *张三*. | +| `g.phone_number(name)` | A phone number, e.g. *+1-123-456-7890*. | +| `g.e_mail(name)` | An email address, e.g. *alice@example.com*. | + +### `MaskedTag` attributes + +| Attribute | Type | Description | +|---|---|---| +| `name` | `str | None` | Tag name for named access in results. | +| `desc` | `str | None` | Natural-language description sent to the model. | +| `regex` | `str | None` | Regex pattern constraining model output. | +| `content` | `str | None` | Filled content (set after model inference). | + +--- + +## `from_openai` — OpenAI Backend + +```python +from gimkit import from_openai +from openai import OpenAI + +model = from_openai(client: OpenAI, model_name: str) +result = model(query, use_gim_prompt=True) +``` + +Returns a callable model. Supports both synchronous and asynchronous calls. + +--- + +## `from_vllm` — vLLM Server Backend + +```python +from gimkit import from_vllm + +model = from_vllm(base_url: str, model_name: str) +result = model(query) +``` + +Requires `pip install gimkit[vllm]` on Linux. + +--- + +## `from_vllm_offline` — vLLM Offline Backend + +```python +from gimkit import from_vllm_offline + +model = from_vllm_offline(model_name: str) +result = model(query) +``` + +Requires `pip install gimkit[vllm]` on Linux. + +--- + +## `Query` and `Response` + +Low-level classes for working with GIM-formatted strings directly: + +```python +from gimkit.contexts import Query, Response, infill + +query = Query(f"Hello, {g(name='word', desc='a single word')}!") +response = Response(f"<|GIM_RESPONSE|>...<|/GIM_RESPONSE|>") +result = infill(query, response) +``` diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index b4d4f60..0000000 --- a/docs/index.html +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - GIMKit — Guided Infilling Modeling Toolkit - - - - -
-
- - -
-
- -
- -
-
-

GIMKit

-

Guided Infilling Modeling Toolkit — precise structured text generation with language models.

-
- PyPI Version - Supported Python versions - Supported Platforms -
-
-
- -
- -
-

Installation

-

Install GIMKit using pip:

-
pip install gimkit
-

For vLLM support, install with the optional dependency:

-
pip install gimkit[vllm]
-
- -
-

Quick Start

-

Here's a simple example using the OpenAI backend:

-
from openai import OpenAI
-from gimkit import from_openai, guide as g
-
-# Initialize the client and model
-client = OpenAI()  # Uses OPENAI_API_KEY environment variable
-model = from_openai(client, model_name="gpt-4")
-
-# Create a query with masked tags
-result = model(f"Hello, {g(desc='a single word')}!", use_gim_prompt=True)
-print(result)  # Output: Hello, world!
-
- -
-

Usage

- -

Creating Masked Tags

-

Use the guide helper (imported as g) to create masked tags:

-
from gimkit import guide as g
-
-# Basic tag with description
-tag = g(name="greeting", desc="A friendly greeting")
-
-# Specialized tags
-name_tag   = g.person_name(name="user_name")
-email_tag  = g.e_mail(name="email")
-phone_tag  = g.phone_number(name="phone")
-word_tag   = g.single_word(name="word")
-
-# Selection from choices
-choice_tag = g.select(name="color", choices=["red", "green", "blue"])
-
-# Tag with regex constraint
-custom_tag = g(name="code", desc="A 4-digit code", regex=r"\d{4}")
- -

Building Queries

-

Combine masked tags with text to build queries:

-
from gimkit import from_openai, guide as g
-from openai import OpenAI
-
-client = OpenAI()
-model = from_openai(client, model_name="gpt-4")
-
-query = f"""
-Name: {g.person_name(name="name")}
-Email: {g.e_mail(name="email")}
-Favorite color: {g.select(name="color", choices=["red", "green", "blue"])}
-"""
-
-result = model(query, use_gim_prompt=True)
-print(result)
- -

Accessing Results

-

Access filled tags from the result:

-
result = model(query, use_gim_prompt=True)
-
-# Iterate over all tags
-for tag in result.tags:
-    print(f"{tag.name}: {tag.content}")
-
-# Access by name
-print(result.tags["name"].content)
-
-# Modify tag content
-result.tags["email"].content = "REDACTED"
-
- -
-

API Reference

- -

guide — Tag Builder

-

A singleton instance of Guide for creating masked tags. Import it as g by convention.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodDescription
g(name, desc, regex, content)Create a generic masked tag with optional attributes.
g.single_word(name)A single word without spaces (\S+).
g.select(name, choices)Choose one value from the given list of options.
g.datetime(name, require_date, require_time)A date and/or time string (e.g., 2023-10-05 14:30:00).
g.person_name(name)A person's name (e.g., John Doe, 张三).
g.phone_number(name)A phone number (e.g., +1-123-456-7890).
g.e_mail(name)An email address (e.g., alice@example.com).
- -

from_openai — OpenAI Backend

-
from gimkit import from_openai
-from openai import OpenAI
-
-model = from_openai(client: OpenAI, model_name: str)
-

Returns a callable model that accepts a query string and returns a Result.

- -

from_vllm / from_vllm_offline — vLLM Backends

-
from gimkit import from_vllm, from_vllm_offline
-

Adapters for vLLM server and offline inference. Requires pip install gimkit[vllm].

-
- -
-

Design Philosophy

-
    -
  • Stable over feature — reliability and correctness are prioritized above new features.
  • -
  • Small open-source model first — designed to work well with small, freely available language models.
  • -
-
- -
-
- - - - - diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..7894160 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,24 @@ +# GIMKit + +**Guided Infilling Modeling Toolkit** — precise structured text generation using language models. + +GIMKit lets you define placeholders (masked tags) in text and have a language model fill them in. It gives you fine-grained control over model outputs through a typed tag system with optional regex constraints. + +[![PyPI Version](https://img.shields.io/pypi/v/gimkit?label=pypi%20package)](https://pypi.org/project/gimkit) +[![Python Versions](https://img.shields.io/pypi/pyversions/gimkit.svg)](https://pypi.org/project/gimkit) +[![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey)](https://pypi.org/project/gimkit) + +--- + +## Features + +- **Masked tag system** — embed typed placeholders directly in f-strings. +- **Regex constraints** — restrict model output to specific patterns. +- **Named access** — retrieve results by tag name or index. +- **Multiple backends** — OpenAI, vLLM (server and offline). +- **Small-model friendly** — designed to work well with compact open-source models. + +## Design Philosophy + +- **Stable over feature** — reliability and correctness are prioritized above new features. +- **Small open-source model first** — designed to work well with small, freely available language models. diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..837874a --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,25 @@ +# Installation + +## Standard + +Install GIMKit using pip: + +```bash +pip install gimkit +``` + +## With vLLM support + +Install with the optional `vllm` extra to enable the vLLM backends: + +```bash +pip install gimkit[vllm] +``` + +!!! note + vLLM is only supported on Linux. On Windows and macOS, omit the `[vllm]` extra. + +## Requirements + +- Python 3.10 or later +- Linux, macOS, or Windows diff --git a/docs/quickstart.md b/docs/quickstart.md new file mode 100644 index 0000000..e0a2a64 --- /dev/null +++ b/docs/quickstart.md @@ -0,0 +1,35 @@ +# Quick Start + +Here is a minimal example using the OpenAI backend. + +## 1. Set up the client + +```python +from openai import OpenAI +from gimkit import from_openai, guide as g + +client = OpenAI() # reads OPENAI_API_KEY from environment +model = from_openai(client, model_name="gpt-4") +``` + +## 2. Create a query with masked tags + +```python +result = model(f"Hello, {g(desc='a single word')}!", use_gim_prompt=True) +print(result) # Hello, world! +``` + +## 3. Run a structured form + +```python +query = f""" +Name: {g.person_name(name="name")} +Email: {g.e_mail(name="email")} +Favorite color: {g.select(name="color", choices=["red", "green", "blue"])} +""" + +result = model(query, use_gim_prompt=True) +print(result.tags["name"].content) # e.g. Alice +print(result.tags["email"].content) # e.g. alice@example.com +print(result.tags["color"].content) # red | green | blue +``` diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..2d9b3cf --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +mkdocs>=1.6.1 +mkdocs-material>=9.6.23 diff --git a/docs/style.css b/docs/style.css deleted file mode 100644 index deedff3..0000000 --- a/docs/style.css +++ /dev/null @@ -1,194 +0,0 @@ -/* ── Reset & Base ─────────────────────────────────────────────────────────── */ -*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } - -:root { - --bg: #ffffff; - --surface: #f6f8fa; - --border: #d0d7de; - --text: #1f2328; - --muted: #57606a; - --accent: #0969da; - --accent-bg: #ddf4ff; - --code-bg: #f6f8fa; - --header-bg: #24292f; - --header-fg: #f0f6fc; - --radius: 6px; - --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; -} - -html { scroll-behavior: smooth; } - -body { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; - font-size: 16px; - line-height: 1.6; - color: var(--text); - background: var(--bg); -} - -/* ── Layout ───────────────────────────────────────────────────────────────── */ -.container { - max-width: 860px; - margin: 0 auto; - padding: 0 24px; -} - -/* ── Header ───────────────────────────────────────────────────────────────── */ -header { - background: var(--header-bg); - position: sticky; - top: 0; - z-index: 100; - border-bottom: 1px solid #444c56; -} - -.header-inner { - display: flex; - align-items: center; - justify-content: space-between; - height: 56px; -} - -.logo { - font-size: 1.2rem; - font-weight: 700; - color: var(--header-fg); - text-decoration: none; - letter-spacing: -0.3px; -} - -nav a { - color: #adbac7; - text-decoration: none; - margin-left: 20px; - font-size: 0.9rem; - transition: color 0.15s; -} - -nav a:hover { color: var(--header-fg); } - -/* ── Hero ─────────────────────────────────────────────────────────────────── */ -.hero { - background: var(--surface); - border-bottom: 1px solid var(--border); - padding: 64px 0 48px; - text-align: center; -} - -.hero h1 { - font-size: 3rem; - font-weight: 800; - letter-spacing: -1px; - margin-bottom: 16px; -} - -.hero .subtitle { - font-size: 1.15rem; - color: var(--muted); - max-width: 600px; - margin: 0 auto 24px; -} - -.badges { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; } -.badges img { height: 20px; } - -/* ── Content ──────────────────────────────────────────────────────────────── */ -.content { padding: 48px 24px; } - -section { margin-bottom: 56px; } -section:last-child { margin-bottom: 0; } - -h2 { - font-size: 1.6rem; - font-weight: 700; - margin-bottom: 16px; - padding-bottom: 8px; - border-bottom: 1px solid var(--border); -} - -h3 { - font-size: 1.1rem; - font-weight: 600; - margin: 28px 0 10px; - color: var(--text); -} - -p { margin-bottom: 12px; color: var(--muted); } - -ul { margin: 0 0 12px 24px; } -ul li { color: var(--muted); margin-bottom: 6px; } -ul li strong { color: var(--text); } - -/* ── Code ─────────────────────────────────────────────────────────────────── */ -code { - font-family: var(--font-mono); - font-size: 0.88em; - background: var(--code-bg); - border: 1px solid var(--border); - border-radius: 4px; - padding: 2px 6px; - color: var(--text); -} - -pre { - background: var(--code-bg); - border: 1px solid var(--border); - border-radius: var(--radius); - padding: 20px 24px; - overflow-x: auto; - margin: 12px 0 20px; -} - -pre code { - background: none; - border: none; - padding: 0; - font-size: 0.875rem; - line-height: 1.65; - color: var(--text); -} - -/* ── Table ────────────────────────────────────────────────────────────────── */ -table { - width: 100%; - border-collapse: collapse; - margin: 12px 0 20px; - font-size: 0.9rem; -} - -th, td { - text-align: left; - padding: 10px 14px; - border: 1px solid var(--border); -} - -th { - background: var(--surface); - font-weight: 600; - color: var(--text); -} - -td { color: var(--muted); } -td:first-child { color: var(--text); white-space: nowrap; } - -tr:nth-child(even) td { background: #fafbfc; } - -/* ── Footer ───────────────────────────────────────────────────────────────── */ -footer { - background: var(--surface); - border-top: 1px solid var(--border); - padding: 24px 0; - text-align: center; - font-size: 0.875rem; - color: var(--muted); -} - -footer a { color: var(--accent); text-decoration: none; } -footer a:hover { text-decoration: underline; } - -/* ── Responsive ───────────────────────────────────────────────────────────── */ -@media (max-width: 600px) { - .hero h1 { font-size: 2.2rem; } - nav a { margin-left: 12px; font-size: 0.82rem; } - pre { padding: 14px 16px; } -} diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 0000000..256dbc1 --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,87 @@ +# Usage Guide + +## Creating Masked Tags + +Use the `guide` helper (conventionally imported as `g`) to create masked tags: + +```python +from gimkit import guide as g + +# Basic tag with description +tag = g(name="greeting", desc="A friendly greeting") + +# Specialized tags +name_tag = g.person_name(name="user_name") +email_tag = g.e_mail(name="email") +phone_tag = g.phone_number(name="phone") +word_tag = g.single_word(name="word") + +# Selection from choices +choice_tag = g.select(name="color", choices=["red", "green", "blue"]) + +# Tag with regex constraint +code_tag = g(name="code", desc="A 4-digit PIN", regex=r"\d{4}") +``` + +## Building Queries + +Masked tags can be embedded directly in Python f-strings: + +```python +from gimkit import from_openai, guide as g +from openai import OpenAI + +client = OpenAI() +model = from_openai(client, model_name="gpt-4") + +query = f""" +Name: {g.person_name(name="name")} +Email: {g.e_mail(name="email")} +Favorite color: {g.select(name="color", choices=["red", "green", "blue"])} +""" + +result = model(query, use_gim_prompt=True) +print(result) +``` + +## Accessing Results + +Tags in the result can be accessed by index or by name: + +```python +result = model(query, use_gim_prompt=True) + +# Iterate over all tags +for tag in result.tags: + print(f"{tag.name}: {tag.content}") + +# Access a specific tag by name +print(result.tags["name"].content) + +# Access by index +print(result.tags[0].content) + +# Modify tag content +result.tags["email"].content = "REDACTED" +``` + +## Using vLLM + +```python +from gimkit import from_vllm + +model = from_vllm(base_url="http://localhost:8000", model_name="your-model") +result = model(query) +``` + +For offline inference without a running server: + +```python +from gimkit import from_vllm_offline + +model = from_vllm_offline(model_name="your-model") +result = model(query) +``` + +!!! note + `from_vllm` and `from_vllm_offline` require `pip install gimkit[vllm]` on Linux. diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..2f297c7 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,44 @@ +site_name: GIMKit +site_url: https://sculptai.github.io/GIMKit +site_description: Guided Infilling Modeling Toolkit — precise structured text generation with language models. +site_author: Shichao Song +repo_name: SculptAI/GIMKit +repo_url: https://github.com/SculptAI/GIMKit + +theme: + name: material + palette: + - scheme: default + primary: indigo + accent: indigo + toggle: + icon: material/brightness-7 + name: Switch to dark mode + - scheme: slate + primary: indigo + accent: indigo + toggle: + icon: material/brightness-4 + name: Switch to light mode + features: + - navigation.top + - content.code.copy + +nav: + - Home: index.md + - Installation: installation.md + - Quick Start: quickstart.md + - Usage Guide: usage.md + - API Reference: api.md + +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.superfences + - pymdownx.inlinehilite + - admonition + - attr_list + - tables + +exclude_docs: | + requirements.txt From 2bdf74498c1340583c0eaaacdf30cd3327edee8a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 03:29:18 +0000 Subject: [PATCH 4/4] chore: remove accidental =1.6.1 file Co-authored-by: Ki-Seki <60967965+Ki-Seki@users.noreply.github.com> --- =1.6.1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 =1.6.1 diff --git a/=1.6.1 b/=1.6.1 deleted file mode 100644 index e69de29..0000000