Skip to content

Commit

Permalink
fix azure conversation url
Browse files Browse the repository at this point in the history
  • Loading branch information
gusibi committed Jan 3, 2024
1 parent 20b0442 commit e640bca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions lib/screens/conversation/conversation_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ class _ConversationScreenState extends State<ConversationScreen> {
palmProvider.setPalmApiKey(palmConfig.apiKey);
palmProvider.setCurrentPalmModel(palmConfig.modelName);
}
conf = configMap[azureConfigname];
if (conf != null) {
final azureConfig = conf.toAzureConfig();
palmProvider.setAzureOpenAIConfig(azureConfig);
}
}

void _queryConversationMessages() async {
Expand Down Expand Up @@ -439,6 +444,10 @@ class _ConversationScreenState extends State<ConversationScreen> {
chatRole = result[0];
message = result[1];
} else if (currentConversation.modelName == azureGPT35Model.modelName) {
final aiSettingProvider =
Provider.of<AISettingProvider>(context, listen: false);
basicUrl = aiSettingProvider.getAuzreOpenAIConfig.basicUrl;
apiKey = aiSettingProvider.getAuzreOpenAIConfig.apiKey;
result = await sendMessageByAzureApi(
basicUrl, apiKey, trimmedText, currentConversation);
chatRole = result[0];
Expand Down
4 changes: 3 additions & 1 deletion lib/screens/conversation/conversation_setting_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,11 @@ class _ConversationSettingScreenState extends State<ConversationSettingScreen> {
prompt: promptController.text,
icon: conversationInfo.icon,
desc: conversationInfo.desc,
modelName: palmModelsMap[palmModel.value]!,
modelName: conversationInfo.modelName,
rank: 0,
lastTime: timestampNow());
log("{{$conv.id}}");
log(conv.modelName);
ConversationReop().updateConversation(conv);
Navigator.pop(context);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/services/azure_openai_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class AzureOpenAIApiService {
var apiVersion = req.apiVersion;
try {
// log("start, model: $currentModel, prompt: $context");
log("$baseURL/openai/deployments/$currentModel/chat/completions?api-version=$apiVersion");
var url =
"$baseURL/openai/deployments/$currentModel/chat/completions?api-version=$apiVersion";
log(url);
var headers = {'Content-Type': 'application/json', "api-key": apiKey};
log("$headers");
log(apiKey);
var request = http.Request(
'POST',
Uri.parse(
"$baseURL/openai/deployments/$currentModel/chat/completions?api-version=$apiVersion"));
var request = http.Request('POST', Uri.parse(url));
var message = '';
for (var i = 0; i < req.messages.length; i++) {
if (req.messages[i].role == roleAI) {
Expand Down

0 comments on commit e640bca

Please sign in to comment.