Teams-AI 库:尝试连接到我的 Azure OpenAI 资源时出现“请求失败,状态代码为 400”

Teams-AI Library: Getting "Request failed with status code 400" while trying to connect to my Azure OpenAI Resource

提问人:CUiD8pdQJh 提问时间:11/8/2023 最后编辑:CUiD8pdQJh 更新时间:11/8/2023 访问量:46

问:

目前,在向使用 teams-ai 和 botbuilder 模块创建的 Teams-Bot 发送消息时,我收到以下响应:

The bot encountered unhandled error: Request failed with status code 400

To continue to run this bot, please fix the bot source code.

当我检查抛出的错误时,这是响应数据:,这是响应 statusText: 。我找不到尸体,这可能是问题的一部分,也可能不是。"Unsupported data type\n""model_error"

我试图找到问题的根源,这可能是将要发送的数据准备好并附加到我的 Azure OpenAI 部署请求的地方,但到目前为止,我还没有运气。

这是我在代码中实现 Azure OpenAI 部署的方式:

const planner = new AzureOpenAIPlanner({
    apiKey: process.env.AZUREOPENAIKEY,
    defaultModel: '{name-of-deployment-in-azure}/chat',
    endpoint: process.env.AZUREOPENAIENDPOINT,
    apiVersion: '2023-07-01-preview'
});

const promptManager = new DefaultPromptManager('C:/test123/prompts');
const storage = new MemoryStorage();

const app = new Application<ApplicationTurnState>({
    storage,
    ai: {
        planner,
        // moderator,
        promptManager,
        prompt: 'chat',
        history: {
            assistantHistoryType: 'text'
        }
    }
});

// Create HTTP server.
const server = restify.createServer();
server.use(restify.plugins.bodyParser());
server.listen(process.env.port || process.env.PORT || 3978, () => {
    console.log(`\nBot Started, ${server.name} listening to ${server.url}`);
});

// Listen for incoming requests.
server.post("/api/messages", async (req, res) => {
    await adapter.process(req, res, async (context) => {
        await app.run(context);
    });
});
TypeScript HTTP BotFramework Teams-Toolkit Azure-OpenAI

评论

0赞 Nicolas R 11/9/2023
在第一视图中让我感到惊讶的是:“defaultModel: '{name-of-deployment-in-azure}/chat'” <我不确定模型名称中是否允许使用“/”。为什么名字里有这个“/chat”?
0赞 CUiD8pdQJh 11/9/2023
这实际上是一个非常有趣的问题。Azure OpenAI 服务的终结点包括 /chat。但是,如果我省略它,它不会自动添加,因此端点首先是错误的。
0赞 Nicolas R 11/10/2023
“Azure OpenAI 服务的终结点包括 /chat”<<取决于你调用的操作。所以我真的不确定你是否应该把它放在这里,你遇到了一个错误,没有?中方能否介绍有关情况?

答: 暂无答案