ChatdollKit Server SDK for Python
SDK to create remote skill server for ChatdollKit. See also 👉 ChatdollKit
Install
$ pip install chatdollkit
Also install application framework you like. We support Flask and FastAPI.
$ pip install flask
Or
$ pip install fastapi uvicorn
Quick start
Server side
Run example API server that just echo what user says.
$ python run_flask.py
Or
$ uvicorn run_fastapi:app --port 12345 --reload
Client side
See ChatdollKit Documentation > Setup Skill client (ChatdollKit device) to use Examples/SkillServer.
If you want to run skill server on host other than localhost configure URLs on the inspector of HttpSkillRouter and HttpPrompter.
After setting up both server and client, run your Chatdoll app and start conversation. Your 3D model will echo what you say.
Create your own Skill Server
Basically Skill(s), Server application and Entrypoint are required to create your Skill Server as following chapters.
First of all, make allinone.py and import required libraries.
from flask import Flask
from chatdollkit.app import SkillBase, AppBase
from chatdollkit.models import (
Request, Response, State, IntentExtractionResult, Intent
)
from chatdollkit.controllers.flask_controller import bp as api_bp
1. Skill
Make EchoSkill class that extends SkillBase and implement process methods to return response that includes a Text-to-Speech voice request.
class EchoSkill(SkillBase):
topic = "echo"
def process(self, request: Request, state: State) -> Response:
# Just echo
resp = Response(Id=request.Id)
resp.AddVoiceTTS(request.Text)
return resp
2. Server application
Make MyApp that extends AppBase and implement get_prompt methods that requires voice input to user and extract_intent to route to EchoSkill.
class MyApp(AppBase):
# Register skill(s)
skills = [EchoSkill]
def get_prompt(self, request: Request, state: State) -> Response:
# Return prompt message
resp = Response(Id="_" if request is None else request.Id)
resp.AddVoiceTTS("This prompt is from server. Please say something.")
return resp
def extract_intent(self, request: Request, state: State) -> IntentExtractionResult:
# Always extract Echo intent
return IntentExtractionResult(Intent=Intent(Name=EchoSkill.topic))
3. Application entry point
Lastly, Add the instance of MyApp to Flask application and register API controller blueprint to app.
# Create Flask app
app = Flask(__name__)
# Create ChatdollKit server app and set it to Flask application
app.chatdoll_app = MyApp(app.logger, True)
# Register API controller
app.register_blueprint(api_bp)
if __name__ == "__main__":
# Start API
app.run(port="12345", debug=True)
See the example if you want to create FastAPI-based skill server.
Use other application framework
To use application framework other than Flask and FastAPI, create controller that handles http request from ChatdollKit client by your self. You can reuse Skill, Server application and models. See chatdollkit.controllers.flask_controller.py or fastapi_controller.py.
Metadata
Release files for chatdollkit 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chatdollkit-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / chatdollkit-0.3.0-py3-none-any.whl
| Download URL | chatdollkit-0.3.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d45c168b0ab2312efd98430f5f0eeef9395535eb07a761f894a770f12869133
|
|
BLAKE2b-256 checksum How to use checksums |
f13229601a7d979e8efd8ef0ea1f1f4f1d638b0783e08159ec9a262e52fd04d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
|
Security for chatdollkit 0.3.0
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.