Commit c22b5381 by 王祖波

openAi

parent 01fa3118
......@@ -37,6 +37,31 @@
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-openai</artifactId>
<version>1.0.0-beta.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>open-ai-sdk</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
......
......@@ -7,13 +7,12 @@ import com.gic.content.api.dto.aigc.AIGCContent;
import com.gic.content.api.qdto.aigc.ContentAIGCQDTO;
import com.gic.content.api.service.common.ThirdApiService;
import com.gic.haoban.manage.web.qo.content.ContentAIGCQO;
import com.open.ai.OpenAIUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
/**
* 好办-三方接口
......@@ -43,4 +42,16 @@ public class ContentThirdController {
}
return RestResponse.successResult(response.getResult());
}
/**
* openAI会话
* @param question
* @return
*/
@RequestMapping(value = "/ai/chat", method = RequestMethod.GET, produces = "text/event-stream;charset=UTF-8")
public SseEmitter openAiChat(String question,String userId,String enterpriseId) {
SseEmitter emitter = new SseEmitter(30000L);
OpenAIUtil.chat(emitter, question,userId,enterpriseId);
return emitter;
}
}
......@@ -37,6 +37,7 @@
<list>
<value>text/html;charset=UTF-8</value>
<value>application/x-www-form-urlencoded;charset=UTF-8</value>
<value>text/plain;charset=UTF-8</value>
<!--默认是 iso-8859-1 -->
</list>
</property>
......@@ -54,6 +55,7 @@
<list>
<value>text/html;charset=UTF-8</value>
<value>application/x-www-form-urlencoded;charset=UTF-8</value>
<value>text/plain;charset=UTF-8</value>
<!--默认是 iso-8859-1 -->
</list>
</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Archetype Created Web Application</display-name>
<context-param>
......@@ -23,6 +23,7 @@
<param-value>/WEB-INF/spring-*.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
......@@ -39,6 +40,7 @@
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
<filter>
......@@ -48,5 +50,6 @@
<filter-mapping>
<filter-name>springSessionRepositoryFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
</web-app>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment