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.65.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

fastapi_poe-0.0.65-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_poe-0.0.65.tar.gz
  • Upload date:
  • Size: 44.9 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.65.tar.gz
Algorithm Hash digest
SHA256 ef37fcf98cc4e3860f4972b1cf6bb215d1ff7cacfb2953ba507d29cf1aea5dbf
MD5 55e3410ab7f4de044309dbe633a7ec62
BLAKE2b-256 8ca055d2b9d103e8b0e956380f53a90fd2805ec9cac84c14c56b5f2fae637420

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_poe-0.0.65.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.65-py3-none-any.whl.

File metadata

  • Download URL: fastapi_poe-0.0.65-py3-none-any.whl
  • Upload date:
  • Size: 31.3 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.65-py3-none-any.whl
Algorithm Hash digest
SHA256 d5da55b854000e6a8d8b303c6b17ffaf3393a4f3a25c59066cc8eaae16fd1c9c
MD5 da0ec7e8e18b3ea50cadefb697131e3e
BLAKE2b-256 8894b6f544333c58dd4ce7b9bfd9b63de2f7539e4c6e700429efc6d7feb1ea7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_poe-0.0.65-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