1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

First commit

This commit is contained in:
Steffo 2019-11-11 13:40:26 +01:00
parent 2d59bca0bd
commit ebaff84017
9 changed files with 48 additions and 9 deletions

View file

@ -1,6 +1,6 @@
# This is a template Pack __init__. You can use this without changing anything in other packages too! # This is a template Pack __init__. You can use this without changing anything in other packages too!
from . import commands, tables, stars from . import commands, tables, stars, utils
from .commands import available_commands from .commands import available_commands
from .tables import available_tables from .tables import available_tables
from .stars import available_page_stars, available_exception_stars from .stars import available_page_stars, available_exception_stars
@ -9,9 +9,9 @@ __all__ = [
"commands", "commands",
"tables", "tables",
"stars", "stars",
"utils",
"available_commands", "available_commands",
"available_tables", "available_tables",
"available_page_stars", "available_page_stars",
"available_exception_stars", "available_exception_stars",
] ]

View file

@ -1,9 +1,9 @@
# Imports go here! # Imports go here!
from .api_kei import ApiKei
# Enter the PageStars of your Pack here! # Enter the PageStars of your Pack here!
available_page_stars = [ available_page_stars = [
ApiKei
] ]
# Enter the ExceptionStars of your Pack here! # Enter the ExceptionStars of your Pack here!

23
keipack/stars/api_kei.py Normal file
View file

@ -0,0 +1,23 @@
from starlette.requests import Request
from starlette.responses import *
from royalnet.web import *
from royalnet.utils import *
import royalnet.packs.common.tables as cpt
import royalpack.tables as rpt
class ApiKei(PageStar):
path = "/api/kei"
tables = {}
async def _generate(self, request: Request, session) -> typing.Tuple[str, str]:
return "happy", "Ciao!"
async def page(self, request: Request) -> JSONResponse:
async with self.session_acm() as session:
emotion, text = await self._generate(request, session)
return JSONResponse({
"emotion": emotion,
"text": text,
})

View file

13
keipack/utils/emotion.py Normal file
View file

@ -0,0 +1,13 @@
from enum import Enum, auto
class Emotion(Enum):
HAPPY = auto()
SAD = auto()
ANGRY = auto()
def __str__(self):
return self.name
def __repr__(self):
return f"<{self.__class__.__qualname__} {self.name}: {self.value}>"

View file

@ -0,0 +1,3 @@
starlette
royalnet
royalpack

View file

@ -7,14 +7,14 @@ with open("requirements.txt", "r") as f:
install_requires = f.readlines() install_requires = f.readlines()
setuptools.setup( setuptools.setup(
name="{packname}", name="keipack",
version="0.1", version="0.1",
author="{packauthorname}", author="Stefano Pigozzi",
author_email="{packauthoremail}", author_email="ste.pigozzi@gmail.com",
description="{packdescription}", description="A mysterious AI assistant",
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="{packgithublink}", url="https://github.com/Steffo99/keipack",
packages=setuptools.find_packages(), packages=setuptools.find_packages(),
install_requires=install_requires, install_requires=install_requires,
python_requires=">=3.7", python_requires=">=3.7",