Spaces:
Sleeping
Sleeping
Daniel Ecer commited on
Commit ·
a0aa138
1
Parent(s): deca7b9
Added placebear
Browse files
fngradio_various_api_mcp/apis/placebear.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from io import BytesIO
|
| 2 |
+
from typing import Annotated
|
| 3 |
+
|
| 4 |
+
import PIL.Image
|
| 5 |
+
from fngradio import FnGradioApp
|
| 6 |
+
import httpx
|
| 7 |
+
from pydantic import Field
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
app = FnGradioApp()
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@app.interface()
|
| 14 |
+
def get_random_placebear(
|
| 15 |
+
width: Annotated[
|
| 16 |
+
int,
|
| 17 |
+
Field(ge=100, le=1000)
|
| 18 |
+
] = 200,
|
| 19 |
+
height: Annotated[
|
| 20 |
+
int,
|
| 21 |
+
Field(ge=100, le=1000)
|
| 22 |
+
] = 200
|
| 23 |
+
) -> PIL.Image.Image:
|
| 24 |
+
"""
|
| 25 |
+
Random image from `placebear.com`
|
| 26 |
+
"""
|
| 27 |
+
response = httpx.get(
|
| 28 |
+
f'https://placebear.com/{width}/{height}',
|
| 29 |
+
follow_redirects=True
|
| 30 |
+
)
|
| 31 |
+
response.raise_for_status()
|
| 32 |
+
image = PIL.Image.open(BytesIO(response.read()))
|
| 33 |
+
return image
|
fngradio_various_api_mcp/app.py
CHANGED
|
@@ -5,6 +5,7 @@ from fngradio_various_api_mcp.apis import (
|
|
| 5 |
jokeapi,
|
| 6 |
numbersapi,
|
| 7 |
picsum,
|
|
|
|
| 8 |
zenquotes
|
| 9 |
)
|
| 10 |
|
|
@@ -14,5 +15,6 @@ app = FnGradioApp(apps=[
|
|
| 14 |
jokeapi.app,
|
| 15 |
numbersapi.app,
|
| 16 |
picsum.app,
|
|
|
|
| 17 |
zenquotes.app
|
| 18 |
])
|
|
|
|
| 5 |
jokeapi,
|
| 6 |
numbersapi,
|
| 7 |
picsum,
|
| 8 |
+
placebear,
|
| 9 |
zenquotes
|
| 10 |
)
|
| 11 |
|
|
|
|
| 15 |
jokeapi.app,
|
| 16 |
numbersapi.app,
|
| 17 |
picsum.app,
|
| 18 |
+
placebear.app,
|
| 19 |
zenquotes.app
|
| 20 |
])
|