Skip to content

Commit

Permalink
feat: add code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
yuluo-yx committed Mar 20, 2024
1 parent 273a923 commit 8682139
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.aot.hint.RuntimeHintsRegistrar;

/**
* The TongYiRuntimeHints class is responsible for registering runtime hints for TongYiAI.
*
* @author yuluo
* @author [email protected]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
import org.springframework.beans.factory.annotation.Autowired;

/**
*
* {@link ChatClient} and {@link StreamingChatClient} implementation for {@literal Alibaba DashScope}
* backed by {@link Generation}.
* @author yuluo
* @author [email protected]
*/
Expand All @@ -51,13 +54,26 @@ public class TongYiChatClient implements ChatClient, StreamingChatClient {

private static final Logger logger = LoggerFactory.getLogger(TongYiChatClient.class);

/**
* DashScope generation client.
*/
private final Generation generation;

/**
* The TongYi models default chat completion api.
*/
private TongYiChatOptions defaultOptions;

/**
* User role message manager.
*/
@Autowired
private MessageManager msgManager;

/**
* Initializes an instance of the TongYiChatClient.
* @param generation DashScope generation client.
*/
public TongYiChatClient(Generation generation) {

this(generation,
Expand All @@ -69,6 +85,11 @@ public TongYiChatClient(Generation generation) {
);
}

/**
* Create a TongYi models client.
* @param generation DashScope model generation client.
* @param options TongYi default chat completion api.
*/
public TongYiChatClient(Generation generation, TongYiChatOptions options) {

this.generation = generation;
Expand Down Expand Up @@ -142,6 +163,11 @@ public Flux<ChatResponse> stream(Prompt prompt) {

}

/**
* Configuration properties to Qwen model params.
* @param prompt {@link Prompt}
* @return Qwen models params {@link QwenParam}
*/
private QwenParam toTongYiChatParams(Prompt prompt) {

Constants.apiKey = getKey();
Expand Down Expand Up @@ -173,7 +199,7 @@ private ChatGenerationMetadata generateChoiceMetadata(GenerationOutput.Choice ch
/**
* Get TongYi model api_key .
* todo: Get key from env and env_file.
* @return api_key
* @return api_key.
*/
private String getKey() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.alibaba.dashscope.aigc.generation.Generation;

/**
* TongYi models constants.
*
* @author yuluo
* @author [email protected]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.alibaba.cloud.ai.tongyi.exception;

/**
* TongYi models runtime exception.
*
* @author yuluo
* @author [email protected]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.springframework.util.Assert;

/**
* {@link ChatResponseMetadata} implementation for {@literal Alibaba DashScope}.
*
* @author yuluo
* @author [email protected]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.springframework.util.Assert;

/**
* {@link Usage} implementation for {@literal Alibaba DashScope}.
*
* @author yuluo
* @author [email protected]
*/
Expand Down

0 comments on commit 8682139

Please sign in to comment.