master
			
			
		
		
							parent
							
								
									3c85f51768
								
							
						
					
					
						commit
						5701fb6c43
					
				@ -1,113 +1,112 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
	<modelVersion>4.0.0</modelVersion>
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
	<parent>
 | 
					    <parent>
 | 
				
			||||||
		<groupId>org.springframework.boot</groupId>
 | 
					        <groupId>org.springframework.boot</groupId>
 | 
				
			||||||
		<artifactId>spring-boot-starter-parent</artifactId>
 | 
					        <artifactId>spring-boot-starter-parent</artifactId>
 | 
				
			||||||
		<version>3.3.5</version>
 | 
					        <version>3.3.5</version>
 | 
				
			||||||
		<relativePath/> <!-- lookup parent from repository -->
 | 
					        <relativePath/> <!-- lookup parent from repository -->
 | 
				
			||||||
	</parent>
 | 
					    </parent>
 | 
				
			||||||
	<groupId>cn.lige2333</groupId>
 | 
					    <groupId>cn.lige2333</groupId>
 | 
				
			||||||
	<artifactId>ligeai</artifactId>
 | 
					    <artifactId>ligeai</artifactId>
 | 
				
			||||||
	<version>0.0.1-SNAPSHOT</version>
 | 
					    <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
	<name>ligeai</name>
 | 
					    <name>ligeai</name>
 | 
				
			||||||
	<description>ligeai</description>
 | 
					    <description>ligeai</description>
 | 
				
			||||||
	<url/>
 | 
					    <url/>
 | 
				
			||||||
	<licenses>
 | 
					    <licenses>
 | 
				
			||||||
		<license/>
 | 
					        <license/>
 | 
				
			||||||
	</licenses>
 | 
					    </licenses>
 | 
				
			||||||
	<developers>
 | 
					    <developers>
 | 
				
			||||||
		<developer/>
 | 
					        <developer/>
 | 
				
			||||||
	</developers>
 | 
					    </developers>
 | 
				
			||||||
	<scm>
 | 
					    <scm>
 | 
				
			||||||
		<connection/>
 | 
					        <connection/>
 | 
				
			||||||
		<developerConnection/>
 | 
					        <developerConnection/>
 | 
				
			||||||
		<tag/>
 | 
					        <tag/>
 | 
				
			||||||
		<url/>
 | 
					        <url/>
 | 
				
			||||||
	</scm>
 | 
					    </scm>
 | 
				
			||||||
	<properties>
 | 
					    <properties>
 | 
				
			||||||
		<java.version>17</java.version>
 | 
					        <java.version>17</java.version>
 | 
				
			||||||
		<spring-ai.version>1.0.0-M3</spring-ai.version>
 | 
					        <spring-ai.version>1.0.0-M3</spring-ai.version>
 | 
				
			||||||
	</properties>
 | 
					    </properties>
 | 
				
			||||||
	<dependencies>
 | 
					    <dependencies>
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>org.springframework.boot</groupId>
 | 
					            <groupId>org.springframework.boot</groupId>
 | 
				
			||||||
			<artifactId>spring-boot-starter-web</artifactId>
 | 
					            <artifactId>spring-boot-starter-web</artifactId>
 | 
				
			||||||
		</dependency>
 | 
					        </dependency>
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>org.springframework.boot</groupId>
 | 
					            <groupId>org.springframework.boot</groupId>
 | 
				
			||||||
			<artifactId>spring-boot-starter-webflux</artifactId>
 | 
					            <artifactId>spring-boot-starter-webflux</artifactId>
 | 
				
			||||||
		</dependency>
 | 
					        </dependency>
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>org.mybatis.spring.boot</groupId>
 | 
					            <groupId>com.alibaba</groupId>
 | 
				
			||||||
			<artifactId>mybatis-spring-boot-starter</artifactId>
 | 
					            <artifactId>fastjson</artifactId>
 | 
				
			||||||
			<version>3.0.3</version>
 | 
					            <version>1.2.58</version>
 | 
				
			||||||
		</dependency>
 | 
					        </dependency>
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>org.springframework.ai</groupId>
 | 
					            <groupId>cn.hutool</groupId>
 | 
				
			||||||
			<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
 | 
					            <artifactId>hutool-all</artifactId>
 | 
				
			||||||
		</dependency>
 | 
					            <version>5.8.21</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>org.springframework.ai</groupId>
 | 
				
			||||||
 | 
					            <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>org.projectlombok</groupId>
 | 
					            <groupId>org.projectlombok</groupId>
 | 
				
			||||||
			<artifactId>lombok</artifactId>
 | 
					            <artifactId>lombok</artifactId>
 | 
				
			||||||
			<optional>true</optional>
 | 
					            <optional>true</optional>
 | 
				
			||||||
		</dependency>
 | 
					        </dependency>
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>org.springframework.boot</groupId>
 | 
					            <groupId>org.springframework.boot</groupId>
 | 
				
			||||||
			<artifactId>spring-boot-starter-test</artifactId>
 | 
					            <artifactId>spring-boot-starter-test</artifactId>
 | 
				
			||||||
			<scope>test</scope>
 | 
					            <scope>test</scope>
 | 
				
			||||||
		</dependency>
 | 
					        </dependency>
 | 
				
			||||||
		<dependency>
 | 
					        <dependency>
 | 
				
			||||||
			<groupId>io.projectreactor</groupId>
 | 
					            <groupId>io.projectreactor</groupId>
 | 
				
			||||||
			<artifactId>reactor-test</artifactId>
 | 
					            <artifactId>reactor-test</artifactId>
 | 
				
			||||||
			<scope>test</scope>
 | 
					            <scope>test</scope>
 | 
				
			||||||
		</dependency>
 | 
					        </dependency>
 | 
				
			||||||
		<dependency>
 | 
					    </dependencies>
 | 
				
			||||||
			<groupId>org.mybatis.spring.boot</groupId>
 | 
					    <dependencyManagement>
 | 
				
			||||||
			<artifactId>mybatis-spring-boot-starter-test</artifactId>
 | 
					        <dependencies>
 | 
				
			||||||
			<version>3.0.3</version>
 | 
					            <dependency>
 | 
				
			||||||
			<scope>test</scope>
 | 
					                <groupId>org.springframework.ai</groupId>
 | 
				
			||||||
		</dependency>
 | 
					                <artifactId>spring-ai-bom</artifactId>
 | 
				
			||||||
	</dependencies>
 | 
					                <version>${spring-ai.version}</version>
 | 
				
			||||||
	<dependencyManagement>
 | 
					                <type>pom</type>
 | 
				
			||||||
		<dependencies>
 | 
					                <scope>import</scope>
 | 
				
			||||||
			<dependency>
 | 
					            </dependency>
 | 
				
			||||||
				<groupId>org.springframework.ai</groupId>
 | 
					        </dependencies>
 | 
				
			||||||
				<artifactId>spring-ai-bom</artifactId>
 | 
					    </dependencyManagement>
 | 
				
			||||||
				<version>${spring-ai.version}</version>
 | 
					 | 
				
			||||||
				<type>pom</type>
 | 
					 | 
				
			||||||
				<scope>import</scope>
 | 
					 | 
				
			||||||
			</dependency>
 | 
					 | 
				
			||||||
		</dependencies>
 | 
					 | 
				
			||||||
	</dependencyManagement>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<build>
 | 
					    <build>
 | 
				
			||||||
		<plugins>
 | 
					        <plugins>
 | 
				
			||||||
			<plugin>
 | 
					            <plugin>
 | 
				
			||||||
				<groupId>org.springframework.boot</groupId>
 | 
					                <groupId>org.springframework.boot</groupId>
 | 
				
			||||||
				<artifactId>spring-boot-maven-plugin</artifactId>
 | 
					                <artifactId>spring-boot-maven-plugin</artifactId>
 | 
				
			||||||
				<configuration>
 | 
					                <configuration>
 | 
				
			||||||
					<excludes>
 | 
					                    <excludes>
 | 
				
			||||||
						<exclude>
 | 
					                        <exclude>
 | 
				
			||||||
							<groupId>org.projectlombok</groupId>
 | 
					                            <groupId>org.projectlombok</groupId>
 | 
				
			||||||
							<artifactId>lombok</artifactId>
 | 
					                            <artifactId>lombok</artifactId>
 | 
				
			||||||
						</exclude>
 | 
					                        </exclude>
 | 
				
			||||||
					</excludes>
 | 
					                    </excludes>
 | 
				
			||||||
				</configuration>
 | 
					                </configuration>
 | 
				
			||||||
			</plugin>
 | 
					            </plugin>
 | 
				
			||||||
		</plugins>
 | 
					        </plugins>
 | 
				
			||||||
	</build>
 | 
					    </build>
 | 
				
			||||||
	<repositories>
 | 
					    <repositories>
 | 
				
			||||||
		<repository>
 | 
					        <repository>
 | 
				
			||||||
			<id>spring-milestones</id>
 | 
					            <id>spring-milestones</id>
 | 
				
			||||||
			<name>Spring Milestones</name>
 | 
					            <name>Spring Milestones</name>
 | 
				
			||||||
			<url>https://repo.spring.io/milestone</url>
 | 
					            <url>https://repo.spring.io/milestone</url>
 | 
				
			||||||
			<snapshots>
 | 
					            <snapshots>
 | 
				
			||||||
				<enabled>false</enabled>
 | 
					                <enabled>false</enabled>
 | 
				
			||||||
			</snapshots>
 | 
					            </snapshots>
 | 
				
			||||||
		</repository>
 | 
					        </repository>
 | 
				
			||||||
	</repositories>
 | 
					    </repositories>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</project>
 | 
					</project>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,2 +1,39 @@
 | 
				
			|||||||
