The ai-service fails to process any event because the code uses the old
openai SDK syntax which was removed in v1.0.0.
Errors seen in docker logs:
I tried to access openai.ChatCompletion, but this is no longer
supported in openai>=1.0.0
I tried to access openai.Embedding, but this is no longer supported
in openai>=1.0.0
The requirements.txt installs openai==1.3.8 which is the new SDK, but
processor.py still uses the old style:
openai.api_key = config.openai_api_key
openai.ChatCompletion.create(...)
openai.Embedding.create(...)
Fix:
Migrated processor.py to the v1 client interface:
from openai import OpenAI
self.client = OpenAI(api_key=config.openai_api_key)
self.client.chat.completions.create(...)
self.client.embeddings.create(...)
Also fixed the embedding response parsing:
Old: response["data"][0]["embedding"]
New: response.data[0].embedding
After this fix the AI service processes events correctly.
The ai-service fails to process any event because the code uses the old
openai SDK syntax which was removed in v1.0.0.
Errors seen in docker logs:
I tried to access openai.ChatCompletion, but this is no longer
supported in openai>=1.0.0
I tried to access openai.Embedding, but this is no longer supported
in openai>=1.0.0
The requirements.txt installs openai==1.3.8 which is the new SDK, but
processor.py still uses the old style:
openai.api_key = config.openai_api_key
openai.ChatCompletion.create(...)
openai.Embedding.create(...)
Fix:
Migrated processor.py to the v1 client interface:
from openai import OpenAI
self.client = OpenAI(api_key=config.openai_api_key)
self.client.chat.completions.create(...)
self.client.embeddings.create(...)
Also fixed the embedding response parsing:
Old: response["data"][0]["embedding"]
New: response.data[0].embedding
After this fix the AI service processes events correctly.