yta-fastapi-docker-api 0.0.1__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 (18) hide show
  1. yta_fastapi_docker_api-0.0.1/README.md → yta_fastapi_docker_api-0.0.3/PKG-INFO +100 -57
  2. yta_fastapi_docker_api-0.0.1/PKG-INFO → yta_fastapi_docker_api-0.0.3/README.md +79 -72
  3. yta_fastapi_docker_api-0.0.3/pyproject.toml +36 -0
  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.1 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/routers/__init__.py +9 -1
  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.3/src/yta_fastapi_docker_api/app/routers/stock.py +68 -0
  10. yta_fastapi_docker_api-0.0.3/src/yta_fastapi_docker_api/app/routers/vibevoice.py +93 -0
  11. yta_fastapi_docker_api-0.0.3/src/yta_fastapi_docker_api/app/routers/youtube.py +87 -0
  12. yta_fastapi_docker_api-0.0.1/pyproject.toml +0 -32
  13. yta_fastapi_docker_api-0.0.1/src/yta_fastapi_docker_api/app/main.py +0 -12
  14. yta_fastapi_docker_api-0.0.1/src/yta_fastapi_docker_api/app/routers/ollama.py +0 -63
  15. yta_fastapi_docker_api-0.0.1/src/yta_fastapi_docker_api/app/routers/youtube.py +0 -33
  16. {yta_fastapi_docker_api-0.0.1 → yta_fastapi_docker_api-0.0.3}/LICENSE +0 -0
  17. {yta_fastapi_docker_api-0.0.1 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/__init__.py +0 -0
  18. {yta_fastapi_docker_api-0.0.1 → yta_fastapi_docker_api-0.0.3}/src/yta_fastapi_docker_api/app/__init__.py +0 -0
@@ -1,57 +1,100 @@
1
- # Youtube Autonomous FastAPI Docker API Module
2
-
3
- The module that is handled by a docker container to isolate the environment we need for each purpose, exposed by a FastAPI that allows asking for the specific resources.
4
-
5
- This project is using `poetry` to handle the dependencies and the virtual environment, and `docker` to manage the specific python version and all the code with the app to be executed.
6
-
7
- This is the entry point API for all the functionality our Youtube Autonomous system is providing. This API will delegate in other API-containers to get what is needed.
8
-
9
- The module that is providing the functionality related to the Youtube platform (downloading, getting metadata, etc.) through a FastAPI that is included and isolated in a Docker container but exposed to the internal and general FastAPI.
10
-
11
- ## Endpoints
12
-
13
- ### Youtube
14
-
15
- #### GET
16
- - `/youtube/videos/{id_video}`
17
- - `/youtube/videos/{id_video}/data`
18
- - `/youtube/videos/{id_video}/download-best-quality`
19
- - `/youtube/videos/{id_video}/download-lowest-quality`
20
- - `/youtube/videos/{id_video}/download-1080`
21
-
22
- You can replace the `{id_video}` with this id `e_YBmIxeyUg` for testing.
23
-
24
- #### POST
25
- No hay endpoints por el momento
26
-
27
- ### Ollama
28
-
29
- #### GET
30
- No hay endpoints por el momento
31
-
32
- #### POST
33
- No hay endpoints por el momento
34
-
35
-
36
- ---
37
-
38
-
39
- ### Other Instructions
40
- #### Generate the image
41
- We need to generate the docker image with all the things we need to be able to run the app inside.
42
- - Use the `$ docker build --no-cache -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file and ignoring the caché. This will download the `python 3.12.x` version, install the dependencies and copy the code. Use this if any dependency has changed since the last time. If you are just updating the code, you can use the following instead.
43
- - Use the `$ docker build -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file. It will download the `python 3.12.x` version, install the dependencies and copy the code, each of these steps only if needed (the cache will make it be ignore if it didn't change).
44
-
45
- #### Run the container
46
- We need to run the container, so it will be mounted and the app will be runing and ready to use.
47
- - Use the command `$ docker rm -f {LIBRARY_NAME} 2>nul` to remove the previous container if existing, so we are able to mount it again from zero.
48
- - Use the command `$ docker run -d -p "%port%":8000 --name {LIBRARY_NAME} {LIBRARY_NAME}` to run and mount the container and make the app be ready to use.
49
-
50
- You can also execute the `run_server_docker.bat` to do all together using the caché (faster).
51
-
52
- ---
53
-
54
- The docker will run uvicorn in the port 8000 internally, but our navigator will redirect the 8001 to that one, so we can have different docker containers working at the same time to provide different services using the same base (uvicorn + fastapi).
55
-
56
- ### Other details
57
- - To run the project locally, execute the `run_server.bat` file or use `$ poetry run uvicorn yta_fastapi_docker_base.app.main:app --reload` directly.
1
+ Metadata-Version: 2.4
2
+ Name: yta-fastapi-docker-api
3
+ Version: 0.0.3
4
+ Summary: Youtube Autonomous FastAPI Docker API Module
5
+ License-File: LICENSE
6
+ Author: danialcala94
7
+ Author-email: danielalcalavalera@gmail.com
8
+ Requires-Python: >=3.10,<3.14
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: fastapi (>=0.124.4,<9999.0.0)
15
+ Requires-Dist: uvicorn (>=0.49.0,<9999.0.0)
16
+ Requires-Dist: yta_fastapi_docker_common (>=0.0.14,<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)
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Youtube Autonomous FastAPI Docker API Module
23
+
24
+ The module that is handled by a docker container to isolate the environment we need for each purpose, exposed by a FastAPI that allows asking for the specific resources.
25
+
26
+ This project is using `poetry` to handle the dependencies and the virtual environment, and `docker` to manage the specific python version and all the code with the app to be executed.
27
+
28
+ This is the entry point API for all the functionality our Youtube Autonomous system is providing. This API will delegate in other API-containers to get what is needed. Only this API is exposed, and all the other containers have another one (for internal use only).
29
+
30
+ ## Steps to do
31
+ Considering that we have a `docker-compose.yml` that includes the different services, we have to copy the VibeVoice voices to the `demo/voices` folder to let the internal container detect them to be used. We can have any custom voice we want, that will be autodetected, such as `demo/voices/fr-Eva_woman.wav`.
32
+
33
+ ## Endpoints
34
+
35
+ ### Youtube
36
+
37
+ #### GET
38
+ - `/youtube/videos/{id_video}`
39
+ - `/youtube/videos/{id_video}/data`
40
+ - `/youtube/videos/{id_video}/download-best-quality`
41
+ - `/youtube/videos/{id_video}/download-lowest-quality`
42
+ - `/youtube/videos/{id_video}/download-1080`
43
+
44
+ You can replace the `{id_video}` with this id `e_YBmIxeyUg` for testing.
45
+
46
+ #### POST
47
+ No endpoints available
48
+
49
+ ### Ollama
50
+
51
+ #### GET
52
+ No endpoints available
53
+
54
+ #### POST
55
+ No endpoints available
56
+
57
+ ### VibeVoice
58
+
59
+ #### GET
60
+ - `/vibevoice/speech`
61
+ - `text` - The text to narrate
62
+ - `voice` - The voice we want to use to narrate. Choose one voice in `demo/voices` or copy your own.
63
+ - `/vibevoice/audio`
64
+ - `text` - The text to narrate
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.
66
+
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
77
+ No endpoints available
78
+
79
+ ---
80
+
81
+
82
+ ### Other Instructions
83
+ #### Generate the image
84
+ We need to generate the docker image with all the things we need to be able to run the app inside.
85
+ - Use the `$ docker build --no-cache -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file and ignoring the caché. This will download the `python 3.12.x` version, install the dependencies and copy the code. Use this if any dependency has changed since the last time. If you are just updating the code, you can use the following instead.
86
+ - Use the `$ docker build -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file. It will download the `python 3.12.x` version, install the dependencies and copy the code, each of these steps only if needed (the cache will make it be ignore if it didn't change).
87
+
88
+ #### Run the container
89
+ We need to run the container, so it will be mounted and the app will be runing and ready to use.
90
+ - Use the command `$ docker rm -f {LIBRARY_NAME} 2>nul` to remove the previous container if existing, so we are able to mount it again from zero.
91
+ - Use the command `$ docker run -d -p "%port%":8000 --name {LIBRARY_NAME} {LIBRARY_NAME}` to run and mount the container and make the app be ready to use.
92
+
93
+ You can also execute the `run_server_docker.bat` to do all together using the caché (faster).
94
+
95
+ ---
96
+
97
+ The docker will run `uvicorn` in the port `8000` internally, but our navigator will redirect the `8001` to that one, so we can have different docker containers working at the same time to provide different services using the same base (`uvicorn` + `fastapi`).
98
+
99
+ ### Other details
100
+ - To run the project locally, execute the `run_server.bat` file or use `$ poetry run uvicorn yta_fastapi_docker_base.app.main:app --reload` directly.
@@ -1,72 +1,79 @@
1
- Metadata-Version: 2.4
2
- Name: yta-fastapi-docker-api
3
- Version: 0.0.1
4
- Summary: Youtube Autonomous FastAPI Docker API Module
5
- License-File: LICENSE
6
- Author: danialcala94
7
- Author-email: danielalcalavalera@gmail.com
8
- Requires-Python: ==3.12.*
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.12
11
- Requires-Dist: fastapi (>=0.0.1,<9999.0.0)
12
- Requires-Dist: requests (>=0.0.1,<9999.0.0)
13
- Requires-Dist: uvicorn (>=0.0.1,<9999.0.0)
14
- Description-Content-Type: text/markdown
15
-
16
- # Youtube Autonomous FastAPI Docker API Module
17
-
18
- The module that is handled by a docker container to isolate the environment we need for each purpose, exposed by a FastAPI that allows asking for the specific resources.
19
-
20
- This project is using `poetry` to handle the dependencies and the virtual environment, and `docker` to manage the specific python version and all the code with the app to be executed.
21
-
22
- This is the entry point API for all the functionality our Youtube Autonomous system is providing. This API will delegate in other API-containers to get what is needed.
23
-
24
- The module that is providing the functionality related to the Youtube platform (downloading, getting metadata, etc.) through a FastAPI that is included and isolated in a Docker container but exposed to the internal and general FastAPI.
25
-
26
- ## Endpoints
27
-
28
- ### Youtube
29
-
30
- #### GET
31
- - `/youtube/videos/{id_video}`
32
- - `/youtube/videos/{id_video}/data`
33
- - `/youtube/videos/{id_video}/download-best-quality`
34
- - `/youtube/videos/{id_video}/download-lowest-quality`
35
- - `/youtube/videos/{id_video}/download-1080`
36
-
37
- You can replace the `{id_video}` with this id `e_YBmIxeyUg` for testing.
38
-
39
- #### POST
40
- No hay endpoints por el momento
41
-
42
- ### Ollama
43
-
44
- #### GET
45
- No hay endpoints por el momento
46
-
47
- #### POST
48
- No hay endpoints por el momento
49
-
50
-
51
- ---
52
-
53
-
54
- ### Other Instructions
55
- #### Generate the image
56
- We need to generate the docker image with all the things we need to be able to run the app inside.
57
- - Use the `$ docker build --no-cache -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file and ignoring the caché. This will download the `python 3.12.x` version, install the dependencies and copy the code. Use this if any dependency has changed since the last time. If you are just updating the code, you can use the following instead.
58
- - Use the `$ docker build -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file. It will download the `python 3.12.x` version, install the dependencies and copy the code, each of these steps only if needed (the cache will make it be ignore if it didn't change).
59
-
60
- #### Run the container
61
- We need to run the container, so it will be mounted and the app will be runing and ready to use.
62
- - Use the command `$ docker rm -f {LIBRARY_NAME} 2>nul` to remove the previous container if existing, so we are able to mount it again from zero.
63
- - Use the command `$ docker run -d -p "%port%":8000 --name {LIBRARY_NAME} {LIBRARY_NAME}` to run and mount the container and make the app be ready to use.
64
-
65
- You can also execute the `run_server_docker.bat` to do all together using the caché (faster).
66
-
67
- ---
68
-
69
- The docker will run uvicorn in the port 8000 internally, but our navigator will redirect the 8001 to that one, so we can have different docker containers working at the same time to provide different services using the same base (uvicorn + fastapi).
70
-
71
- ### Other details
72
- - To run the project locally, execute the `run_server.bat` file or use `$ poetry run uvicorn yta_fastapi_docker_base.app.main:app --reload` directly.
1
+ # Youtube Autonomous FastAPI Docker API Module
2
+
3
+ The module that is handled by a docker container to isolate the environment we need for each purpose, exposed by a FastAPI that allows asking for the specific resources.
4
+
5
+ This project is using `poetry` to handle the dependencies and the virtual environment, and `docker` to manage the specific python version and all the code with the app to be executed.
6
+
7
+ This is the entry point API for all the functionality our Youtube Autonomous system is providing. This API will delegate in other API-containers to get what is needed. Only this API is exposed, and all the other containers have another one (for internal use only).
8
+
9
+ ## Steps to do
10
+ Considering that we have a `docker-compose.yml` that includes the different services, we have to copy the VibeVoice voices to the `demo/voices` folder to let the internal container detect them to be used. We can have any custom voice we want, that will be autodetected, such as `demo/voices/fr-Eva_woman.wav`.
11
+
12
+ ## Endpoints
13
+
14
+ ### Youtube
15
+
16
+ #### GET
17
+ - `/youtube/videos/{id_video}`
18
+ - `/youtube/videos/{id_video}/data`
19
+ - `/youtube/videos/{id_video}/download-best-quality`
20
+ - `/youtube/videos/{id_video}/download-lowest-quality`
21
+ - `/youtube/videos/{id_video}/download-1080`
22
+
23
+ You can replace the `{id_video}` with this id `e_YBmIxeyUg` for testing.
24
+
25
+ #### POST
26
+ No endpoints available
27
+
28
+ ### Ollama
29
+
30
+ #### GET
31
+ No endpoints available
32
+
33
+ #### POST
34
+ No endpoints available
35
+
36
+ ### VibeVoice
37
+
38
+ #### GET
39
+ - `/vibevoice/speech`
40
+ - `text` - The text to narrate
41
+ - `voice` - The voice we want to use to narrate. Choose one voice in `demo/voices` or copy your own.
42
+ - `/vibevoice/audio`
43
+ - `text` - The text to narrate
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
+
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
56
+ No endpoints available
57
+
58
+ ---
59
+
60
+
61
+ ### Other Instructions
62
+ #### Generate the image
63
+ We need to generate the docker image with all the things we need to be able to run the app inside.
64
+ - Use the `$ docker build --no-cache -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file and ignoring the caché. This will download the `python 3.12.x` version, install the dependencies and copy the code. Use this if any dependency has changed since the last time. If you are just updating the code, you can use the following instead.
65
+ - Use the `$ docker build -t {LIBRARY_NAME} .` command to generate the Docker image by using the `dockerfile` file. It will download the `python 3.12.x` version, install the dependencies and copy the code, each of these steps only if needed (the cache will make it be ignore if it didn't change).
66
+
67
+ #### Run the container
68
+ We need to run the container, so it will be mounted and the app will be runing and ready to use.
69
+ - Use the command `$ docker rm -f {LIBRARY_NAME} 2>nul` to remove the previous container if existing, so we are able to mount it again from zero.
70
+ - Use the command `$ docker run -d -p "%port%":8000 --name {LIBRARY_NAME} {LIBRARY_NAME}` to run and mount the container and make the app be ready to use.
71
+
72
+ You can also execute the `run_server_docker.bat` to do all together using the caché (faster).
73
+
74
+ ---
75
+
76
+ The docker will run `uvicorn` in the port `8000` internally, but our navigator will redirect the `8001` to that one, so we can have different docker containers working at the same time to provide different services using the same base (`uvicorn` + `fastapi`).
77
+
78
+ ### Other details
79
+ - To run the project locally, execute the `run_server.bat` file or use `$ poetry run uvicorn yta_fastapi_docker_base.app.main:app --reload` directly.
@@ -0,0 +1,36 @@
1
+ [project]
2
+ name = "yta-fastapi-docker-api"
3
+ version = "0.0.3"
4
+ description = "Youtube Autonomous FastAPI Docker API Module"
5
+ authors = [
6
+ {name = "danialcala94", email = "danielalcalavalera@gmail.com"}
7
+ ]
8
+ readme = "README.md"
9
+ requires-python = ">=3.10,<3.14"
10
+
11
+ [tool.poetry.dependencies]
12
+ # Mandatory
13
+ yta_httpx = { version = ">=0.0.27,<1.0.0", optional = false }
14
+ fastapi = { version = ">=0.124.4,<9999.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
+ 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 }
19
+ # Optional
20
+
21
+ [tool.poetry]
22
+ packages = [{include = "yta_fastapi_docker_api", from = "src"}]
23
+
24
+ [tool.poetry.group.dev.dependencies]
25
+ pytest = "^8.3.5"
26
+ yta_testing = ">=0.3.6"
27
+
28
+ [tool.pytest.ini_options]
29
+ markers = [
30
+ "mandatory: mandatory tests for release",
31
+ "additional: exhaustive and demanding tests"
32
+ ]
33
+
34
+ [build-system]
35
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
36
+ build-backend = "poetry.core.masonry.api"
@@ -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)
@@ -1,5 +1,5 @@
1
1
  from fastapi import APIRouter
2
- from fastapi.responses import JSONResponse
2
+ from fastapi.responses import JSONResponse, RedirectResponse
3
3
 
4
4
 
5
5
  PREFIX = f''
@@ -8,6 +8,14 @@ router = APIRouter(
8
8
  prefix = PREFIX
9
9
  )
10
10
 
11
+ @router.get('/')
12
+ def router_index(
13
+ ) -> RedirectResponse:
14
+ return RedirectResponse(
15
+ url = "/docs"
16
+ )
17
+
18
+
11
19
  @router.get('/check-status')
12
20
  def route_check_status(
13
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
+ )
@@ -0,0 +1,68 @@
1
+ from yta_fastapi_docker_common import proxy_stream_endpoint
2
+ from yta_programming_env import Environment
3
+ from fastapi import APIRouter
4
+ from fastapi.responses import StreamingResponse
5
+ from starlette.responses import StreamingResponse
6
+
7
+
8
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('STOCK_FASTAPI_DOCKER_ENDPOINT')
9
+ PREFIX = f'/stock'
10
+
11
+ router = APIRouter(
12
+ prefix = PREFIX
13
+ )
14
+
15
+
16
+
17
+ # TODO: This will be removed soon, it is just
18
+ # to test that is working by avoiding using
19
+ # real reqeusts to the stock providers
20
+ @router.get('/test')
21
+ async def get_stock_test_image(
22
+ query: str
23
+ ) -> StreamingResponse:
24
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/stock/test'
25
+
26
+ return await proxy_stream_endpoint(
27
+ url = endpoint_url,
28
+ method = 'GET',
29
+ params = {
30
+ 'query': query
31
+ },
32
+ do_close_response = True,
33
+ do_close_client = True
34
+ )
35
+
36
+
37
+ @router.get('/image')
38
+ async def get_stock_image(
39
+ query: str
40
+ ) -> StreamingResponse:
41
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/stock/image'
42
+
43
+ return await proxy_stream_endpoint(
44
+ url = endpoint_url,
45
+ method = 'GET',
46
+ params = {
47
+ 'query': query
48
+ },
49
+ do_close_response = True,
50
+ do_close_client = True
51
+ )
52
+
53
+
54
+ @router.get('/video')
55
+ async def get_stock_video(
56
+ query: str
57
+ ) -> StreamingResponse:
58
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/stock/video'
59
+
60
+ return await proxy_stream_endpoint(
61
+ url = endpoint_url,
62
+ method = 'GET',
63
+ params = {
64
+ 'query': query
65
+ },
66
+ do_close_response = True,
67
+ do_close_client = True
68
+ )
@@ -0,0 +1,93 @@
1
+ from yta_fastapi_docker_common import proxy_stream_endpoint
2
+ from yta_programming_env import Environment
3
+ from fastapi import APIRouter
4
+ from fastapi.responses import StreamingResponse
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class CreateVibevoiceSpeech(BaseModel):
9
+ text: str
10
+ voice: str
11
+
12
+ class CreateVibevoiceAudio(BaseModel):
13
+ text: str
14
+ voice: str
15
+
16
+
17
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('VIBEVOICE_FASTAPI_DOCKER_ENDPOINT')
18
+ PREFIX = f'/vibevoice'
19
+
20
+ router = APIRouter(
21
+ prefix = PREFIX
22
+ )
23
+
24
+ @router.post('/speech')
25
+ async def get_vibevoice_generate_speech(
26
+ request: CreateVibevoiceSpeech
27
+ ) -> StreamingResponse:
28
+ """
29
+ TODO: By now I'm allowing a single speaker, but
30
+ Vibevoice is accepting up to 4. Change it when
31
+ completely tested and working.
32
+ """
33
+ # # Body in Postman here below:
34
+ # {
35
+ # "script": "Speaker 0: I want to know if you are really amazing, because I am not sure.",
36
+ # "speakers": [
37
+ # {"speaker_id": 0, "voice_preset": "en-Alice_woman"},
38
+ # {"speaker_id": 1, "voice_preset": "en-Carter_man"}
39
+ # ],
40
+ # "cfg_scale": 1.3,
41
+ # "inference_steps": 10,
42
+ # "response_format": "mp3",
43
+ # "stream": false
44
+ # }
45
+
46
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/v1/vibevoice/generate'
47
+
48
+ return await proxy_stream_endpoint(
49
+ url = endpoint_url,
50
+ method = 'POST',
51
+ json = {
52
+ 'script': f'Speaker 0: {request.text}',
53
+ 'speakers': [
54
+ {
55
+ 'speaker_id': 0, 'voice_preset': request.voice
56
+ }
57
+ ],
58
+ 'cfg_scale': 1.3,
59
+ 'inference_steps': 10,
60
+ 'response_format': 'mp3',
61
+ 'stream': False
62
+ },
63
+ do_close_response = True,
64
+ do_close_client = True
65
+ )
66
+
67
+
68
+ @router.post('/audio')
69
+ async def get_vibevoice_generate_audio(
70
+ request: CreateVibevoiceAudio
71
+ ) -> StreamingResponse:
72
+ # # Body in Postman here below:
73
+ # {
74
+ # "model": "tts-1-hd",
75
+ # "input": "Salut ! Je m'appelle Eva.",
76
+ # "voice": "fr-Eva_woman",
77
+ # "response_format": "wav"
78
+ # }
79
+
80
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/v1/audio/speech'
81
+
82
+ return await proxy_stream_endpoint(
83
+ url = endpoint_url,
84
+ method = 'POST',
85
+ json = {
86
+ 'model': 'tts-1-hd',
87
+ 'input': request.text,
88
+ 'voice': request.voice,
89
+ 'response_format': 'wav'
90
+ },
91
+ do_close_response = True,
92
+ do_close_client = True
93
+ )
@@ -0,0 +1,87 @@
1
+ from yta_fastapi_docker_common import proxy_stream_endpoint
2
+ from yta_programming_env import Environment
3
+ from fastapi import APIRouter
4
+ from yta_httpx.client import HttpClient
5
+ from fastapi.responses import StreamingResponse, JSONResponse
6
+
7
+
8
+ CONTAINER_API_ENDPOINT_URL = Environment.get_env('YOUTUBE_FASTAPI_DOCKER_ENDPOINT')
9
+ PREFIX = f'/youtube'
10
+
11
+ router = APIRouter(
12
+ prefix = PREFIX
13
+ )
14
+
15
+ @router.get('/videos/{id_video}')
16
+ async def get_video(
17
+ id_video: str
18
+ ) -> JSONResponse:
19
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/youtube/videos/{id_video}'
20
+
21
+ async with HttpClient(...) as http_client:
22
+ response = await http_client.get.complete(
23
+ url = endpoint_url
24
+ )
25
+
26
+ return JSONResponse(
27
+ content = response.json(),
28
+ status_code = response.status_code
29
+ )
30
+
31
+
32
+ @router.get('/videos/{id_video}/data')
33
+ async def get_video_data(
34
+ id_video: str
35
+ ) -> JSONResponse:
36
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/youtube/videos/{id_video}/data'
37
+
38
+ async with HttpClient(...) as http_client:
39
+ response = await http_client.get.complete(
40
+ url = endpoint_url
41
+ )
42
+
43
+ return JSONResponse(
44
+ content = response.json(),
45
+ status_code = response.status_code
46
+ )
47
+
48
+ @router.get('/videos/{id_video}/download-lowest-quality')
49
+ async def get_download_video_lowest_quality(
50
+ id_video: str
51
+ ) -> StreamingResponse:
52
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/youtube/videos/{id_video}/download-lowest-quality'
53
+
54
+ return await proxy_stream_endpoint(
55
+ url = endpoint_url,
56
+ method = 'GET',
57
+ do_close_response = True,
58
+ do_close_client = True
59
+ )
60
+
61
+
62
+ @router.get('/videos/{id_video}/download-highest-quality')
63
+ async def get_download_video_highest_quality(
64
+ id_video: str
65
+ ) -> StreamingResponse:
66
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/youtube/videos/{id_video}/download-highest-quality'
67
+
68
+ return await proxy_stream_endpoint(
69
+ url = endpoint_url,
70
+ method = 'GET',
71
+ do_close_response = True,
72
+ do_close_client = True
73
+ )
74
+
75
+
76
+ @router.get('/videos/{id_video}/download-1080')
77
+ async def get_download_video_1080(
78
+ id_video: str
79
+ ) -> StreamingResponse:
80
+ endpoint_url = f'{CONTAINER_API_ENDPOINT_URL}/youtube/videos/{id_video}/download-1080'
81
+
82
+ return await proxy_stream_endpoint(
83
+ url = endpoint_url,
84
+ method = 'GET',
85
+ do_close_response = True,
86
+ do_close_client = True
87
+ )
@@ -1,32 +0,0 @@
1
- [project]
2
- name = "yta-fastapi-docker-api"
3
- version = "0.0.1"
4
- description = "Youtube Autonomous FastAPI Docker API Module"
5
- authors = [
6
- {name = "danialcala94", email = "danielalcalavalera@gmail.com"}
7
- ]
8
- readme = "README.md"
9
- requires-python = "==3.12.*"
10
- dependencies = [
11
- "fastapi (>=0.0.1,<9999.0.0)",
12
- "uvicorn (>=0.0.1,<9999.0.0)",
13
- "requests (>=0.0.1,<9999.0.0)"
14
- ]
15
-
16
- [tool.poetry]
17
- packages = [{include = "yta_fastapi_docker_api", from = "src"}]
18
-
19
- [tool.poetry.group.dev.dependencies]
20
- pytest = "^8.3.5"
21
- httpx = ">=0.0.1"
22
- yta_testing = ">=0.0.1"
23
-
24
- [tool.pytest.ini_options]
25
- markers = [
26
- "mandatory: mandatory tests for release",
27
- "additional: exhaustive and demanding tests"
28
- ]
29
-
30
- [build-system]
31
- requires = ["poetry-core>=2.0.0,<3.0.0"]
32
- build-backend = "poetry.core.masonry.api"
@@ -1,12 +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 fastapi import FastAPI
5
-
6
-
7
- app = FastAPI()
8
-
9
- # Include all the routers we have
10
- app.include_router(general_router)
11
- app.include_router(youtube_router)
12
- app.include_router(ollama_router)
@@ -1,63 +0,0 @@
1
- from fastapi import APIRouter, Body
2
- from fastapi.responses import JSONResponse, Response
3
-
4
- import requests
5
-
6
-
7
- # TODO: Get this from a .env, should point to the container
8
- OLLAMA_URL = 'http://yta_fastapi_docker_ollama:8000'
9
-
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('/agents/transcription-cleaner')
23
- def get_agents_transcription_cleaner(
24
- # prompt: Prompt
25
- # prompt: str
26
- payload: dict = Body(...)
27
- ) -> JSONResponse:
28
- print('---')
29
- print(payload)
30
- print('---')
31
- response = requests.post(
32
- url = f'{OLLAMA_URL}/ollama/agents/transcription-cleaner',
33
- json = payload
34
- )
35
- print('@@@')
36
- print(response)
37
- print('@@@')
38
-
39
- content_type = response.headers.get("content-type", "")
40
-
41
- if "application/json" in content_type:
42
- return JSONResponse(
43
- content = response.json(),
44
- status_code = response.status_code
45
- )
46
-
47
- """
48
- If I don't have the model it is just returning an
49
- 'Internal Server Error' message, but not that we
50
- don't have the specific model...
51
- """
52
- # TODO:
53
- return Response(
54
- # bytes (?)
55
- content = response.content,
56
- status_code = response.status_code,
57
- media_type = response.headers.get("content-type")
58
- )
59
-
60
- return JSONResponse(
61
- content = response.json(),
62
- status_code = response.status_code
63
- )
@@ -1,33 +0,0 @@
1
- from fastapi import APIRouter
2
- from fastapi.responses import JSONResponse
3
-
4
- import requests
5
-
6
-
7
- # TODO: Get this from a .env, should point to the container
8
- YOUTUBE_URL = 'http://yta_fastapi_docker_youtube:8000'
9
-
10
- PREFIX = f'/youtube'
11
-
12
- router = APIRouter(
13
- prefix = PREFIX
14
- )
15
-
16
- @router.get('/videos/{id_video}')
17
- def get_video(
18
- id_video: str
19
- ) -> JSONResponse:
20
- response = requests.get(f'{YOUTUBE_URL}/youtube/videos/{id_video}')
21
-
22
- return JSONResponse(
23
- content = response.json(),
24
- status_code = response.status_code
25
- )
26
-
27
- return JSONResponse(
28
- {
29
- 'error': False,
30
- 'data': data
31
- },
32
- status_code = 200
33
- )