Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions samples/crewai/app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions samples/crewai/app/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
Loading