2025-03-02 13:34:44 +00:00
|
|
|
package com.ai.controller;
|
|
|
|
|
2025-03-04 12:09:16 +00:00
|
|
|
import com.ai.service.Assist;
|
2025-03-02 13:34:44 +00:00
|
|
|
import com.ai.service.LangChainService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/langchain")
|
|
|
|
public class LangChainController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private LangChainService langChainService;
|
|
|
|
|
2025-03-04 12:09:16 +00:00
|
|
|
@Autowired
|
|
|
|
private Assist assist;
|
|
|
|
|
2025-03-02 13:34:44 +00:00
|
|
|
/**
|
|
|
|
* 处理用户输入并调用 LangChainService 获取响应
|
|
|
|
* @param input 用户输入的内容
|
|
|
|
* @return 大语言模型生成的响应
|
|
|
|
*/
|
|
|
|
@GetMapping("/chat")
|
|
|
|
public String chat(@RequestParam("input") String input) {
|
|
|
|
System.out.println("start chat...");
|
|
|
|
return langChainService.getResponse(input);
|
|
|
|
}
|
2025-03-04 12:09:16 +00:00
|
|
|
|
|
|
|
@GetMapping("/high/chat")
|
|
|
|
public String highChat(@RequestParam("input") String input) {
|
|
|
|
System.out.println("start highlevel chat...");
|
|
|
|
return assist.chat(input);
|
|
|
|
}
|
2025-03-02 13:34:44 +00:00
|
|
|
}
|