Class SpringAIPromptController

java.lang.Object
com.bytedesk.ai.springai.spring.SpringAIPromptController

@RestController @RequestMapping("/springai/prompt") @ConditionalOnProperty(name="spring.ai.ollama.chat.enabled", havingValue="true") public class SpringAIPromptController extends Object
Prompt Engineering 提示词工程 AI应用的核心:提示词的好坏直接影响AI的回答质量 Prompt四个核心要点: 1. 指令:明确告诉AI要做什么 2. 上下文:提供给AI一些相关的信息 3. 用户输入:用户输入的信息 4. 格式:告诉AI返回格式,比如json 另外可以提供一些示例:提供给AI一些示例 https://docs.spring.io/spring-ai/reference/api/prompt.html https://github.com/Azure-Samples/spring-ai-azure-workshop
  • Field Details

    • defaultChatClient

      private final org.springframework.ai.chat.client.ChatClient defaultChatClient
    • ollamaRedisVectorStore

      private final org.springframework.ai.vectorstore.VectorStore ollamaRedisVectorStore
    • jokeResource

      @Value("classpath:/aidemo/prompts/joke-prompt.st") private org.springframework.core.io.Resource jokeResource
    • systemResource

      @Value("classpath:/aidemo/prompts/system-message.st") private org.springframework.core.io.Resource systemResource
    • docsToStuffResource

      @Value("classpath:/aidemo/rag/wikipedia-curling.md") private org.springframework.core.io.Resource docsToStuffResource
    • qaPromptResource

      @Value("classpath:/aidemo/prompts/qa-prompt.st") private org.springframework.core.io.Resource qaPromptResource
    • bikesResource

      @Value("classpath:/aidemo/rag/bikes.json") private org.springframework.core.io.Resource bikesResource
    • systemBikePrompt

      @Value("classpath:/aidemo/prompts/system-qa.st") private org.springframework.core.io.Resource systemBikePrompt
  • Constructor Details

    • SpringAIPromptController

      public SpringAIPromptController()
  • Method Details

    • templating

      @GetMapping("/templating") public org.springframework.http.ResponseEntity<JsonResult<?>> templating(@RequestParam(value="adjective",defaultValue="funny") String adjective, @RequestParam(value="topic",defaultValue="cows") String topic)
    • roles

      @GetMapping("/roles") public org.springframework.http.ResponseEntity<JsonResult<?>> roles(@RequestParam(value="message",defaultValue="Tell me about three famous pirates from the Golden Age of Piracy and why they did. Write at least a sentence for each pirate.") String message, @RequestParam(value="name",defaultValue="Bob") String name, @RequestParam(value="voice",defaultValue="pirate") String voice)
    • stuff

      @GetMapping("/stuff") public org.springframework.http.ResponseEntity<JsonResult<?>> stuff(@RequestParam(value="message",defaultValue="Which athletes won the mixed doubles gold medal in curling at the 2022 Winter Olympics?\'") String message, @RequestParam(value="stuff",defaultValue="false") boolean stuff)
    • rag

      @GetMapping("/rag") public org.springframework.http.ResponseEntity<JsonResult<?>> rag(@RequestParam(value="message",defaultValue="What is the most popular bike brand?") String message)
    • generate

      @GetMapping("/format") public org.springframework.http.ResponseEntity<JsonResult<?>> generate(@RequestParam(value="actor",defaultValue="Jeff Bridges") String actor)
    • structured

      @GetMapping("/structured") public org.springframework.http.ResponseEntity<JsonResult<?>> structured(@RequestParam(value="message",defaultValue="Tell me about the actor Jeff Bridges") String message)
    • getSystemMessage

      private org.springframework.ai.chat.messages.Message getSystemMessage(List<org.springframework.ai.document.Document> similarDocuments)