Azure OpenAI Basic Chat bot with Bing Search v7
hi setup a open ai model with basic chat bot and bing search v7 and integration into Teams App.
on the code site is using javascript
\src\app
it have a app.js
and also a new js call bingsearch.js >> this will be my bing search api key and endpoint
however after i deploy , the bing search is working fine but the basic chat bot will failed "The bot encountered an error or bug. Please try again later."
this is my app.js
const { MemoryStorage } = require("botbuilder");
const path = require("path");
const config = require("../config");
const { Application, ActionPlanner, OpenAIModel, PromptManager } = require("@microsoft/teams-ai");
const { getTopBingResults } = require("./bingSearch"); // Updated import for multiple results
// Create AI components
const model = new OpenAIModel({
azureApiKey: config.azureOpenAIKey,
azureDefaultDeployment: config.azureOpenAIDeploymentName,
azureEndpoint: config.azureOpenAIEndpoint,
useSystemMessages: true,
logRequests: true,
});
const prompts = new PromptManager({
promptsFolder: path.join(__dirname, "../prompts"),
});
const planner = new ActionPlanner({
model,
prompts,
defaultPrompt: "chat",
});
// Define storage and application
const storage = new MemoryStorage();
const app = new Application({
storage,
ai: {
planner,
``` },
});
app.run = async (context) => {
try {
const userQuery = context.activity.text.trim();
if (userQuery.toLowerCase().startsWith('/search')) {
const searchTerm = userQuery.replace('/search', '').trim();
const results = await getTopBingResults(searchTerm);
if (results.length > 0) {
let message = 'Here are some search results:\n';
results.forEach((result, index) => {
message += `\n${index + 1}. [${result.title}](${result.url})\n${result.snippet}\n`;
});
await context.sendActivity(message);
``` } else {
await context.sendActivity('No results found.');
} else {
// Use the planner to process general queries
await planner.process(context);
}
``` } catch (error) {
console.error('Error processing message:', error);
await context.sendActivity('The bot encountered an error or bug. Please try again later.');
};
module.exports = app;
i totally no idea how i can solve it ? seek for expect for help on it.
how i can able run the teams app with basic chat bot with bing search v7?
thanks a lot