Python SDK for the Foil Engine NPC API
Project description
Foil Engine Python SDK
Python SDK for the Foil Engine NPC API. Add AI-powered NPC conversations to your game or application.
Installation
pip install foilengine
Quick Start
from foilengine import FoilEngineClient
client = FoilEngineClient(api_key="pk_live_...")
# Discover your personas
personas = client.personas.list()
# Initialize a session
session = client.chat.init_session(
persona_id=personas[0].id,
user_session_id="player-001",
player_name="Alex",
player_gender="non-binary",
)
print(session.message) # NPC's greeting
# Send a message
response = client.chat.send_message(
persona_id=personas[0].id,
message="What do you recommend?",
user_session_id="player-001",
)
print(response.message) # NPC's reply
print(response.current_state) # State machine state
print(response.score) # Session score
Async Support
from foilengine import AsyncFoilEngineClient
async with AsyncFoilEngineClient(api_key="pk_live_...") as client:
personas = await client.personas.list_async()
response = await client.chat.send_message_async(
persona_id=personas[0].id,
message="Hello!",
user_session_id="player-001",
)
Configuration
client = FoilEngineClient(
api_key="pk_live_...", # required
base_url="http://localhost:8000", # default: https://api.foilengine.com
timeout=30.0, # default: 30s
max_retries=3, # default: 3
)
Documentation
Full documentation at foilengine.com/docs/sdk/python
License
MIT
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
foilengine-0.1.0.tar.gz
(8.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file foilengine-0.1.0.tar.gz.
File metadata
- Download URL: foilengine-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6261dc04916b8ccaa3a58a63a495e2d0c49269036c9543fb5f7c2116c5f20024
|
|
| MD5 |
ad3f2a9548a3359a87d5da021e26bd39
|
|
| BLAKE2b-256 |
ea73f85d881228abccfa93683b5b2e570b02f5db50d3a9f0d46b2f787cbeadc5
|
File details
Details for the file foilengine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: foilengine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c323298c88a1f524e9a6fba252aabb79f610affc7a79ae839e667424d9ad14ff
|
|
| MD5 |
6c20d3e85ac1c93351d2031833885ac7
|
|
| BLAKE2b-256 |
ec63bafc0d37597a77bd2a80a59ceab693f068070d71f9bb794a60e35c263891
|