package cn.lige2333.ligeai.chatgpt.controller;public class ChatGptController {
 | 
					package cn.lige2333.ligeai.chatgpt.controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.ai.chat.client.ChatClient;
 | 
				
			||||||
 | 
					import org.springframework.ai.openai.OpenAiChatModel;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.http.MediaType;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
 | 
					import reactor.core.publisher.Flux;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@RestController
 | 
				
			||||||
 | 
					@RequestMapping("/ajax")
 | 
				
			||||||
 | 
					@CrossOrigin
 | 
				
			||||||
 | 
					public class ChatGptController {
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private OpenAiChatModel chatModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final ChatClient chatClient;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ChatGptController(ChatClient.Builder chatClientBuilder) {
 | 
				
			||||||
 | 
					        this.chatClient = chatClientBuilder.build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @GetMapping("/ai/generate")
 | 
				
			||||||
 | 
					    public String generate(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
 | 
				
			||||||
 | 
					        return this.chatClient.prompt()
 | 
				
			||||||
 | 
					                .user(message)
 | 
				
			||||||
 | 
					                .call()
 | 
				
			||||||
 | 
					                .content();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @GetMapping(value = "/ai/generateStream",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
 | 
				
			||||||
 | 
					    public Flux<String> generateStream(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
 | 
				
			||||||
 | 
					        return this.chatClient.prompt()
 | 
				
			||||||
 | 
					                .user(message)
 | 
				
			||||||
 | 
					                .stream()
 | 
				
			||||||
 | 
					                .content();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1 +1,4 @@
 | 
				
			|||||||
spring.application.name=ligeai
 | 
					spring.application.name=ligeai
 | 
				
			||||||
 | 
					server.port=8100
 | 
				
			||||||
 | 
					spring.ai.openai.api-key=123
 | 
				
			||||||
 | 
					spring.ai.openai.base-url=123
 | 
				
			||||||
					Loading…
					
					
				
		Reference in New Issue