yta-fastapi-docker-api 0.0.2__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yta-fastapi-docker-api
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Youtube Autonomous FastAPI Docker API Module
5
5
  License-File: LICENSE
6
6
  Author: danialcala94
@@ -12,10 +12,11 @@ Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Requires-Dist: fastapi (>=0.124.4,<9999.0.0)
15
- Requires-Dist: uvicorn (>=0.48.0,<9999.0.0)
15
+ Requires-Dist: uvicorn (>=0.49.0,<9999.0.0)
16
16
  Requires-Dist: yta_fastapi_docker_common (>=0.0.14,<1.0.0)
17
- Requires-Dist: yta_fastapi_docker_pydantic_models (>=0.0.1,<1.0.0)
18
- Requires-Dist: yta_httpx (>=0.0.26,<1.0.0)
17
+ Requires-Dist: yta_fastapi_docker_pydantic_models (>=0.0.5,<1.0.0)
18
+ Requires-Dist: yta_httpx (>=0.0.27,<1.0.0)
19
+ Requires-Dist: yta_programming_env (>=0.3.2,<1.0.0)
19
20
  Description-Content-Type: text/markdown
20
21
 
21
22
  # Youtube Autonomous FastAPI Docker API Module
@@ -45,25 +46,36 @@ You can replace the `{id_video}` with this id `e_YBmIxeyUg` for testing.
45
46
  #### POST
46
47
  No endpoints available
47
48
 
48
- ### Ollama
49
+ ### Llama.cpp
49
50
 
50
51
  #### GET
51
52
  No endpoints available
52
53
 
53
54
  #### POST
54
- No endpoints available
55
+ - `/llamacpp/gemma4`
56
+ - `prompt` - The prompt we want to give
57
+ - `output_schema` - The schema we want as the output
55
58
 
56
59
  ### VibeVoice
57
60
 
58
- ### GET
61
+ #### GET
59
62
  - `/vibevoice/speech`
60
63
  - `text` - The text to narrate
61
- - `voice` - The voice we want to use to narrate (`en-Alice_woman`, `en-Carter_man`, `fr-Eva_woman`, etc.). Choose one voice in `demo/voices` or copy your own.
64
+ - `voice` - The voice we want to use to narrate. Choose one voice in `demo/voices` or copy your own.
62
65
  - `/vibevoice/audio`
63
66
  - `text` - The text to narrate
64
67
  - `voice` - The voice we want to use to narrate (`en-Alice_woman`, `en-Carter_man`, `fr-Eva_woman`, etc.) Choose one voice in `demo/voices` or copy your own.
65
68
 
66
- ### POST
69
+ #### POST
70
+ No endpoints available
71
+
72
+ ### Proxy
73
+
74
+ #### GET
75
+ - `/proxy/image`
76
+ - `url` - The url to download the image from.
77
+
78
+ #### POST
67
79
  No endpoints available
68
80
 
69
81
  ---
@@ -25,25 +25,36 @@ You can replace the `{id_video}` with this id `e_YBmIxeyUg` for testing.
25
25
  #### POST
26
26
  No endpoints available
27
27
 
28
- ### Ollama
28
+ ### Llama.cpp
29
29
 
30
30
  #### GET
31
31
  No endpoints available
32
32
 
33
33
  #### POST
34
- No endpoints available
34
+ - `/llamacpp/gemma4`
35
+ - `prompt` - The prompt we want to give
36
+ - `output_schema` - The schema we want as the output
35
37
 
36
38
  ### VibeVoice
37
39
 
38
- ### GET
40
+ #### GET
39
41
  - `/vibevoice/speech`
40
42
  - `text` - The text to narrate
41
- - `voice` - The voice we want to use to narrate (`en-Alice_woman`, `en-Carter_man`, `fr-Eva_woman`, etc.). Choose one voice in `demo/voices` or copy your own.
43
+ - `voice` - The voice we want to use to narrate. Choose one voice in `demo/voices` or copy your own.
42
44
  - `/vibevoice/audio`
43
45
  - `text` - The text to narrate
44
46
  - `voice` - The voice we want to use to narrate (`en-Alice_woman`, `en-Carter_man`, `fr-Eva_woman`, etc.) Choose one voice in `demo/voices` or copy your own.
45
47
 
46
- ### POST
48
+ #### POST
49
+ No endpoints available
50
+
51
+ ### Proxy
52
+
53
+ #### GET
54
+ - `/proxy/image`
55
+ - `url` - The url to download the image from.
56
+
57
+ #### POST
47
58
  No endpoints available
