Skip to main content

A demonstration of the Poe protocol using FastAPI

Project description

fastapi_poe

An implementation of the Poe protocol using FastAPI.

Installation

Install the package from PyPI:

pip install fastapi-poe

Write your own bot

This package can also be used as a base to write your own bot. You can inherit from PoeBot to make a bot:

import fastapi_poe as fp

class EchoBot(fp.PoeBot):
    async def get_response(self, request: fp.QueryRequest):
        last_message = request.query[-1].content
        yield fp.PartialResponse(text=last_message)

if __name__ == "__main__":
    fp.run(EchoBot(), allow_without_key=True)

Now, run your bot using python <filename.py>.

  • In a different terminal, run ngrok to make it publicly accessible.
  • Use the publicly accessible url to integrate your bot with Poe

Enable authentication

Poe servers send requests containing Authorization HTTP header in the format "Bearer <access_key>"; the access key is configured in the bot settings page.

To validate that the request is from the Poe servers, you can either set the environment variable POE_ACCESS_KEY or pass the parameter access_key in the run function like:

if __name__ == "__main__":
    fp.run(EchoBot(), access_key=<key>)

Samples

Check out our starter code repository for some examples you can use to get started with bot development.

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

fastapi_poe-0.0.68.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

fastapi_poe-0.0.68-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_poe-0.0.68.tar.gz.

File metadata

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

File hashes

Hashes for fastapi_poe-0.0.68.tar.gz
Algorithm Hash digest
SHA256 9c2605bf75cd737880ff45dcc0251e0dbde1d0fd11e3bfb6489589159b2939b4
MD5 7c7d99f0d2409c32fa6e6b500b35f489
BLAKE2b-256 d90bae2b97d0b8a8c82e69034e62236fc8cbe97bde2f332cf37567da6b828d9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_poe-0.0.68.tar.gz:

Publisher: publish.yml on poe-platform/fastapi_poe

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

File details

Details for the file fastapi_poe-0.0.68-py3-none-any.whl.

File metadata

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

File hashes

Hashes for fastapi_poe-0.0.68-py3-none-any.whl
Algorithm Hash digest
SHA256 4eba528c497f5694d92f263e28d62a58711ff9e065537adf698676c66526eb0b
MD5 7426106116eaf1358abc7e4217579557
BLAKE2b-256 220674b378b053442b28c3170f96535777137fc3f2eb17edb1b573a71ef88bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_poe-0.0.68-py3-none-any.whl:

Publisher: publish.yml on poe-platform/fastapi_poe

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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page