feat: update rag example and readme files (#3774)

Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
pull/3796/head
YuLuo 7 months ago committed by GitHub
parent 84177d10e8
commit d0da90c0db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -40,22 +40,27 @@ You need to introduce the following dependencies in the POM. XML:
<dependency> <dependency>
<groupId>org.springframework.ai</groupId> <groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-redis-spring-boot-starter</artifactId> <artifactId>spring-ai-redis-store-spring-boot-starter</artifactId>
<version>${spring.ai.version}</version> <version>${spring.ai.version}</version>
</dependency> </dependency>
``` ```
## 3. Configuration ## 3. Configuration
Configure the following information in the application. Yml: Configure the following information in application.yml: > Note: It is recommended that you configure apiKey via an environment variable for apiKey security.
> Note: It is recommended to configure the apiKey via environment variables for apiKey security.
> Reference: https://github.com/alibaba/spring-cloud-alibaba/tree/2023.x/spring-cloud-alibaba-examples/ai-example/spring-cloud-ai-example#% E6%8E%A5%E5%85%A5-spring-cloud-starter-alibaba-ai:
```yaml ```yaml
spring: spring:
ai: ai:
vectorstore: vectorstore:
redis: redis:
# Configure Redis connection URI, default value is redis://127.0.0.1:6379
# uri: redis://127.0.0.1:6379
index: peer index: peer
prefix: peer Prefix: peer
``` ```
## 4. Write the code ## 4. Write the code
@ -120,7 +125,7 @@ You can start the SprigBoot main class and then use a browser to access:
```shell ```shell
# request params is promptthe default valueWhat ber pairs well with smoked meats?" # request params is promptthe default valueWhat ber pairs well with smoked meats?"
http://localhost:8080/rag/chat http://localhost:8081/rag/chat
``` ```
To experience the RAG application. To experience the RAG application.

@ -40,7 +40,7 @@ services:
<dependency> <dependency>
<groupId>org.springframework.ai</groupId> <groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-redis-spring-boot-starter</artifactId> <artifactId>spring-ai-redis-store-spring-boot-starter</artifactId>
<version>${spring.ai.version}</version> <version>${spring.ai.version}</version>
</dependency> </dependency>
``` ```
@ -49,11 +49,16 @@ services:
在 application.yml 中配置如下信息: 在 application.yml 中配置如下信息:
> 注意:为了保证 apiKey 安全,建议通过环境变量的方式配置 apiKey。
> 参考https://github.com/alibaba/spring-cloud-alibaba/tree/2023.x/spring-cloud-alibaba-examples/ai-example/spring-cloud-ai-example#%E6%8E%A5%E5%85%A5-spring-cloud-starter-alibaba-ai:
```yaml ```yaml
spring: spring:
ai: ai:
vectorstore: vectorstore:
redis: redis:
# Configure the Redis connection URI, default value is redis://127.0.0.1:6379
# uri: redis://127.0.0.1:6379
index: peer index: peer
prefix: peer prefix: peer
``` ```
@ -120,7 +125,7 @@ private Message getSystemMessage(List<Document> similarDocuments) {
```shell ```shell
# 参数为 prompt默认值为What ber pairs well with smoked meats?" # 参数为 prompt默认值为What ber pairs well with smoked meats?"
http://localhost:8080/rag/chat http://localhost:8081/rag/chat
``` ```
来体验 RAG 应用。 来体验 RAG 应用。

@ -21,12 +21,17 @@ spring:
application: application:
name: sca-ai-rag-example name: sca-ai-rag-example
cloud: cloud:
ai: # We recommend configuring the api-key via an environment variable.
tongyi: # Please see https://github.com/alibaba/spring-cloud-alibaba/tree/2023.x/spring-cloud-alibaba-examples/ai-example/spring-cloud-ai-example#%E6%8E%A5%E5%85%A5-spring-cloud-starter-alibaba-ai:
api-key: sk-xxxxxx # ai:
# tongyi:
# connection:
# api-key: sk-xxxxxx
ai: ai:
vectorstore: vectorstore:
redis: redis:
uri: your redis addr # egredis://127.0.0.1:6379 # Configure the Redis connection URI, default value is redis://127.0.0.1:6379
# uri: redis://127.0.0.1:6379
index: peer index: peer
prefix: peer prefix: peer

@ -32,9 +32,9 @@ import static com.alibaba.cloud.ai.tongyi.common.constants.TongYiConstants.SCA_A
public class TongYiConnectionProperties { public class TongYiConnectionProperties {
/** /**
* Spring Cloud Alibaba AI connection configuration Prefix. * Spring Cloud Alibaba AI connection configuration prefix.
*/ */
public static final String CONFIG_PREFIX = SCA_AI_CONFIGURATION + "tongyi"; public static final String CONFIG_PREFIX = SCA_AI_CONFIGURATION + "connection";
/** /**
* TongYi LLM API key. * TongYi LLM API key.

Loading…
Cancel
Save