Skip to content

Commit

Permalink
Add pre-commit and formatters (poe-platform#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored May 12, 2023
1 parent 23d29f9 commit fd0a5d7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 8 deletions.
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
repos:
# Order matters because pyupgrade may make changes that pycln and black have to clean up
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.3
hooks:
- id: pycln
args: [--config=pyproject.toml]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-simplify

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
3 changes: 3 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
proseWrap: always
printWidth: 88
endOfLine: auto
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Heroku Poe sample

This is a sample repository for creating Poe API bots on Heroku. For more information on API bots, see [poe-protocol](https://github.com/poe-platform/poe-protocol).
This is a sample repository for creating Poe API bots on Heroku. For more information on
API bots, see [poe-protocol](https://github.com/poe-platform/poe-protocol).

## Getting started

- Create an account on [heroku.com](https://heroku.com)
- On the website, create a new application. Let's name it $YOUR_APP
- [Install](https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli) the Heroku CLI
- Open the [bot creation page](https://poe.com/create_bot?api=1). An API key will be pre-generated for you.
- [Install](https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli) the
Heroku CLI
- Open the [bot creation page](https://poe.com/create_bot?api=1). An API key will be
pre-generated for you.
- Open a terminal and run:
- `git clone https://github.com/poe-platform/heroku-sample.git`
- `cd heroku-sample`
- `heroku git:remote -a $YOUR_APP`
- `heroku config:set POE_API_KEY=$POE_API_KEY`, where `$POE_API_KEY` is the API key you got from [bot creation page](https://poe.com/create_bot?api=1)
- `heroku config:set POE_API_KEY=$POE_API_KEY`, where `$POE_API_KEY` is the API key
you got from [bot creation page](https://poe.com/create_bot?api=1)
- `git push heroku main`
- Now your app should be online at `https://$YOUR_APP.herokuapp.com/`
- Add the URL in the bot creation page
Expand All @@ -21,4 +25,7 @@ This is a sample repository for creating Poe API bots on Heroku. For more inform

## Customize your bot

The above instructions just start a simple bot with no AI capabilities. To make your own bot, modify `main.py` and push to Heroku again. You can see sample code in the [poe-protocol](https://github.com/poe-platform/poe-protocol) repository or on [Replit](https://replit.com/@JelleZijlstra2/Poe-API-Template).
The above instructions just start a simple bot with no AI capabilities. To make your own
bot, modify `main.py` and push to Heroku again. You can see sample code in the
[poe-protocol](https://github.com/poe-platform/poe-protocol) repository or on
[Replit](https://replit.com/@JelleZijlstra2/Poe-API-Template).
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "A barebones Poe API bot, which can easily be deployed to Heroku.",
"image": "heroku/python",
"repository": "https://github.com/poe-platform/heroku-sample",
"keywords": ["python", "poe" ],
"keywords": ["python", "poe"],
"env": {
"POE_API_KEY": {
"description": "API key for your Poe bot.",
"generator": "secret"
}
}
}
}
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi_poe.samples.catbot import CatBot
from fastapi_poe import run
from fastapi_poe.samples.catbot import CatBot

run(CatBot())
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tool.black]
target-version = ['py37']
skip-magic-trailing-comma = true

[tool.pycln]
all = true

[tool.isort]
profile = "black"
combine_as_imports = true
skip_gitignore = true

0 comments on commit fd0a5d7

Please sign in to comment.