Hi there Tom Chow
Thanks for using QandA platform.
Thatts an interesting question and I believe yesIntegrating Azure OpenAI "On Your Data" into a Flutter environment is possible, but it needs calling the REST API directly since specific packages like Azure.AI.OpenAI and OpenAI.Chat are not available for Flutter (I guess). You can do this by using Flutter's HTTP package to make API requests and handle responses.
- for ex you can use the
http
package in Flutter to send requests to the Azure OpenAI API. You can configure chat agent through the JSON payload in your requests. - and structure your JSON payload to include parameters for Azure AI Search, data sources, and other configurations. like below
import 'package:http/http.dart' as http;
import 'dart:convert';
Future<void> callAzureOpenAI() async {
final String endpoint = 'https://<your-openai-endpoint>/openai/deployments/<deployment-id>/chat/completions?api-version=2023-05-15';
final String apiKey = '<your-api-key>';
final Map<String, dynamic> requestBody = {
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a joke."}
],
"max_tokens": 50,
"temperature": 0.7,
"top_p": 1.0
};
final response = await http.post(
Uri.parse(endpoint),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $apiKey',
},
body: json.encode(requestBody),
);
if (response.statusCode == 200) {
final Map<String, dynamic> responseData = json.decode(response.body);
print(responseData['choices'][0]['message']['content']);
} else {
print('Request failed with status: ${response.statusCode}.');
}
}
And I don't think there are any docs on this but have a look at this doc for some additional info
https://learn.microsoft.com/en-us/azure/ai-services/openai/
If this helps kindly accept the response thanks much.