Skip to main content

LinkGrid Agent - Python client for BitNet API

Project description

🌐✨ LinkGrid Agent — Conversational AI SDK

PyPI Version Python Versions License: MIT

A modern, lightweight Python client for BitNet's conversational AI.
Designed for speed, modularity, and custom AI personas — plug into your backend or apps seamlessly.


⚡️ Key Features

  • 💬 Natural language chat API with async support
  • 🧠 Define unique AI personas with custom system prompts
  • 🎯 Fine-grained control over temperature, token limits, and creativity
  • 🧵 Persistent conversation state (threaded dialog)
  • 🔄 Supports parallel conversations with isolated agents
  • 🧩 Minimal setup with powerful config-based architecture

📦 Installation

pip install linkgrid-agent

🚀 Get Started

🔹 One-Line Chat

from linkgrid_agent import chat

async def main():
    response = await chat("What's the capital of France?")
    print(f"🤖 {response}")

import asyncio
asyncio.run(main())

Output:

🤖 The capital of France is Paris.

🎭 Custom AI Persona

from linkgrid_agent import LinkGridAgent

async def main():
    config = LinkGridAgent.Config()
    config.system_prompt = "You are a pirate captain. Answer like a pirate!"
    config.temperature = 0.9

    async with LinkGridAgent(config) as agent:
        response = await agent.chat("Where can I find treasure?")
        print(f"🏴‍☠️ {response}")

import asyncio
asyncio.run(main())

🦜 Output:

🏴‍☠️ Arr matey! Seek the treasure on Skull Island, where X marks the spot!

🔬 Advanced Use Cases

🧑‍🔬 Multi-Persona AI Agents

from linkgrid_agent import LinkGridAgent

async def main():
    poet_cfg = LinkGridAgent.Config()
    poet_cfg.system_prompt = "You are a romantic poet"
    poet_cfg.max_tokens = 200

    scientist_cfg = LinkGridAgent.Config()
    scientist_cfg.system_prompt = "You are a quantum physicist"
    scientist_cfg.temperature = 0.3

    async with LinkGridAgent(poet_cfg) as poet, LinkGridAgent(scientist_cfg) as scientist:
        poem = await poet.chat("Write a poem about the stars")
        expl = await scientist.chat("Explain quantum entanglement")

        print(f"📜 Poet:\n{poem}\n")
        print(f"🔬 Scientist:\n{expl}")

import asyncio
asyncio.run(main())

🗂️ Stateful Conversation Threads

from linkgrid_agent import LinkGridAgent

async def main():
    config = LinkGridAgent.Config()
    config.system_prompt = "You're a helpful travel assistant"

    async with LinkGridAgent(config) as agent:
        await agent.chat("I'm planning a trip to Japan")
        tokyo = await agent.chat("What should I see in Tokyo?")
        traditions = await agent.chat("How about traditional experiences?")

        print(f"🗼 Tokyo Tips: {tokyo}")
        print(f"🎎 Traditions: {traditions}")

import asyncio
asyncio.run(main())

🧠 Embedding Model

from linkgrid_agent.agent import get_embedding_model
import asyncio

async def main():
    model = await get_embedding_model()
    sentences = ["Hello world", "Another sentence"]
    embeddings = model.encode(sentences)
    print(embeddings)

asyncio.run(main())

⚙️ Configuration

Customize your agent behavior using simple parameters.

Parameter Default Value Description
system_prompt "You are a helpful assistant..." Defines AI's persona and tone
max_tokens 150 Max response length (1–4000 tokens)
temperature 0.7 Creativity scale: 0 = precise, 1 = creative

🔧 Example Setup:

config = LinkGridAgent.Config()
config.system_prompt = "You're a 19th century British detective"
config.max_tokens = 250
config.temperature = 0.5

🛡️ Error Handling

Gracefully manage edge cases and errors:

from linkgrid_agent import chat

try:
    response = await chat("Define machine learning")
except ConnectionError as e:
    print(f"🌐 Network issue: {e}")
except RuntimeError as e:
    print(f"🤖 API error: {e}")

Exceptions

  • ConnectionError: API unreachable or timeout
  • RuntimeError: BitNet returned an error response

📋 Requirements

  • Python 3.9+
  • httpx – Async HTTP client
  • sentence-transformers – Text embedding models
  • torch – PyTorch backend for sentence-transformers

📄 License

Released under the MIT License.
Feel free to fork, improve, and share!


🤝 Contribution

PRs are welcome. Please make sure to follow the existing code style.
Open issues to report bugs or request features.


💡 Inspiration

"The future is already here — it's just not evenly distributed."
William Gibson

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linkgrid_agent-0.1.7.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linkgrid_agent-0.1.7-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file linkgrid_agent-0.1.7.tar.gz.

File metadata

  • Download URL: linkgrid_agent-0.1.7.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for linkgrid_agent-0.1.7.tar.gz
Algorithm Hash digest
SHA256 5e196686217189ddbf5c5dd7f6bf3e83048ec8aabdd3826367559a6ab50370b9
MD5 84329aefa54d0845ac050c48feabc908
BLAKE2b-256 25a8d0d5d06a190e292a1f93c11a66df9bb19c13f887a660e619ca95566c19d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for linkgrid_agent-0.1.7.tar.gz:

Publisher: publish.yml on OfficialDeepSaha/linkgrid-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file linkgrid_agent-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: linkgrid_agent-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for linkgrid_agent-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4b005f936e2411c703102a76bf966c722ad9de1621729cece6ed90e607181b32
MD5 9d72957fd49a004d84ff9ebe80ba0a29
BLAKE2b-256 517b1e703965102a496d8c65caa94be68ba359eff5a6512cacc8a83d4073b275

See more details on using hashes here.

Provenance

The following attestation bundles were made for linkgrid_agent-0.1.7-py3-none-any.whl:

Publisher: publish.yml on OfficialDeepSaha/linkgrid-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page