diff --git a/.gitignore b/.gitignore index cbb4ff273..cb403a63b 100644 --- a/.gitignore +++ b/.gitignore @@ -484,7 +484,7 @@ modules.xml # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: -.python-version +# .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..a5c4c7633 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9.0 diff --git a/backend/.python-version b/backend/.python-version new file mode 100644 index 000000000..a5c4c7633 --- /dev/null +++ b/backend/.python-version @@ -0,0 +1 @@ +3.9.0 diff --git a/backend/adapter_processor/exceptions.py b/backend/adapter_processor/exceptions.py index f2eeeb73e..5bddbb3c2 100644 --- a/backend/adapter_processor/exceptions.py +++ b/backend/adapter_processor/exceptions.py @@ -20,6 +20,14 @@ class InValidAdapterId(APIException): default_detail = "Adapter ID is not Valid." +class InvalidEncryptionKey(APIException): + status_code = 403 + default_detail = ( + "Platform encryption key for storing adapter credentials has changed! " + "Please inform the organization admin to contact support." + ) + + class InternalServiceError(APIException): status_code = 500 default_detail = "Internal Service error" diff --git a/backend/adapter_processor/serializers.py b/backend/adapter_processor/serializers.py index 716016282..80637206e 100644 --- a/backend/adapter_processor/serializers.py +++ b/backend/adapter_processor/serializers.py @@ -4,7 +4,8 @@ from account.serializer import UserSerializer from adapter_processor.adapter_processor import AdapterProcessor from adapter_processor.constants import AdapterKeys -from cryptography.fernet import Fernet +from adapter_processor.exceptions import InvalidEncryptionKey +from cryptography.fernet import Fernet, InvalidToken from django.conf import settings from rest_framework import serializers from rest_framework.serializers import ModelSerializer @@ -62,7 +63,10 @@ def to_representation(self, instance: AdapterInstance) -> dict[str, str]: rep.pop(AdapterKeys.ADAPTER_METADATA_B) - adapter_metadata = instance.get_adapter_meta_data() + try: + adapter_metadata = instance.get_adapter_meta_data() + except InvalidToken: + raise InvalidEncryptionKey rep[AdapterKeys.ADAPTER_METADATA] = adapter_metadata # Retrieve context window if adapter is a LLM # For other adapter types, context_window is not relevant. diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 33de0fed5..373fe9f63 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -130,6 +130,9 @@ services: - ../prompt-service/.env labels: - traefik.enable=false + extra_hosts: + # "host-gateway" is a special string that translates to host docker0 i/f IP. + - "host.docker.internal:host-gateway" x2text-service: image: unstract/x2text-service:${VERSION} diff --git a/platform-service/src/unstract/platform_service/main.py b/platform-service/src/unstract/platform_service/main.py index 883f12017..f7ea2b5fb 100644 --- a/platform-service/src/unstract/platform_service/main.py +++ b/platform-service/src/unstract/platform_service/main.py @@ -506,4 +506,4 @@ def handle_custom_exception(error: Any) -> tuple[Response, Any]: if __name__ == "__main__": # Start the server - app.run() + app.run(host="0.0.0.0", port="3001") diff --git a/prompt-service/.python-version b/prompt-service/.python-version new file mode 100644 index 000000000..a5c4c7633 --- /dev/null +++ b/prompt-service/.python-version @@ -0,0 +1 @@ +3.9.0 diff --git a/run-platform.sh b/run-platform.sh index eb7dfa832..a11261fe4 100755 --- a/run-platform.sh +++ b/run-platform.sh @@ -222,6 +222,8 @@ build_services() { } elif [ "$first_setup" = true ] || [ "$opt_upgrade" = true ]; then echo -e "$blue_text""Pulling""$default_text"" docker images tag ""$blue_text""$opt_version""$default_text""." + # Try again on a slow network. + VERSION=$opt_version $docker_compose_cmd -f $script_dir/docker/docker-compose.yaml pull || VERSION=$opt_version $docker_compose_cmd -f $script_dir/docker/docker-compose.yaml pull || { echo -e "$red_text""Failed to pull docker images.""$default_text" echo -e "$red_text""Either version not found or docker is not running.""$default_text"