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

    Fields
    Modifier and Type
    Field
    Description
    private final ExecutorService
     
    private final SpringAIOllamaService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.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
    chatSSE(String message)
    方式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<?>>
    chatSync(String message)
    方式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/health
    void
    获取Ollama所有可用的模型列表 http://127.0.0.1:9003/springai/ollama/models

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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

      @GetMapping("/health") public org.springframework.http.ResponseEntity<JsonResult<?>> 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