01. A private conversation - 2006-07-10

上周我去剧院观看了一场有趣的戏剧,但是一对坐在后面的年轻男女大声交谈,严重影响了我的观剧体验。我尝试制止他们,却得到了粗鲁的回应,认为这是他们的私人谈话,与我无关。

01. A private conversation

Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. “I can not hear a word!” I said angrily. “It’s none of your business,” the young man said rudely, “This is a private conversation.”

 

Theatre    /        /

Actor      /        /

Bear       /        /

Rudely     /        /

Conversation /        /

 
package com.zhix.ai.controller; import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions; import com.alibaba.cloud.ai.memory.jdbc.MysqlChatMemoryRepository; import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor; import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor; import org.springframework.ai.chat.memory.ChatMemory; import org.springframework.ai.chat.memory.ChatMemoryRepository; import org.springframework.ai.chat.memory.MessageWindowChatMemory; import org.springframework.jdbc.core.JdbcTemplate; 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("/ai/hellowrold") public class HelloworldController { private static final String DEFAULT_PROMPT = "你是一个博学的智能聊天助手,请根据用户提问回答!"; private final ChatClient dashScopeChatClient; private final ChatMemoryRepository chatMemoryRepository; private final ChatMemory chatMemory; public HelloworldController(JdbcTemplate jdbcTemplate, ChatClient.Builder chatClientBuilder) { // 初始化 ChatMemoryRepository 和 ChatMemory this.chatMemoryRepository = MysqlChatMemoryRepository.mysqlBuilder() .jdbcTemplate(jdbcTemplate) .build(); this.chatMemory = MessageWindowChatMemory.builder() .chatMemoryRepository(chatMemoryRepository) .build(); this.dashScopeChatClient = chatClientBuilder .defaultSystem(DEFAULT_PROMPT) .defaultAdvisors(new SimpleLoggerAdvisor()) // 注册 Advisor .defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build()) .defaultOptions( DashScopeChatOptions.builder() .withTopP(0.7) .build() ) .build(); } @GetMapping("/simpleChat") public String simpleChat(@RequestParam(value = "query", defaultValue = "你好,很高兴认识你,能简单介绍一下自己吗?") String query, @RequestParam(value = "chat-id", defaultValue = "1") String chatId) { return dashScopeChatClient.prompt(query) .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, chatId)) .call().content(); } } implementation platform("com.alibaba.cloud.ai:spring-ai-alibaba-bom:1.0.0.2") implementation 'com.alibaba.cloud.ai:spring-ai-alibaba-starter-dashscope' implementation 'com.alibaba.cloud.ai:spring-ai-alibaba-starter-memory-jdbc:1.0.0.2' implementation 'mysql:mysql-connector-java:8.0.32'代码和依赖对吗,不对的话怎么改
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值