Browse Source

上传代码

weicu
liwei1dao 1 year ago
parent
commit
95a21742ba
  1. 37
      lib/modules/agent/controllers/agent_controller.dart
  2. 12
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

37
lib/modules/agent/controllers/agent_controller.dart

@ -2073,7 +2073,7 @@ class AgentController extends GetxController with WidgetsBindingObserver {
color: Colors.grey.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(Icons.navigation, color: Colors.grey),
child: const Icon(Icons.navigation, color: Colors.orange),
),
title: const Text('苹果地图'),
subtitle: const Text('使用苹果地图导航'),
@ -2082,6 +2082,23 @@ class AgentController extends GetxController with WidgetsBindingObserver {
openAppleMap(destination, mode);
},
),
ListTile(
leading: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(Icons.navigation, color: Colors.grey),
),
title: const Text('内置导航'),
subtitle: const Text('使用内置地图导航'),
onTap: () {
Get.back();
openInternalGaodeMap(
start, destination, endlatitude, endlongitude, mode);
},
),
// 底部安全区域
SizedBox(height: MediaQuery.of(Get.context!).padding.bottom + 20),
],
@ -2503,6 +2520,24 @@ class AgentController extends GetxController with WidgetsBindingObserver {
}
}
/// 打开内置高德地图进行导航
Future<bool> openInternalGaodeMap(
String start,
String destination,
String endlatitude,
String endlongitude,
String mode // 'driving', 'transit', 'walking', 'cycling'
) async {
try {
_navigationManager.open(start, "$endlongitude,$endlatitude", mode);
return true;
} catch (e) {
print('打开内置高德地图失败: $e');
Get.snackbar('错误', '打开地图时发生错误');
return false;
}
}
/// 打开Google地图进行导航
Future<bool> openGoogleMap(String daddr, String mode) async {
try {

12
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -62,6 +62,7 @@ class AgentServiceImpl: NSObject {
private let agentId = "default_agent"
//工具调用提示
public var callingTool = ""
private var navigationMode = ""
private var isInitialized: Bool = false
private var isRecognizing: Bool = false
@ -165,6 +166,10 @@ class AgentServiceImpl: NSObject {
self.config = config
if let navigationMode = config["navigationMode"] as? String {
self.navigationMode = navigationMode
}
if let callingTool = config["callingTool"] as? String {
self.callingTool = callingTool
}
@ -215,6 +220,7 @@ class AgentServiceImpl: NSObject {
sendError("Azure语音区域缺失", code: "CONFIG_ERROR")
return false
}
//启动定位服务
NotificationCenter.default.post(name: .locationstartEvent, object: nil)
// addlocationmonitor()
@ -1020,7 +1026,7 @@ private func jsonToString(_ json: [String: Any]) -> String? {
// 应用在前台时的原有逻辑
// 根据导航模式选择不同的导航方式
switch mode {
switch self.navigationMode {
case "internal_gaode":
// 使用内置高德导航
// startInternalNavigation(start: start, destination: destination,
@ -1706,7 +1712,7 @@ class ChatApiStreamCallback: StreamCallback {
do {
guard let agentService = try agentService else { return }
if sessionid == agentService.currsessionId {
if sessionid == agentService.currsessionId {
// 停止等待音效
agentService.audioPlayer?.stopAwaitSound()
}
@ -1762,7 +1768,7 @@ class ChatApiStreamCallback: StreamCallback {
}catch{
print("liwei--------------- AI Call onFunctionCall 异常: \(error)")
}
}
func onFunctionCallResult(_ sessionid:String,_ functionCall: [String: Any], _ functionCallResult: [String: Any]) {

Loading…
Cancel
Save