mindforge-py
This package contains Python clients and utilities for interacting with the Mindforge API. Specifically, there's a MindforgeServerClient for interactions with our REST API (e.g. creating an NPC, deleting a capability), and a MindforgeBrowserClient for joining live sessions in your client-side code.
Installation
To install the Mindforge client, use pip:
pip install mindforge
Server-side Usage
Create a MindforgeServerClient:
from mindforge import MindforgeServerClient
client = MindforgeServerClient(
base_url="https://api.mindforge.ai", # Optional
api_key="your-api-key"
)
To use this client, you'll need a Mindforge API key. You can create keys in the dashboard.
Performing NPC interactions
To trigger an NPC interaction:
from mindforge.messages import NPCText, NPCClientFunctionFire
npc_id = "your-npc-id" # get from dashboard
history = [
{"role": "player", "content": "Hello, NPC!"},
{"role": "npc", "content": "Greetings! How can I assist you today?"},
]
try:
result = await client.perform.trigger(npc_id, history)
for message in result:
if isinstance(message, NPCText):
print("NPC Text:", message.content)
elif isinstance(message, NPCClientFunctionFire):
print("NPC Function:", message.name, message.args)
except ValueError as error:
print("Error performing NPC interaction:", error)
Browser-side Usage
Create a MindforgeBrowserClient:
from mindforge import MindforgeBrowserClient, MindforgeNPCMessageType
client = MindforgeBrowserClient()
Joining a session
To join a live session:
token = "your-session-token" # `get_mindforge_session_token from token.py`
try:
await client.join_session(token)
print("Joined session successfully")
except ValueError as error:
print("Error joining session:", error)
Receiving messages
You can listen for various events emitted by the client:
@client.on(MindforgeNPCMessageType.Text)
def handle_text(message):
print("Received NPC text:", message.content)
@client.on(MindforgeNPCMessageType.InputAudioTranscript)
def handle_input_transcript(message):
print("Received input audio transcript:", message.content)
@client.on(MindforgeNPCMessageType.OutputAudioTranscript)
def handle_output_transcript(message):
print("Received output audio transcript:", message.content)
@client.on(MindforgeNPCMessageType.ClientFunctionFire)
def handle_client_function(message):
print("NPC triggered client function:", message.name, message.args)
Disconnecting
To disconnect from the session:
client.disconnect()
Event Types
The client uses the following event types:
Server Event Types
| Event Type | Description |
|---|---|
NPCText |
Received when the NPC sends a text message. |
NPCInputAudioTranscript |
Received when the input audio transcript is available. |
NPCOutputAudioTranscript |
Received when the output audio transcript is available. |
NPCClientFunctionFire |
Received when the NPC triggers a client-side function. |
Client Event Types
| Event Type | Description |
|---|---|
PlayerText |
Used to send a text message from the player to the server. |
PlayerTriggerNPCMessage |
Used to trigger an NPC message from the player. |
Support
If you need any help or have any questions, please open a GitHub issue or contact us at team@mindforge.ai.
Metadata
Release files for mindforge 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mindforge-1.0.4.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mindforge-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / mindforge-1.0.4.tar.gz
| Download URL | mindforge-1.0.4.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ce42e0fb15d939100901c675dd289af71511759a5392bcdf08cd6e64245972c
|
|
BLAKE2b-256 checksum How to use checksums |
33062b3133ca354be43df0ec0bd68d162fa13df0b0b79793b4a73dde8bc8eb0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / mindforge-1.0.4-py3-none-any.whl
| Download URL | mindforge-1.0.4-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1e30f5277dfef99b443efaaae96873a24a874aeecadb79bf6fba6590a54e03f
|
|
BLAKE2b-256 checksum How to use checksums |
354cdfd2a8c973aede248e04c412281f3541720907a909d21f2d2a00471d1927
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for mindforge 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.