|
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Flux;
|
|
|
|
|
+import space.anyi.springAiAlibabaLearn.model.Person;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/chatClient")
|
|
@RequestMapping("/chatClient")
|
|
@@ -78,4 +79,15 @@ public class ChatClientController {
|
|
|
})
|
|
})
|
|
|
.map(chatClientResponse -> chatClientResponse.chatResponse().getResult().getOutput().getText());
|
|
.map(chatClientResponse -> chatClientResponse.chatResponse().getResult().getOutput().getText());
|
|
|
}
|
|
}
|
|
|
|
|
+ @GetMapping("/entity")
|
|
|
|
|
+ public Person entity(){
|
|
|
|
|
+ //将LLM的输出转换为Java对象
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 内部会在prompt中追加Person类的结构消息,并要求LLM输出符合格式的JSON字符串
|
|
|
|
|
+ */
|
|
|
|
|
+ return chatClient
|
|
|
|
|
+ .prompt("生成一个人的消息.")
|
|
|
|
|
+ .call()
|
|
|
|
|
+ .entity(Person.class);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|