Azure GPT模型适配TTYG ChatGPT检索插件失败求助
问题概述
使用OpenAI API密钥可正常运行GraphDB的TTYG(Talk To Your Graph)功能,但切换为Azure OpenAI密钥后始终无法工作。该Azure密钥已在其他工具中验证可用,且已按官方配置文档完成所有步骤。
当前配置信息
Shell脚本环境变量
export BEARER_TOKEN="<my bearer token>" export OPENAI_API_KEY="<my azure api key>" export OPENAI_API_BASE="https://test-1.openai.azure.com/" export OPENAI_API_TYPE="azure" export OPENAI_EMBEDDINGMODEL_DEPLOYMENTID="test-1-text-embedding-ada-002"
GraphDB Java属性
graphdb.gpt.token: <my azure api key> graphdb.gpt.model: test-1-text-embedding-ada-002 graphdb.gpt.url: https://test-1.openai.azure.com/openai/deployments/test-1-text-embedding-ada-002/chat/completions?api-version=2023-03-15-preview graphdb.gpt.auth: api-key
报错信息
"Handler dispatch failed; nested exception is. Could not initialize class com.graphdb.gpt.Gpt..."
排查与修复建议
修正API端点路径
TTYG功能依赖**文本嵌入(embeddings)**服务,当前配置的graphdb.gpt.url指向聊天补全(chat/completions)端点,与功能需求不匹配。需将端点修改为Azure OpenAI嵌入服务路径:graphdb.gpt.url: https://test-1.openai.azure.com/openai/deployments/test-1-text-embedding-ada-002/embeddings?api-version=2023-03-15-preview补充Azure专属配置参数
在GraphDB Java属性中添加Azure服务类型标识,确保系统识别为Azure OpenAI:graphdb.gpt.api-type: azure同时确认Shell环境变量中的
OPENAI_API_TYPE="azure"已正确传递到GraphDB进程,若部署环境存在变量隔离,可直接在GraphDB启动脚本中注入该变量。校验模型ID与端点一致性
确认graphdb.gpt.model的值与Azure OpenAI部署的嵌入模型ID完全一致,避免拼写或大小写错误。排查类初始化依赖问题
类初始化失败可能源于GraphDB版本对Azure OpenAI SDK的支持不足。检查是否使用了支持Azure OpenAI的GraphDB版本,若版本较旧,建议升级至对应兼容版本;若依赖缺失,需确认GraphDB安装包中包含Azure OpenAI相关SDK组件。
内容的提问来源于stack exchange,提问作者Lmil