48
59
 
49
60
  ---
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yta-fastapi-docker-api"
3
- version = "0.0.2"
3
+ version = "0.0.4"
4
4
  description = "Youtube Autonomous FastAPI Docker API Module"
5
5
  authors = [
6
6
  {name = "danialcala94", email = "danielalcalavalera@gmail.com"}
@@ -10,11 +10,12 @@ requires-python = ">=3.10,<3.14"
10
10
 
11
11
  [tool.poetry.dependencies]
12
12
  # Mandatory
13
- yta_httpx = { version = ">=0.0.26,<1.0.0", optional = false }
13
+ yta_httpx = { version = ">=0.0.27,<1.0.0", optional = false }
14
14
  fastapi = { version = ">=0.124.4,<9999.0.0", optional = false }
15
- uvicorn = { version = ">=0.48.0,<9999.0.0", optional = false }
16
- yta_fastapi_docker_pydantic_models = { version = ">=0.0.1,<1.0.0", optional = false }
15
+ uvicorn = { version = ">=0.49.0,<9999.0.0", optional = false }
16
+ yta_fastapi_docker_pydantic_models = { version = ">=0.0.5,<1.0.0", optional = false }
17
17
  yta_fastapi_docker_common = { version = ">=0.0.14,<1.0.0", optional = false }
18
+ yta_programming_env = { version = ">=0.3.2,<1.0.0", optional = false }
18
19
  # Optional
19
20
 
20
21
  [tool.poetry]
@@ -22,7 +23,7 @@ packages = [{include = "yta_fastapi_docker_api", from = "src"}]
22
23
 
23
24
  [tool.poetry.group.dev.dependencies]
24
25
  pytest = "^8.3.5"
25
- yta_testing = ">=0.3.4"
26
+ yta_testing = ">=0.3.6"
26
27
 
27
28
  [tool.pytest.ini_options]
28
29
  markers = [
@@ -0,0 +1,28 @@
1
+ from yta_fastapi_docker_api.app.routers import router as general_router
2
+ from yta_fastapi_docker_api.app.routers.youtube import router as youtube_router
3
+ from yta_fastapi_docker_api.app.routers.llamacpp import router as llamacpp_router
4
+ from yta_fastapi_docker_api.app.routers.vibevoice import router as vibevoice_router
5
+ from yta_fastapi_docker_api.app.routers.stock import router as stock_router
6
+ from yta_fastapi_docker_api.app.routers.proxy import router as proxy_router
7
+ from fastapi.middleware.cors import CORSMiddleware
8
+ from fastapi import FastAPI
9
+
10
+
11
+ app = FastAPI()
12
+
13
+ # Added for the proxy-image endpoint
14
+ app.add_middleware(
15
+ CORSMiddleware,
16
+ allow_origins=["*"],
17
+ allow_credentials=False,
18
+ allow_methods=["*"],
19
+ allow_headers=["*"],
20
+ )
21
+
22
+ # Include all the routers we have
23
+ app.include_router(general_router)
24
+ app.include_router(youtube_router)
25
+ app.include_router(llamacpp_router)
26
+ app.include_router(vibevoice_router)
27
+ app.include_router(stock_router)
28
+ app.include_router(proxy_router)
@@ -15,6 +15,7 @@ def router_index(
15
15
  url = "/docs"
16
16
  )
17
17
 
18
+
18
19
  @router.get('/check-status')
19
20
  def route_check_status(
20
21
  ) -> JSONResponse:
@@ -0,0 +1,31 @@
1
+ from yta_fastapi_docker_pydantic_models.llamacpp import GemmaRequest
2
+ from yta_fastapi_docker_common import proxy_stream_endpoint
3
+ from yta_programming_env import Environment
4
+ from fastapi import APIRouter
5
+
6
+
7
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('LLAMACPP_FASTAPI_DOCKER_ENDPOINT')
8
+ PREFIX = f'/llamacpp'
9
+
10
+ router = APIRouter(
11
+ prefix = PREFIX
12
+ )
13
+
14
+ @router.post('/gemma4')
15
+ async def post_llamacpp_gemma4(
16
+ request: GemmaRequest
17
+ ) -> 'StreamingResponse':
18
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/llamacpp/gemma4'
19
+
20
+ payload = request.model_dump()
21
+
22
+ """
23
+ {'request': {'prompt': 'Hola', 'output_schema': None}}
24
+ """
25
+ return await proxy_stream_endpoint(
26
+ url = endpoint_url,
27
+ method = 'POST',
28
+ json = payload,
29
+ do_close_response = True,
30
+ do_close_client = True
31
+ )
@@ -0,0 +1,30 @@
1
+ from fastapi import APIRouter
2
+ from fastapi.responses import Response
3
+ from yta_httpx.client import HttpClient
4
+
5
+
6
+ PREFIX = f'/proxy'
7
+
8
+ router = APIRouter(
9
+ prefix = PREFIX
10
+ )
11
+
12
+
13
+ @router.get('/image')
14
+ async def router_proxy_image(
15
+ url: str
16
+ ) -> Response:
17
+ async with HttpClient(...) as http_client:
18
+ response = await http_client.get.complete(
19
+ url = url
20
+ )
21
+
22
+ content_type = response.headers.get(
23
+ 'Content-Type',
24
+ 'application/octet-stream'
25
+ )
26
+
27
+ return Response(
28
+ content = response.content,
29
+ media_type = content_type
30
+ )
@@ -1,17 +1,11 @@
1
+ from yta_fastapi_docker_common import proxy_stream_endpoint
2
+ from yta_programming_env import Environment
1
3
  from fastapi import APIRouter
2
4
  from fastapi.responses import StreamingResponse
3
- from yta_fastapi_docker_common import proxy_stream_endpoint
4
5
  from starlette.responses import StreamingResponse
5
6
 
6
7
 
7
- # TODO: Get this from a .env, should point to the container
8
- CONTAINER_API_ENDPOINT_URL = "http://yta_fastapi_docker_stock:8000"
9
- # CONTAINER_API_ENDPOINT_URL = "http://localhost:8002"
10
- """
11
- This is just for manual testing when the other
12
- fastapi dockers are exposed.
13
- """
14
-
8
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('STOCK_FASTAPI_DOCKER_ENDPOINT')
15
9
  PREFIX = f'/stock'
16
10
 
17
11
  router = APIRouter(
@@ -1,4 +1,5 @@
1
1
  from yta_fastapi_docker_common import proxy_stream_endpoint
2
+ from yta_programming_env import Environment
2
3
  from fastapi import APIRouter
3
4
  from fastapi.responses import StreamingResponse
4
5
  from pydantic import BaseModel
@@ -13,14 +14,7 @@ class CreateVibevoiceAudio(BaseModel):
13
14
  voice: str
14
15
 
15
16
 
16
- # TODO: Get this from a .env, should point to the container
17
- CONTAINER_API_ENDPOINT_URL = 'http://yta_fastapi_docker_vibevoice:8001'
18
- # CONTAINER_API_ENDPOINT_URL = 'http://localhost:8001'
19
- """
20
- This is just for manual testing when the other
21
- fastapi dockers are exposed.
22
- """
23
-
17
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('VIBEVOICE_FASTAPI_DOCKER_ENDPOINT')
24
18
  PREFIX = f'/vibevoice'
25
19
 
26
20
  router = APIRouter(
@@ -1,17 +1,11 @@
1
- from fastapi import APIRouter
2
1
  from yta_fastapi_docker_common import proxy_stream_endpoint
2
+ from yta_programming_env import Environment
3
+ from fastapi import APIRouter
3
4
  from yta_httpx.client import HttpClient
4
5
  from fastapi.responses import StreamingResponse, JSONResponse
5
6
 
6
7
 
7
- # TODO: Get this from a .env, should point to the container
8
- CONTAINER_API_ENDPOINT_URL = 'http://yta_fastapi_docker_youtube:8000'
9
- # CONTAINER_API_ENDPOINT_URL = 'http://localhost:8002'
10
- """
11
- This is just for manual testing when the other
12
- fastapi dockers are exposed.
13
- """
14
-
8
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('YOUTUBE_FASTAPI_DOCKER_ENDPOINT')
15
9
  PREFIX = f'/youtube'
16
10
 
17
11
  router = APIRouter(
@@ -1,17 +0,0 @@
1
- from yta_fastapi_docker_api.app.routers import router as general_router
2
- from yta_fastapi_docker_api.app.routers.youtube import router as youtube_router
3
- from yta_fastapi_docker_api.app.routers.ollama import router as ollama_router
4
- from yta_fastapi_docker_api.app.routers.vibevoice import router as vibevoice_router
5
- from yta_fastapi_docker_api.app.routers.stock import router as stock_router
6
- from fastapi import FastAPI
7
-
8
-
9
- app = FastAPI()
10
-
11
- # Include all the routers we have
12
- app.include_router(general_router)
13
- app.include_router(youtube_router)
14
- # TODO: By now ollama needs more work to be stable
15
- # app.include_router(ollama_router)
16
- app.include_router(vibevoice_router)
17
- app.include_router(stock_router)
@@ -1,126 +0,0 @@
1
- from yta_fastapi_docker_pydantic_models.ollama import Prompt
2
- from fastapi import APIRouter, Body
3
- from fastapi.responses import JSONResponse, Response
4
-
5
- # import requests
6
-
7
-
8
- # TODO: Get this from a .env, should point to the container
9
- CONTAINER_API_ENDPOINT_URL = 'http://yta_fastapi_docker_ollama:8000'
10
- CONTAINER_API_ENDPOINT_URL = "http://localhost:8002"
11
- """
12
- This is just for manual testing when the other
13
- fastapi dockers are exposed.
14
- """
15
-
16
- PREFIX = f'/ollama'
17
-
18
- router = APIRouter(
19
- prefix = PREFIX
20
- )
21
-
22
- """
23
- TODO: The 'prompt' is a class in the 'yta_fastapi_docker_ollama'
24
- but I don't want to duplicate code and I'm not importing
25
- any module to be able to bring it here...
26
- """
27
-
28
- @router.post('/agents/transcription-cleaner')
29
- def get_agents_transcription_cleaner(
30
- prompt: Prompt
31
- ) -> JSONResponse:
32
- endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/ollama/agents/transcription-cleaner'
33
-
34
- # This below if pydantic v2
35
- payload = prompt.model_dump()
36
- # This below if pydantic v1
37
- # payload = request.dict()
38
-
39
- resp = requests.post(
40
- url = endpoint_url,
41
- json = payload,
42
- stream = True
43
- )
44
-
45
- excluded_headers = {
46
- "content-length",
47
- "transfer-encoding",
48
- "connection",
49
- "content-encoding"
50
- }
51
-
52
- headers = {
53
- k: v for k, v in resp.headers.items()
54
- if k.lower() not in excluded_headers
55
- }
56
-
57
- # TODO: We need to handle errors that are not JSON
58
- content_type = resp.headers.get("content-type")
59
-
60
- if "application/json" in content_type:
61
- return JSONResponse(
62
- content = resp.json(),
63
- status_code = resp.status_code,
64
- headers = headers
65
- )
66
-
67
- """
68
- If I don't have the model it is just returning an
69
- 'Internal Server Error' message, but not that we
70
- don't have the specific model...
71
- """
72
- return Response(
73
- # bytes (?)
74
- content = resp.content,
75
- status_code = resp.status_code,
76
- media_type = resp.headers.get("content-type"),
77
- headers = headers
78
- )
79
-
80
- """
81
- This method below was not using the pydantic model
82
- but was working correctly. Leave it here until the
83
- one with the model is working.
84
- """
85
- # @router.post('/agents/transcription-cleaner')
86
- # def get_agents_transcription_cleaner(
87
- # # prompt: Prompt
88
- # # prompt: str
89
- # payload: dict = Body(...)
90
- # ) -> JSONResponse:
91
- # print('---')
92
- # print(payload)
93
- # print('---')
94
- # response = requests.post(
95
- # url = f'{OLLAMA_URL}/ollama/agents/transcription-cleaner',
96
- # json = payload
97
- # )
98
- # print('@@@')
99
- # print(response)
100
- # print('@@@')
101
-
102
- # content_type = response.headers.get("content-type", "")
103
-
104
- # if "application/json" in content_type:
105
- # return JSONResponse(
106
- # content = response.json(),
107
- # status_code = response.status_code
108
- # )
109
-
110
- # """
111
- # If I don't have the model it is just returning an
112
- # 'Internal Server Error' message, but not that we
113
- # don't have the specific model...
114
- # """
115
- # # TODO:
116
- # return Response(
117
- # # bytes (?)
118
- # content = response.content,
119
- # status_code = response.status_code,
120
- # media_type = response.headers.get("content-type")
121
- # )
122
-
123
- # return JSONResponse(
124
- # content = response.json(),
125
- # status_code = response.status_code
126
- # )