1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[5849],{28453:(e,i,n)=>{n.d(i,{R:()=>l,x:()=>a});var d=n(96540);const r={},s=d.createContext(r);function l(e){const i=d.useContext(s);return d.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function a(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),d.createElement(s.Provider,{value:i},e.children)}},31943:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>t,contentTitle:()=>a,default:()=>h,frontMatter:()=>l,metadata:()=>d,toc:()=>c});const d=JSON.parse('{"id":"rag/embeddings/more/mistralai-embeddings","title":"Mistral AI Embeddings","description":"Spring AI \u652f\u6301 Mistral AI \u7684\u6587\u672c embeddings \u6a21\u578b\u3002","source":"@site/integration/rag/embeddings/more/mistralai-embeddings.md","sourceDirName":"rag/embeddings/more","slug":"/rag/embeddings/more/mistralai-embeddings","permalink":"/integration/rag/embeddings/more/mistralai-embeddings","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/integration/rag/embeddings/more/mistralai-embeddings.md","tags":[],"version":"current","lastUpdatedBy":"Ken Liu","lastUpdatedAt":1768271906000,"frontMatter":{},"sidebar":"integrationSidebar","previous":{"title":"MiniMax Embeddings","permalink":"/integration/rag/embeddings/more/minimax-embeddings"},"next":{"title":"Oracle Cloud Infrastructure (OCI) GenAI Embeddings","permalink":"/integration/rag/embeddings/more/oci-genai-embeddings"}}');var r=n(74848),s=n(28453);const l={},a="Mistral AI Embeddings",t={},c=[{value:"\u53ef\u7528\u6a21\u578b",id:"\u53ef\u7528\u6a21\u578b",level:2},{value:"\u5148\u51b3\u6761\u4ef6",id:"\u5148\u51b3\u6761\u4ef6",level:2},{value:"\u6dfb\u52a0\u4ed3\u5e93\u548c BOM",id:"\u6dfb\u52a0\u4ed3\u5e93\u548c-bom",level:3},{value:"\u81ea\u52a8\u914d\u7f6e",id:"\u81ea\u52a8\u914d\u7f6e",level:2},{value:"Embedding \u5c5e\u6027",id:"embedding-\u5c5e\u6027",level:3},{value:"Retry \u5c5e\u6027",id:"retry-\u5c5e\u6027",level:4},{value:"\u8fde\u63a5\u5c5e\u6027",id:"\u8fde\u63a5\u5c5e\u6027",level:4},{value:"\u914d\u7f6e\u5c5e\u6027",id:"\u914d\u7f6e\u5c5e\u6027",level:4},{value:"\u8fd0\u884c\u65f6\u9009\u9879",id:"\u8fd0\u884c\u65f6\u9009\u9879",level:2},{value:"\u793a\u4f8b Controller",id:"\u793a\u4f8b-controller",level:2},{value:"\u624b\u52a8\u914d\u7f6e",id:"\u624b\u52a8\u914d\u7f6e",level:2}];function o(e){const i={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.header,{children:(0,r.jsx)(i.h1,{id:"mistral-ai-embeddings",children:"Mistral AI Embeddings"})}),"\n",(0,r.jsx)(i.p,{children:"Spring AI \u652f\u6301 Mistral AI \u7684\u6587\u672c embeddings \u6a21\u578b\u3002\nEmbeddings \u662f\u6587\u672c\u7684\u5411\u91cf\u8868\u793a\uff0c\u901a\u8fc7\u5b83\u4eec\u5728\u9ad8\u7ef4\u5411\u91cf\u7a7a\u95f4\u4e2d\u7684\u4f4d\u7f6e\u6355\u83b7\u6bb5\u843d\u7684\u8bed\u4e49\u542b\u4e49\u3002Mistral AI Embeddings API \u63d0\u4f9b\u6700\u5148\u8fdb\u7684\u6587\u672c embeddings\uff0c\u53ef\u7528\u4e8e\u8bb8\u591a NLP \u4efb\u52a1\u3002"}),"\n",(0,r.jsx)(i.h2,{id:"\u53ef\u7528\u6a21\u578b",children:"\u53ef\u7528\u6a21\u578b"}),"\n",(0,r.jsx)(i.p,{children:"Mistral AI \u63d0\u4f9b\u4e24\u4e2a embedding \u6a21\u578b\uff0c\u6bcf\u4e2a\u90fd\u9488\u5bf9\u4e0d\u540c\u7684\u7528\u4f8b\u8fdb\u884c\u4e86\u4f18\u5316\uff1a"}),"\n",(0,r.jsxs)(i.table,{children:[(0,r.jsx)(i.thead,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.th,{children:"Model"}),(0,r.jsx)(i.th,{children:"Dimensions"}),(0,r.jsx)(i.th,{children:"Use Case"}),(0,r.jsx)(i.th,{children:"Description"})]})}),(0,r.jsxs)(i.tbody,{children:[(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:(0,r.jsx)(i.code,{children:"mistral-embed"})}),(0,r.jsx)(i.td,{children:"1024"}),(0,r.jsx)(i.td,{children:"General text"}),(0,r.jsx)(i.td,{children:"\u9002\u7528\u4e8e\u8bed\u4e49\u641c\u7d22\u3001\u805a\u7c7b\u548c\u6587\u672c\u76f8\u4f3c\u6027\u4efb\u52a1\u7684\u901a\u7528 embedding \u6a21\u578b\u3002\u9002\u5408\u81ea\u7136\u8bed\u8a00\u5185\u5bb9\u3002"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:(0,r.jsx)(i.co
1de,{children:"codestral-embed"})}),(0,r.jsx)(i.td,{children:"1536"}),(0,r.jsx)(i.td,{children:"Code"}),(0,r.jsx)(i.td,{children:"\u4e13\u95e8\u9488\u5bf9\u4ee3\u7801\u76f8\u4f3c\u6027\u3001\u4ee3\u7801\u641c\u7d22\u548c\u4ee3\u7801\u4ed3\u5e93\u7684\u68c0\u7d22\u589e\u5f3a\u751f\u6210 (RAG) \u8fdb\u884c\u4f18\u5316\u7684 embedding \u6a21\u578b\u3002\u63d0\u4f9b\u4e13\u95e8\u4e3a\u7406\u89e3\u4ee3\u7801\u8bed\u4e49\u800c\u8bbe\u8ba1\u7684\u9ad8\u7ef4 embeddings\u3002"})]})]})]}),"\n",(0,r.jsx)(i.p,{children:"\u9009\u62e9\u6a21\u578b\u65f6\uff1a"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:["\u5bf9\u4e8e\u4e00\u822c\u6587\u672c\u5185\u5bb9\uff08\u5982\u6587\u6863\u3001\u6587\u7ae0\u6216\u7528\u6237\u67e5\u8be2\uff09\uff0c\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"mistral-embed"})]}),"\n",(0,r.jsxs)(i.li,{children:["\u5728\u5904\u7406\u4ee3\u7801\u3001\u6280\u672f\u6587\u6863\u6216\u6784\u5efa\u4ee3\u7801\u611f\u77e5\u7684 RAG \u7cfb\u7edf\u65f6\uff0c\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"codestral-embed"})]}),"\n"]}),"\n",(0,r.jsx)(i.h2,{id:"\u5148\u51b3\u6761\u4ef6",children:"\u5148\u51b3\u6761\u4ef6"}),"\n",(0,r.jsx)(i.p,{children:"\u60a8\u9700\u8981\u521b\u5efa\u4e00\u4e2a API \u6765\u8bbf\u95ee MistralAI embeddings \u6a21\u578b\u3002"}),"\n",(0,r.jsxs)(i.p,{children:["\u5728 ",(0,r.jsx)(i.a,{href:"https://auth.mistral.ai/ui/registration%5BMistralAI",children:"https://auth.mistral.ai/ui/registration[MistralAI"})," \u6ce8\u518c\u9875\u9762] \u521b\u5efa\u8d26\u6237\uff0c\u5e76\u5728 ",(0,r.jsx)(i.a,{href:"https://console.mistral.ai/api-keys/%5BAPI",children:"https://console.mistral.ai/api-keys/[API"})," Keys \u9875\u9762] \u751f\u6210 token\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["Spring AI \u9879\u76ee\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.api-key"})," \u7684\u914d\u7f6e\u5c5e\u6027\uff0c\u60a8\u5e94\u8be5\u5c06\u5176\u8bbe\u7f6e\u4e3a\u4ece console.mistral.ai \u83b7\u53d6\u7684 ",(0,r.jsx)(i.code,{children:"API Key"})," \u7684\u503c\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u60a8\u53ef\u4ee5\u5728 ",(0,r.jsx)(i.code,{children:"application.properties"})," \u6587\u4ef6\u4e2d\u8bbe\u7f6e\u6b64\u914d\u7f6e\u5c5e\u6027\uff1a"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-properties",children:"spring.ai.mistralai.api-key=<your-mistralai-api-key>\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u4e3a\u4e86\u5728\u5904\u7406\u654f\u611f\u4fe1\u606f\uff08\u5982 API keys\uff09\u65f6\u589e\u5f3a\u5b89\u5168\u6027\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Spring Expression Language (SpEL) \u5f15\u7528\u73af\u5883\u53d8\u91cf\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-yaml",children:"# In application.yml\nspring:\n ai:\n mistralai:\n api-key: ${MISTRALAI_API_KEY}\n"})}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"# In your environment or .env file\nexport MISTRALAI_API_KEY=<your-mistralai-api-key>\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u60a8\u8fd8\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e2d\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u8bbe\u7f6e\u6b64\u914d\u7f6e\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-java",children:'// Retrieve API key from a secure source or environment variable\nString apiKey = System.getenv("MISTRALAI_API_KEY");\n'})}),"\n",(0,r.jsx)(i.h3,{id:"\u6dfb\u52a0\u4ed3\u5e93\u548c-bom",children:"\u6dfb\u52a0\u4ed3\u5e93\u548c BOM"}),"\n",(0,r.jsxs)(i.p,{children:["Spring AI \u5de5\u4ef6\u53d1\u5e03\u5728 Maven Central \u548c Spring Snapshot \u4ed3\u5e93\u4e2d\u3002\n\u8bf7\u53c2\u9605 ",(0,r.jsx)(i.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#artifact-repositories",children:"Artifact Repositories"})," \u90e8\u5206\uff0c\u5c06\u8fd9\u4e9b\u4ed3\u5e93\u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u7cfb\u7edf\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u4e3a\u4e86\u5e2e\u52a9\u4f9d\u8d56\u7ba1\u7406\uff0cSpring AI \u63d0\u4f9b\u4e86\u4e00\u4e2a BOM\uff08\u7269\u6599\u6e05\u5355\uff09\uff0c\u4ee5\u786e\u4fdd\u5728\u6574\u4e2a\u9879\u76ee\u4e2d\u4f7f\u7528\u4e00\u81f4\u7248\u672c\u7684 Spring AI\u3002\u8bf7\u53c2\u9605 ",(0,r.jsx)(i.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u7cfb\u7edf\u3002"]}),"\n",(0,r.jsx)(i.h2,{id:"\u81ea\u52a8\u914d\u7f6e",children:"\u81ea\u52a8\u914d\u7f6e"}),"\n",(0,r.jsx)(i.h1,{id:"\u6ce8\u610f",children:"[\u6ce8\u610f]"}),"\n",(0,r.jsxs)(i.h1,{id:"spring-ai-\u81ea\u52a8\u914d\u7f6estarter-\u6a21\u5757\u7684\u5de5\u4ef6\u540d\u79f0\u53d1\u751f\u4e86\u91cd\u5927\u53d8\u5316\u8bf7\u53c2\u9605-httpsdocsspringiospring-aireferenceupgrade-noteshtml\u5347\u7ea7\u8bf4\u660e-\u4e86\u89e3\u66f4\u591a\u4fe1\u606f",children:["Spring AI \u81ea\u52a8\u914d\u7f6e\u3001starter \u6a21\u5757\u7684\u5de5\u4ef6\u540d\u79f0\u53d1\u751f\u4e86\u91cd\u5927\u53d8\u5316\u3002\n\u8bf7\u53c2\u9605 ",(0,r.jsx)(i.a,{href:"https://docs.spring.io/spring-ai/reference/upgrade-notes.html%5B%E5%8D%87%E7%BA%A7%E8%AF%B4%E6%98%8E",children:"https://docs.spring.io/spring-ai/reference/upgrade-notes.html[\u5347\u7ea7\u8bf4\u660e"}),"] \u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["Spring AI \u4e3a MistralAI Embedding Model \u63d0\u4f9b Spring Boot \u81ea\u52a8\u914d\u7f6e\u3002\n\u8981\u542f\u7528\u5b83\uff0c\u8bf7\u5c06\u4ee5\u4e0b\u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u9879\u76ee\u7684 Maven ",(0,r.jsx)(i.co
1de,{children:"pom.xml"})," \u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-xml",children:"<dependency>\n <groupId>org.springframework.ai</groupId>\n <artifactId>spring-ai-starter-model-mistral-ai</artifactId>\n</dependency>\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u6216\u6dfb\u52a0\u5230\u60a8\u7684 Gradle ",(0,r.jsx)(i.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-groovy",children:"dependencies {\n implementation 'org.springframework.ai:spring-ai-starter-model-mistral-ai'\n}\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u63d0\u793a\uff1a\u8bf7\u53c2\u9605 ",(0,r.jsx)(i.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"embedding-\u5c5e\u6027",children:"Embedding \u5c5e\u6027"}),"\n",(0,r.jsx)(i.h4,{id:"retry-\u5c5e\u6027",children:"Retry \u5c5e\u6027"}),"\n",(0,r.jsxs)(i.p,{children:["\u524d\u7f00 ",(0,r.jsx)(i.code,{children:"spring.ai.retry"})," \u7528\u4f5c\u5141\u8bb8\u60a8\u914d\u7f6e Mistral AI Embedding \u6a21\u578b\u7684\u91cd\u8bd5\u673a\u5236\u7684\u5c5e\u6027\u524d\u7f00\u3002"]}),"\n",(0,r.jsxs)(i.table,{children:[(0,r.jsx)(i.thead,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.th,{children:"Property"}),(0,r.jsx)(i.th,{children:"Description"}),(0,r.jsx)(i.th,{children:"Default"})]})}),(0,r.jsxs)(i.tbody,{children:[(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.max-attempts"}),(0,r.jsx)(i.td,{children:"\u6700\u5927\u91cd\u8bd5\u6b21\u6570\u3002"}),(0,r.jsx)(i.td,{children:"10"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.backoff.initial-interval"}),(0,r.jsx)(i.td,{children:"\u6307\u6570\u9000\u907f\u7b56\u7565\u7684\u521d\u59cb\u7761\u7720\u6301\u7eed\u65f6\u95f4\u3002"}),(0,r.jsx)(i.td,{children:"2 sec."})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.backoff.multiplier"}),(0,r.jsx)(i.td,{children:"\u9000\u907f\u95f4\u9694\u4e58\u6570\u3002"}),(0,r.jsx)(i.td,{children:"5"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.backoff.max-interval"}),(0,r.jsx)(i.td,{children:"\u6700\u5927\u9000\u907f\u6301\u7eed\u65f6\u95f4\u3002"}),(0,r.jsx)(i.td,{children:"3 min."})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.on-client-errors"}),(0,r.jsxs)(i.td,{children:["\u5982\u679c\u4e3a false\uff0c\u629b\u51fa NonTransientAiException\uff0c\u5e76\u4e14\u4e0d\u5bf9 ",(0,r.jsx)(i.code,{children:"4xx"})," \u5ba2\u6237\u7aef\u9519\u8bef\u4ee3\u7801\u5c1d\u8bd5\u91cd\u8bd5"]}),(0,r.jsx)(i.td,{children:"false"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.exclude-on-http-codes"}),(0,r.jsx)(i.td,{children:"\u4e0d\u5e94\u89e6\u53d1\u91cd\u8bd5\u7684 HTTP \u72b6\u6001\u4ee3\u7801\u5217\u8868\uff08\u4f8b\u5982\uff0c\u629b\u51fa NonTransientAiException\uff09\u3002"}),(0,r.jsx)(i.td,{children:"empty"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.retry.on-http-codes"}),(0,r.jsx)(i.td,{children:"\u5e94\u89e6\u53d1\u91cd\u8bd5\u7684 HTTP \u72b6\u6001\u4ee3\u7801\u5217\u8868\uff08\u4f8b\u5982\uff0c\u629b\u51fa TransientAiException\uff09\u3002"}),(0,r.jsx)(i.td,{children:"empty"})]})]})]}),"\n",(0,r.jsx)(i.h4,{id:"\u8fde\u63a5\u5c5e\u6027",children:"\u8fde\u63a5\u5c5e\u6027"}),"\n",(0,r.jsxs)(i.p,{children:["\u524d\u7f00 ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai"})," \u7528\u4f5c\u5141\u8bb8\u60a8\u8fde\u63a5\u5230 MistralAI \u7684\u5c5e\u6027\u524d\u7f00\u3002"]}),"\n",(0,r.jsxs)(i.table,{children:[(0,r.jsx)(i.thead,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.th,{children:"Property"}),(0,r.jsx)(i.th,{children:"Description"}),(0,r.jsx)(i.th,{children:"Default"})]})}),(0,r.jsxs)(i.tbody,{children:[(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.base-url"}),(0,r.jsx)(i.td,{children:"\u8981\u8fde\u63a5\u5230\u7684 URL"}),(0,r.jsx)(i.td,{children:(0,r.jsx)(i.a,{href:"https://api.mistral.ai",children:"https://api.mistral.ai"})})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.api-key"}),(0,r.jsx)(i.td,{children:"API Key"}),(0,r.jsx)(i.td,{children:"-"})]})]})]}),"\n",(0,r.jsx)(i.h4,{id:"\u914d\u7f6e\u5c5e\u6027",children:"\u914d\u7f6e\u5c5e\u6027"}),"\n",(0,r.jsx)(i.h1,{id:"\u6ce8\u610f-1",children:"[\u6ce8\u610f]"}
1),"\n",(0,r.jsxs)(i.p,{children:["\u73b0\u5728\u901a\u8fc7\u524d\u7f00\u4e3a ",(0,r.jsx)(i.code,{children:"spring.ai.model.embedding"})," \u7684\u9876\u7ea7\u5c5e\u6027\u6765\u914d\u7f6e embedding \u81ea\u52a8\u914d\u7f6e\u7684\u542f\u7528\u548c\u7981\u7528\u3002"]}),"\n",(0,r.jsx)(i.p,{children:"\u8981\u542f\u7528\uff0cspring.ai.model.embedding=mistral\uff08\u9ed8\u8ba4\u542f\u7528\uff09"}),"\n",(0,r.jsx)(i.p,{children:"\u8981\u7981\u7528\uff0cspring.ai.model.embedding=none\uff08\u6216\u4efb\u4f55\u4e0d\u5339\u914d mistral \u7684\u503c\uff09"}),"\n",(0,r.jsx)(i.h1,{id:"\u8fdb\u884c\u6b64\u66f4\u6539\u662f\u4e3a\u4e86\u5141\u8bb8\u914d\u7f6e\u591a\u4e2a\u6a21\u578b",children:"\u8fdb\u884c\u6b64\u66f4\u6539\u662f\u4e3a\u4e86\u5141\u8bb8\u914d\u7f6e\u591a\u4e2a\u6a21\u578b\u3002"}),"\n",(0,r.jsxs)(i.p,{children:["\u524d\u7f00 ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.embedding"})," \u662f\u914d\u7f6e MistralAI \u7684 ",(0,r.jsx)(i.code,{children:"EmbeddingModel"})," \u5b9e\u73b0\u7684\u5c5e\u6027\u524d\u7f00\u3002"]}),"\n",(0,r.jsxs)(i.table,{children:[(0,r.jsx)(i.thead,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.th,{children:"Property"}),(0,r.jsx)(i.th,{children:"Description"}),(0,r.jsx)(i.th,{children:"Default"})]})}),(0,r.jsxs)(i.tbody,{children:[(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.embedding.enabled (\u5df2\u79fb\u9664\u4e14\u4e0d\u518d\u6709\u6548)"}),(0,r.jsx)(i.td,{children:"\u542f\u7528 OpenAI embedding \u6a21\u578b\u3002"}),(0,r.jsx)(i.td,{children:"true"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.model.embedding"}),(0,r.jsx)(i.td,{children:"\u542f\u7528 OpenAI embedding \u6a21\u578b\u3002"}),(0,r.jsx)(i.td,{children:"mistral"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.embedding.base-url"}),(0,r.jsx)(i.td,{children:"\u53ef\u9009\u8986\u76d6 spring.ai.mistralai.base-url \u4ee5\u63d0\u4f9b embedding \u7279\u5b9a\u7684 url"}),(0,r.jsx)(i.td,{children:"-"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.embedding.api-key"}),(0,r.jsx)(i.td,{children:"\u53ef\u9009\u8986\u76d6 spring.ai.mistralai.api-key \u4ee5\u63d0\u4f9b embedding \u7279\u5b9a\u7684 api-key"}),(0,r.jsx)(i.td,{children:"-"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.embedding.metadata-mode"}),(0,r.jsx)(i.td,{children:"\u6587\u6863\u5185\u5bb9\u63d0\u53d6\u6a21\u5f0f\u3002"}),(0,r.jsx)(i.td,{children:"EMBED"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.embedding.options.model"}),(0,r.jsx)(i.td,{children:"\u8981\u4f7f\u7528\u7684\u6a21\u578b"}),(0,r.jsx)(i.td,{children:"mistral-embed"})]}),(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{children:"spring.ai.mistralai.embedding.options.encodingFormat"}),(0,r.jsx)(i.td,{children:"\u8fd4\u56de embeddings \u7684\u683c\u5f0f\u3002\u53ef\u4ee5\u662f float \u6216 base64\u3002"}),(0,r.jsx)(i.td,{children:"-"})]})]})]}),"\n",(0,r.jsxs)(i.p,{children:["\u6ce8\u610f\uff1a\u60a8\u53ef\u4ee5\u4e3a ",(0,r.jsx)(i.code,{children:"ChatModel"})," \u548c ",(0,r.jsx)(i.code,{children:"EmbeddingModel"})," \u5b9e\u73b0\u8986\u76d6\u901a\u7528\u7684 ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.base-url"})," \u548c ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.api-key"}),"\u3002\n\u5982\u679c\u8bbe\u7f6e\u4e86 ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.embedding.base-url"})," \u548c ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.embedding.api-key"})," \u5c5e\u6027\uff0c\u5b83\u4eec\u4f18\u5148\u4e8e\u901a\u7528\u5c5e\u6027\u3002\n\u540c\u6837\uff0c\u5982\u679c\u8bbe\u7f6e\u4e86 ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.chat.base-url"})," \u548c ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.chat.api-key"})," \u5c5e\u6027\uff0c\u5b83\u4eec\u4f18\u5148\u4e8e\u901a\u7528\u5c5e\u6027\u3002\n\u5982\u679c\u60a8\u60f3\u4e3a\u4e0d\u540c\u7684\u6a21\u578b\u548c\u4e0d\u540c\u7684\u6a21\u578b\u7aef\u70b9\u4f7f\u7528\u4e0d\u540c\u7684 MistralAI \u8d26\u6237\uff0c\u8fd9\u5f88\u6709\u7528\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u63d0\u793a\uff1a\u6240\u6709\u524d\u7f00\u4e3a ",(0,r.jsx)(i.co
1de,{children:"spring.ai.mistralai.embedding.options"})," \u7684\u5c5e\u6027\u90fd\u53ef\u4ee5\u901a\u8fc7\u5728 ",(0,r.jsx)(i.code,{children:"EmbeddingRequest"})," \u8c03\u7528\u4e2d\u6dfb\u52a0\u7279\u5b9a\u4e8e\u8bf7\u6c42\u7684 ",(0,r.jsx)(i.a,{href:"#embedding-options",children:"embedding-options"})," \u5728\u8fd0\u884c\u65f6\u8986\u76d6\u3002"]}),"\n",(0,r.jsx)(i.h2,{id:"\u8fd0\u884c\u65f6\u9009\u9879",children:"\u8fd0\u884c\u65f6\u9009\u9879"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiEmbeddingOptions.java%5BMistralAiEmbeddingOptions.java",children:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiEmbeddingOptions.java[MistralAiEmbeddingOptions.java"}),"] \u63d0\u4f9b MistralAI \u914d\u7f6e\uff0c\u4f8b\u5982\u8981\u4f7f\u7528\u7684\u6a21\u578b\u7b49\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u4e5f\u53ef\u4ee5\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"spring.ai.mistralai.embedding.options"})," \u5c5e\u6027\u914d\u7f6e\u9ed8\u8ba4\u9009\u9879\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u5728\u542f\u52a8\u65f6\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"MistralAiEmbeddingModel"})," \u6784\u9020\u51fd\u6570\u6765\u8bbe\u7f6e\u7528\u4e8e\u6240\u6709 embedding \u8bf7\u6c42\u7684\u9ed8\u8ba4\u9009\u9879\u3002\n\u5728\u8fd0\u884c\u65f6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"MistralAiEmbeddingOptions"})," \u5b9e\u4f8b\u4f5c\u4e3a ",(0,r.jsx)(i.code,{children:"EmbeddingRequest"})," \u7684\u4e00\u90e8\u5206\u6765\u8986\u76d6\u9ed8\u8ba4\u9009\u9879\u3002"]}),"\n",(0,r.jsx)(i.p,{children:"\u4f8b\u5982\uff0c\u4e3a\u7279\u5b9a\u8bf7\u6c42\u8986\u76d6\u9ed8\u8ba4\u6a21\u578b\u540d\u79f0\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-java",children:'// Using mistral-embed for general text\nEmbeddingResponse textEmbeddingResponse = embeddingModel.call(\n new EmbeddingRequest(List.of("Hello World", "World is big and salvation is near"),\n MistralAiEmbeddingOptions.builder()\n .withModel("mistral-embed")\n .build()));\n\n// Using codestral-embed for code\nEmbeddingResponse codeEmbeddingResponse = embeddingModel.call(\n new EmbeddingRequest(List.of("public class HelloWorld {}", "def hello_world():"),\n MistralAiEmbeddingOptions.builder()\n .withModel("codestral-embed")\n .build()));\n'})}),"\n",(0,r.jsx)(i.h2,{id:"\u793a\u4f8b-controller",children:"\u793a\u4f8b Controller"}),"\n",(0,r.jsxs)(i.p,{children:["\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a ",(0,r.jsx)(i.code,{children:"EmbeddingModel"})," \u5b9e\u73b0\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u6ce8\u5165\u5230\u60a8\u7684\u7c7b\u4e2d\u3002\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"EmbeddingModel"})," \u5b9e\u73b0\u7684\u7b80\u5355 ",(0,r.jsx)(i.code,{children:"@Controller"})," \u7c7b\u793a\u4f8b\u3002"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-properties",children:"spring.ai.mistralai.api-key=YOUR_API_KEY\nspring.ai.mistralai.embedding.options.model=mistral-embed\n"})}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-java",children:'@RestController\npublic class EmbeddingController {\n\n private final EmbeddingModel embeddingModel;\n\n @Autowired\n public EmbeddingController(EmbeddingModel embeddingModel) {\n this.embeddingModel = embeddingModel;\n }\n\n @GetMapping("/ai/embedding")\n public Map embed(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {\n var embeddingResponse = this.embeddingModel.embedForResponse(List.of(message));\n return Map.of("embedding", embeddingResponse);\n }\n}\n'})}),"\n",(0,r.jsx)(i.h2,{id:"\u624b\u52a8\u914d\u7f6e",children:"\u624b\u52a8\u914d\u7f6e"}),"\n",(0,r.jsxs)(i.p,{children:["\u5982\u679c\u60a8\u4e0d\u4f7f\u7528 Spring Boot\uff0c\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e OpenAI Embedding Model\u3002\n\u4e3a\u6b
164\uff0c\u8bf7\u5c06 ",(0,r.jsx)(i.code,{children:"spring-ai-mistral-ai"})," \u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u9879\u76ee\u7684 Maven ",(0,r.jsx)(i.code,{children:"pom.xml"})," \u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-xml",children:"<dependency>\n <groupId>org.springframework.ai</groupId>\n <artifactId>spring-ai-mistral-ai</artifactId>\n</dependency>\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u6216\u6dfb\u52a0\u5230\u60a8\u7684 Gradle ",(0,r.jsx)(i.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-groovy",children:"dependencies {\n implementation 'org.springframework.ai:spring-ai-mistral-ai'\n}\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u63d0\u793a\uff1a\u8bf7\u53c2\u9605 ",(0,r.jsx)(i.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u6ce8\u610f\uff1a",(0,r.jsx)(i.code,{children:"spring-ai-mistral-ai"})," \u4f9d\u8d56\u9879\u8fd8\u63d0\u4f9b\u5bf9 ",(0,r.jsx)(i.code,{children:"MistralAiChatModel"})," \u7684\u8bbf\u95ee\u3002\n\u6709\u5173 ",(0,r.jsx)(i.code,{children:"MistralAiChatModel"})," \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 ",(0,r.jsx)(i.a,{href:"../../../chatmodels/more/mistralai-chat",children:"MistralAI Chat Client"})," \u90e8\u5206\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:["\u63a5\u4e0b\u6765\uff0c\u521b\u5efa\u4e00\u4e2a ",(0,r.jsx)(i.code,{children:"MistralAiEmbeddingModel"})," \u5b9e\u4f8b\u5e76\u4f7f\u7528\u5b83\u6765\u8ba1\u7b97\u4e24\u4e2a\u8f93\u5165\u6587\u672c\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\uff1a"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-java",children:'var mistralAiApi = new MistralAiApi(System.getenv("MISTRAL_AI_API_KEY"));\n\nvar embeddingModel = new MistralAiEmbeddingModel(this.mistralAiApi,\n MistralAiEmbeddingOptions.builder()\n .withModel("mistral-embed")\n .withEncodingFormat("float")\n .build());\n\nEmbeddingResponse embeddingResponse = this.embeddingModel\n .embedForResponse(List.of("Hello World", "World is big and salvation is near"));\n'})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"MistralAiEmbeddingOptions"})," \u63d0\u4f9b embedding \u8bf7\u6c42\u7684\u914d\u7f6e\u4fe1\u606f\u3002\noptions \u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e2a ",(0,r.jsx)(i.code,{children:"builder()"})," \u4ee5\u4fbf\u8f7b\u677e\u521b\u5efa\u9009\u9879\u3002"]})]})}function h(e={}){const{wrapper:i}={...(0,s.R)(),...e.components};return i?(0,r.jsx)(i,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.