28 lines
884 B
Java
28 lines
884 B
Java
|
package com.ai.controller;
|
||
|
|
||
|
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;
|
||
|
|
||
|
/**
|
||
|
* 处理用户输入并调用 LangChainService 获取响应
|
||
|
* @param input 用户输入的内容
|
||
|
* @return 大语言模型生成的响应
|
||
|
*/
|
||
|
@GetMapping("/chat")
|
||
|
public String chat(@RequestParam("input") String input) {
|
||
|
System.out.println("start chat...");
|
||
|
return langChainService.getResponse(input);
|
||
|
}
|
||
|
}
|