Package com.bytedesk.ai.springai.ollama
Class SpringAIOllamaController
java.lang.Object
com.bytedesk.ai.springai.ollama.SpringAIOllamaController
@RestController
@RequestMapping("/springai/ollama")
@ConditionalOnProperty(name="spring.ai.ollama.chat.enabled",
havingValue="true")
public class SpringAIOllamaController
extends Object
Ollama接口
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExecutorService
private final SpringAIOllamaService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<JsonResult<?>>
chatCustom
(String message) 自定义模型参数的调用示例 http://127.0.0.1:9003/springai/ollama/chat/custom?org.springframework.web.servlet.mvc.method.annotation.SseEmitter
方式3:SSE调用 http://127.0.0.1:9003/springai/ollama/chat/sse?reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse>
chatStream
(String message) 方式2:异步流式调用 http://127.0.0.1:9003/springai/ollama/chat/stream?org.springframework.http.ResponseEntity<JsonResult<?>>
方式1:同步调用 http://127.0.0.1:9003/springai/ollama/chat/sync?org.springframework.http.ResponseEntity<JsonResult<?>>
检测Ollama服务是否正常运行 http://127.0.0.1:9003/springai/ollama/healthvoid
destroy()
获取Ollama所有可用的模型列表 http://127.0.0.1:9003/springai/ollama/models
-
Field Details
-
springAIOllamaService
-
executorService
-
-
Constructor Details
-
SpringAIOllamaController
public SpringAIOllamaController()
-
-
Method Details
-
chatSync
@GetMapping("/chat/sync") public org.springframework.http.ResponseEntity<JsonResult<?>> chatSync(@RequestParam(value="message",defaultValue="Tell me a joke") String message) 方式1:同步调用 http://127.0.0.1:9003/springai/ollama/chat/sync?message=hello -
chatStream
@GetMapping("/chat/stream") public reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> chatStream(@RequestParam(value="message",defaultValue="Tell me a joke") String message) 方式2:异步流式调用 http://127.0.0.1:9003/springai/ollama/chat/stream?message=hello -
chatSSE
@GetMapping(value="/chat/sse", produces="text/event-stream") public org.springframework.web.servlet.mvc.method.annotation.SseEmitter chatSSE(@RequestParam("message") String message) 方式3:SSE调用 http://127.0.0.1:9003/springai/ollama/chat/sse?message=hello -
chatCustom
@GetMapping("/chat/custom") public org.springframework.http.ResponseEntity<JsonResult<?>> chatCustom(@RequestParam(value="message",defaultValue="Tell me a joke") String message) 自定义模型参数的调用示例 http://127.0.0.1:9003/springai/ollama/chat/custom?message=hello -
checkHealth
检测Ollama服务是否正常运行 http://127.0.0.1:9003/springai/ollama/health -
destroy
public void destroy()获取Ollama所有可用的模型列表 http://127.0.0.1:9003/springai/ollama/models
-