yta-fastapi-docker-api 0.0.2__tar.gz → 0.0.3__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.
Files changed (16) hide show
  1. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/PKG-INFO +17 -7
  2. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/README.md +12 -3
  3. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/pyproject.toml +6 -5
  4. yta_fastapi_docker_api-0.0.3/src/yta_fastapi_docker_api/app/main.py +28 -0
  5. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/routers/__init__.py +1 -0
  6. yta_fastapi_docker_api-0.0.3/src/yta_fastapi_docker_api/app/routers/llamacpp.py +31 -0
  7. yta_fastapi_docker_api-0.0.3/src/yta_fastapi_docker_api/app/routers/ollama.py +148 -0
  8. yta_fastapi_docker_api-0.0.3/src/yta_fastapi_docker_api/app/routers/proxy.py +30 -0
  9. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/routers/stock.py +3 -9
  10. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/routers/vibevoice.py +2 -8
  11. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/routers/youtube.py +3 -9
  12. yta_fastapi_docker_api-0.0.2/src/yta_fastapi_docker_api/app/main.py +0 -17
  13. yta_fastapi_docker_api-0.0.2/src/yta_fastapi_docker_api/app/routers/ollama.py +0 -126
  14. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/LICENSE +0 -0
  15. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/__init__.py +0 -0
  16. {yta_fastapi_docker_api-0.0.2 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/__init__.py +0 -0
@@ -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.3
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
@@ -55,15 +56,24 @@ No endpoints available
55
56
 
56
57
  ### VibeVoice
57
58
 
58
- ### GET
59
+ #### GET
59
60
  - `/vibevoice/speech`
60
61
  - `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.
62
+ - `voice` - The voice we want to use to narrate. Choose one voice in `demo/voices` or copy your own.
62
63
  - `/vibevoice/audio`
63
64
  - `text` - The text to narrate
64
65
  - `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
66
 
66
- ### POST
67
+ #### POST
68
+ No endpoints available
69
+
70
+ ### Proxy
71
+
72
+ #### GET
73
+ - `/proxy/image`
74
+ - `url` - The url to download the image from.
75
+
76
+ #### POST
67
77
  No endpoints available
68
78
 
69
79
  ---
@@ -35,15 +35,24 @@ No endpoints available
35
35
 
36
36
  ### VibeVoice
37
37
 
38
- ### GET
38
+ #### GET
39
39
  - `/vibevoice/speech`
40
40
  - `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.
41
+ - `voice` - The voice we want to use to narrate. Choose one voice in `demo/voices` or copy your own.
42
42
  - `/vibevoice/audio`
43
43
  - `text` - The text to narrate
44
44
  - `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
45
 
46
- ### POST
46
+ #### POST
47
+ No endpoints available
48
+
49
+ ### Proxy
50
+
51
+ #### GET
52
+ - `/proxy/image`
53
+ - `url` - The url to download the image from.
54
+
55
+ #### POST
47
56
  No endpoints available
48
57
 
49
58
  ---
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yta-fastapi-docker-api"
3
- version = "0.0.2"
3
+ version = "0.0.3"
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,148 @@
1
+ # from yta_fastapi_docker_pydantic_models.ollama import Prompt
2
+ # from yta_fastapi_docker_common import proxy_stream_endpoint
3
+ # from yta_programming_env import Environment
4
+ # from yta_httpx.client import HttpClient
5
+ # from fastapi import APIRouter
6
+ # from fastapi.responses import JSONResponse, Response
7
+
8
+
9
+ # CONTAINER_API_ENDPOINT_URL = Environment.get_env('OLLAMA_DOCKER_ENDPOINT')
10
+ # PREFIX = f'/ollama'
11
+
12
+ # router = APIRouter(
13
+ # prefix = PREFIX
14
+ # )
15
+
16
+ # """
17
+ # TODO: The 'prompt' is a class in the 'yta_fastapi_docker_ollama'
18
+ # but I don't want to duplicate code and I'm not importing
19
+ # any module to be able to bring it here...
20
+ # """
21
+
22
+ # @router.post('/gemma4')
23
+ # async def post_ollama_gemma4(
24
+ # prompt_system: Prompt,
25
+ # prompt: Prompt
26
+ # ) -> 'StreamingResponse':
27
+ # endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/ollama/gemma4'
28
+
29
+ # payload = {
30
+ # 'prompt_system': prompt_system.model_dump(),
31
+ # 'prompt': prompt.model_dump()
32
+ # }
33
+
34
+ # return await proxy_stream_endpoint(
35
+ # url = endpoint_url,
36
+ # method = 'POST',
37
+ # json = payload,
38
+ # do_close_response = True,
39
+ # do_close_client = True
40
+ # )
41
+
42
+ # @router.post('/agents/transcription-cleaner')
43
+ # async def post_ollama_agents_transcription_cleaner(
44
+ # prompt: Prompt
45
+ # ) -> 'StreamingResponse':
46
+ # endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/ollama/agents/transcription-cleaner'
47
+
48
+ # # This below if pydantic v2
49
+ # payload = prompt.model_dump()
50
+ # # This below if pydantic v1
51
+ # # payload = request.dict()
52
+
53
+ # return await proxy_stream_endpoint(
54
+ # url = endpoint_url,
55
+ # method = 'POST',
56
+ # json = payload,
57
+ # do_close_response = True,
58
+ # do_close_client = True
59
+ # )
60
+
61
+ # async with HttpClient(...) as http_client:
62
+ # response = await http_client.post.stream(
63
+ # url = endpoint_url,
64
+ # json = payload
65
+ # )
66
+
67
+ # excluded_headers = {
68
+ # "content-length",
69
+ # "transfer-encoding",
70
+ # "connection",
71
+ # "content-encoding"
72
+ # }
73
+
74
+ # headers = {
75
+ # k: v for k, v in response.headers.items()
76
+ # if k.lower() not in excluded_headers
77
+ # }
78
+
79
+ # # TODO: We need to handle errors that are not JSON
80
+ # content_type = resp.headers.get("content-type")
81
+
82
+ # if "application/json" in content_type:
83
+ # return JSONResponse(
84
+ # content = resp.json(),
85
+ # status_code = resp.status_code,
86
+ # headers = headers
87
+ # )
88
+
89
+ # """
90
+ # If I don't have the model it is just returning an
91
+ # 'Internal Server Error' message, but not that we
92
+ # don't have the specific model...
93
+ # """
94
+ # return Response(
95
+ # # bytes (?)
96
+ # content = resp.content,
97
+ # status_code = resp.status_code,
98
+ # media_type = resp.headers.get("content-type"),
99
+ # headers = headers
100
+ # )
101
+
102
+ # """
103
+ # This method below was not using the pydantic model
104
+ # but was working correctly. Leave it here until the
105
+ # one with the model is working.
106
+ # """
107
+ # # @router.post('/agents/transcription-cleaner')
108
+ # # def get_agents_transcription_cleaner(
109
+ # # # prompt: Prompt
110
+ # # # prompt: str
111
+ # # payload: dict = Body(...)
112
+ # # ) -> JSONResponse:
113
+ # # print('---')
114
+ # # print(payload)
115
+ # # print('---')
116
+ # # response = requests.post(
117
+ # # url = f'{OLLAMA_URL}/ollama/agents/transcription-cleaner',
118
+ # # json = payload
119
+ # # )
120
+ # # print('@@@')
121
+ # # print(response)
122
+ # # print('@@@')
123
+
124
+ # # content_type = response.headers.get("content-type", "")
125
+
126
+ # # if "application/json" in content_type:
127
+ # # return JSONResponse(
128
+ # # content = response.json(),
129
+ # # status_code = response.status_code
130
+ # # )
131
+
132
+ # # """
133
+ # # If I don't have the model it is just returning an
134
+ # # 'Internal Server Error' message, but not that we
135
+ # # don't have the specific model...
136
+ # # """
137
+ # # # TODO:
138
+ # # return Response(
139
+ # # # bytes (?)
140
+ # # content = response.content,
141
+ # # status_code = response.status_code,
142
+ # # media_type = response.headers.get("content-type")
143
+ # # )
144
+
145
+ # # return JSONResponse(
146
+ # # content = response.json(),
147
+ # # status_code = response.status_code
148
+ # # )
@@ -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
- # )