Text Prompt Flow Endpoint Consumption
Hi,
I want to ask questions about text prompt flow endpoint consumption. I have created a text prompt flow following this documentation. Then, I deploy this prompt flow so I can consume the endpoint to my own application. However, I just realized that my own application does not have the conversation history. I already tested the endpoint in Azure AI Foundry for the conversation history and it works but in my own application it does not work. This is my code for back-end. I have tried to declare the conversation history alone in my code, but it seems like, it follows the input in the text prompt flow I created before. Kindly request help on how to enable the conversation history in this code or do I need to modify the front-end code also?
Thank you so much for helping.
import axios from 'axios';
const apiKey = process.env.AZURE_KEY;
const endpoint = process.env.AZURE_ENDPOINT;
export const askQuestion = async (question) => {
const data = {
chat_history: [], // Initially empty, can be populated as needed
chat_input: question
};
try {
const response = await axios.post(endpoint, data, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'azureml-model-deployment': 'bmi-ai-bishub-project-gpt4o-1'
}
});
if (response.data) {
// // Extract and return only the raw output
return response.data.chat_output || JSON.stringify(response.data, null, 2);
} else {
throw new Error('No response from the server');
}
} catch (error) {
throw new Error(error.response ? error.response.data : error.message);
}
};