diff --git a/samples/crewai/app/config/settings.py b/samples/crewai/app/config/settings.py index eb1b6ab3..b2a624f0 100644 --- a/samples/crewai/app/config/settings.py +++ b/samples/crewai/app/config/settings.py @@ -155,26 +155,31 @@ def get_private_ips(): REDIS_URL = os.environ.get("REDIS_URL") -import urllib.parse - -parsed_url = urllib.parse.urlparse(REDIS_URL) - -REDIS_HOST = parsed_url.hostname -REDIS_PORT = parsed_url.port - # Channels/Redis CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { - "hosts": [(REDIS_HOST, REDIS_PORT)], + "hosts": [REDIS_URL], }, }, } -# Celery -CELERY_BROKER_URL = REDIS_URL -CELERY_RESULT_BACKEND = REDIS_URL +# Celery requires CERT_NONE (uppercase); channels_redis requires none (lowercase). +# Normalize the URL for Celery by uppercasing the ssl_cert_reqs value. +_celery_url = REDIS_URL.replace('ssl_cert_reqs=none', 'ssl_cert_reqs=CERT_NONE') if REDIS_URL else REDIS_URL +CELERY_BROKER_URL = _celery_url +CELERY_RESULT_BACKEND = _celery_url + +# Azure Redis Enterprise (EnterpriseCluster mode) still enforces cross-slot +# restrictions inside MULTI/EXEC. Kombu pipelines multiple keys (priority queue +# variants, unacked/unacked_index) in MULTI/EXEC blocks. Setting global_keyprefix +# to a Redis hash tag forces ALL Kombu keys to hash to the same slot, eliminating +# all CROSSSLOT errors. priority_steps=[0] is kept to reduce key proliferation. +CELERY_BROKER_TRANSPORT_OPTIONS = { + 'global_keyprefix': '{celery}', + 'priority_steps': [0], +} # CrewAI (no special settings needed for hello world) diff --git a/samples/crewai/app/core/tasks.py b/samples/crewai/app/core/tasks.py index a0866551..c37485e9 100644 --- a/samples/crewai/app/core/tasks.py +++ b/samples/crewai/app/core/tasks.py @@ -17,7 +17,7 @@ def crewai_summary(text: str): embedding = embedding_client.embeddings.create( model=os.getenv("EMBEDDING_MODEL"), - input=text, + input=[text], ) summaries = Summary.objects.annotate( @@ -57,7 +57,7 @@ def crewai_summary(text: str): summary_embedding = embedding_client.embeddings.create( model=os.getenv("EMBEDDING_MODEL"), - input=summary, + input=[summary], ).data[0].embedding try: