Skip to main content

A demonstration of the Poe protocol using FastAPI

Project description

fastapi_poe

An implementation of the Poe protocol using FastAPI.

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


Release history Release notifications | RSS feed

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_poe-0.0.34-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_poe-0.0.34.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for fastapi_poe-0.0.34.tar.gz
Algorithm Hash digest
SHA256 bfdc5a7901e09299bab2bb943c1920fbd2d8a3b146453a7df0ec85716945e605
MD5 e231999c558834addd485e94dda75ff8
BLAKE2b-256 e747ec95263da2e0b60798331f9fc4c950f0d50718d92a518d8026523460b3ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastapi_poe-0.0.34-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for fastapi_poe-0.0.34-py3-none-any.whl
Algorithm Hash digest
SHA256 f3339a52ea78d0dd1232abec303d762b323b2b327910806fd27ff285a74d304d
MD5 df04fb37020c0a4a972a3ff7e49dcb7e
BLAKE2b-256 9e5e6a4f197cc665967b343543d6a7b1ae0e1b7331cfa00749c42e04049311d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page