dev : 合并提交 #41
| @ -1,12 +1,11 @@ | |||||||
| package org.jcnc.llmx.core.spi.provider | package org.jcnc.llmx.core.spi.provider | ||||||
| 
 | 
 | ||||||
| import kotlinx.coroutines.flow.Flow |  | ||||||
| import org.jcnc.llmx.core.spi.entities.request.ChatRequest | import org.jcnc.llmx.core.spi.entities.request.ChatRequest | ||||||
| import org.jcnc.llmx.core.spi.entities.request.EmbeddingRequest | import org.jcnc.llmx.core.spi.entities.request.EmbeddingRequest | ||||||
| import org.jcnc.llmx.core.spi.entities.response.ChatResponsePart | import org.jcnc.llmx.core.spi.entities.response.ChatResponsePart | ||||||
| import org.jcnc.llmx.core.spi.entities.response.EmbeddingResponse | import org.jcnc.llmx.core.spi.entities.response.EmbeddingResponse | ||||||
|  | import org.reactivestreams.Publisher | ||||||
| import org.springframework.http.MediaType | import org.springframework.http.MediaType | ||||||
| 
 |  | ||||||
| import org.springframework.web.bind.annotation.PostMapping | import org.springframework.web.bind.annotation.PostMapping | ||||||
| import org.springframework.web.bind.annotation.RequestMapping | import org.springframework.web.bind.annotation.RequestMapping | ||||||
| 
 | 
 | ||||||
| @ -31,7 +30,7 @@ interface LLMProvider { | |||||||
|      * @return 返回一个Flow流,通过该流可以接收到聊天响应的部分数据,如消息、状态更新等 |      * @return 返回一个Flow流,通过该流可以接收到聊天响应的部分数据,如消息、状态更新等 | ||||||
|      */ |      */ | ||||||
|     @PostMapping("/chat", produces = [MediaType.APPLICATION_NDJSON_VALUE]) |     @PostMapping("/chat", produces = [MediaType.APPLICATION_NDJSON_VALUE]) | ||||||
|     fun chat(request: ChatRequest): Flow<ChatResponsePart> |     fun chat(request: ChatRequest): Publisher<ChatResponsePart> | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 嵌入功能方法 |      * 嵌入功能方法 | ||||||
|  | |||||||
| @ -1,16 +1,19 @@ | |||||||
| package org.jcnc.llmx.impl.baiLian.controller | package org.jcnc.llmx.impl.baiLian.controller | ||||||
| 
 | 
 | ||||||
| import kotlinx.coroutines.flow.Flow | 
 | ||||||
|  | import kotlinx.coroutines.reactive.asPublisher | ||||||
| import org.jcnc.llmx.core.spi.entities.request.ChatRequest | import org.jcnc.llmx.core.spi.entities.request.ChatRequest | ||||||
| import org.jcnc.llmx.core.spi.entities.request.EmbeddingRequest | import org.jcnc.llmx.core.spi.entities.request.EmbeddingRequest | ||||||
| import org.jcnc.llmx.core.spi.entities.response.ChatResponsePart | import org.jcnc.llmx.core.spi.entities.response.ChatResponsePart | ||||||
| import org.jcnc.llmx.core.spi.entities.response.EmbeddingResponse | import org.jcnc.llmx.core.spi.entities.response.EmbeddingResponse | ||||||
| import org.jcnc.llmx.core.spi.provider.LLMProvider | import org.jcnc.llmx.core.spi.provider.LLMProvider | ||||||
| import org.jcnc.llmx.impl.baiLian.service.BaiLianModelService | import org.jcnc.llmx.impl.baiLian.service.BaiLianModelService | ||||||
|  | import org.reactivestreams.Publisher | ||||||
| 
 | 
 | ||||||
| import org.springframework.web.bind.annotation.RequestBody | import org.springframework.web.bind.annotation.RequestBody | ||||||
| import org.springframework.web.bind.annotation.RestController | import org.springframework.web.bind.annotation.RestController | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  *百炼提供商 |  *百炼提供商 | ||||||
|  * |  * | ||||||
| @ -18,10 +21,9 @@ import org.springframework.web.bind.annotation.RestController | |||||||
|  * @author gewuyou |  * @author gewuyou | ||||||
|  */ |  */ | ||||||
| @RestController | @RestController | ||||||
| //@RequestMapping("/provider") |  | ||||||
| class BaiLianProvider( | class BaiLianProvider( | ||||||
|     private val baiLianModelService: BaiLianModelService |     private val baiLianModelService: BaiLianModelService | ||||||
| ): LLMProvider { | ) : LLMProvider { | ||||||
|     /** |     /** | ||||||
|      * 初始化与聊天服务的连接,以处理聊天请求 |      * 初始化与聊天服务的连接,以处理聊天请求 | ||||||
|      * |      * | ||||||
| @ -31,9 +33,8 @@ class BaiLianProvider( | |||||||
|      * @param request 聊天请求对象,包含建立聊天所需的信息,如用户标识、会话标识等 |      * @param request 聊天请求对象,包含建立聊天所需的信息,如用户标识、会话标识等 | ||||||
|      * @return 返回一个Flow流,通过该流可以接收到聊天响应的部分数据,如消息、状态更新等 |      * @return 返回一个Flow流,通过该流可以接收到聊天响应的部分数据,如消息、状态更新等 | ||||||
|      */ |      */ | ||||||
| //    @PostMapping("/chat") |     override fun chat(@RequestBody request: ChatRequest): Publisher<ChatResponsePart> { | ||||||
|     override fun chat(@RequestBody request: ChatRequest): Flow<ChatResponsePart> { |         return baiLianModelService.streamChat(request).asPublisher() | ||||||
|         return baiLianModelService.streamChat(request) |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user