Skip to content

feat: add deepseek reasoning content support and adjust some code #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

yuluo-yx
Copy link
Collaborator

@yuluo-yx yuluo-yx commented Feb 20, 2025

package indi.yuluo.deepseek;

import java.util.Map;

import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import jakarta.servlet.http.HttpServletResponse;
import reactor.core.publisher.Flux;

import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.model.Generation;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yuluo
 * @author <a href="mailto:[email protected]">yuluo</a>
 */

@RestController
@RequestMapping("/chat")
public class DeepSeekController {

	private final DashScopeChatModel chatModel;

	public DeepSeekController(DashScopeChatModel chatModel) {
		this.chatModel = chatModel;
	}

	@GetMapping("/hi")
	public String hi() {
		return "hi";
	}

	@GetMapping("/{prompt}")
	public Generation chat(@PathVariable(value = "prompt") String prompt) {

		ChatResponse chatResponse = chatModel.call(new Prompt(prompt));

		if (!chatResponse.getResults().isEmpty()) {
			Map<String, Object> metadata = chatResponse.getResults()
					.get(0)
					.getOutput()
					.getMetadata();
			System.out.println(metadata);
		}

		return chatResponse.getResult();
	}

	@GetMapping("/stream/{prompt}")
	public Flux<ChatResponse> streamChat(
			@PathVariable(value = "prompt") String prompt,
			HttpServletResponse response
	) {

		response.setCharacterEncoding("UTF-8");

		return chatModel.stream(new Prompt(prompt));
	}

}

d287ef08a5df1baa6970e279750dd53e

@@ -51,362 +51,361 @@
*
*/
public class MongodbDocumentReader implements DocumentReader, Closeable {
private static final Logger log = LoggerFactory.getLogger(MongodbDocumentReader.class);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

格式化了代码

@@ -15,271 +15,262 @@
*/
package com.alibaba.cloud.ai.reader.mongodb;

import lombok.Builder;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前去掉 lombok 似乎不彻底,不知道为啥没检查出来,这次是对上次得更新弥补

@@ -73,6 +73,7 @@
<module>community/document-readers/huggingface-fs-document-reader</module>
<module>community/document-readers/email-document-reader</module>
<module>community/document-readers/mbox-document-reader</module>
<module>community/document-readers/mongodb-document-reader</module>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加到 pom.xml

@yuluo-yx
Copy link
Collaborator Author

ptal @chickenlj @fuyou-lxm

Copy link
Collaborator

@PolarishT PolarishT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@yuluo-yx yuluo-yx merged commit d8821cd into main Feb 21, 2025
4 checks passed
@yuluo-yx yuluo-yx deleted the 0218-yuluo/add-deepseek branch February 21, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants