Skip to content

DorsetProject/dorset-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dorset remote agent library

https://secure.travis-ci.org/DorsetProject/dorset-python.png?branch=master

This library provides components for implementing the remote agent web service API for Dorset conversational interface project.

Installation

Install using pip:

$ pip install dorset

Note that the setup requires a recent version of setuptools and pip. To upgrade:

$ pip install --upgrade setuptools pip

Usage

This library handles the encoding and decoding of requests and responses from a Dorset application. This supports the creation of remote agents written in Python. Use this library with a python framework for RESTful APIs like Flask, Bottle, or Django.

The web framework will handle HTTP requests and response and this library will decode the request as an AgentRequest object and will encode an AgentResponse.

With Flask, this will look like:

app = Flask("dorset_hello")

# required endpoint for the application to test if the agent is alive
@app.route('/ping', methods=['GET'])
def ping():
    return json.dumps("pong")

# primary endpoint
@app.route('/request', methods=['POST'])
def process():
    agent_request = Dorset.decode_request(request.get_data(as_text=True))

    print(agent_request.text)

    return Dorset.encode_response(text="hello, world!")

Releases

No releases published

Packages

No packages published

Languages