Spring AI(初步了解)
一、什么是Spring AI
二、Spring AI的主要特点
Spring AI提供的API支持跨人工智能提供商的聊天、文本到图像、嵌入模型等,同时支持同步喝流API选项;
1、Chat Models (聊天模型)
- OpenAI
- Azure Open AI
- Amazon Bedrock
- Cohere's Command
- AI21 Labs' Jurassic-2
- Meta's LLama 2
- Amazon's Titan
- Google Vertex AI Palm
- Google Gemini
- HuggingFace - access thousands of models, including those from Meta such as Llama2
- Ollama - run AI models on your local machine
- MistralAI
2、Text-to-image Models (文本到图像模型)
- OpenAI with DALL-E
- StabilityAI
3、Transcription (audio to text) Models 转录(音频到文本)模型
- OpenAI
4、Embedding Models (嵌入模型)
- OpenAI
- Azure OpenAI
- Ollama
- ONNX
- PostgresML
- Bedrock Cohere
- Bedrock Titan
- Google VertexAI
- Mistal AI
The Vector Store API provides portability across different providers, featuring a novel SQL-like metadata filtering API that maintains portability.(提供了跨不同供应商的可移植性,其特点是提供了一种新颖的类似SQL的元数据过滤API,已保持可移植性)
5、Vector Databases (矢量数据库)
- Azure Vector Search
- Chroma
- Milvus
- Neo4j
- PostgreSQL/PGVector
- PineCone
- Redis
- Weaviate
- Qdrant
6、Spring Boot Auto Configuration and Starters for AI Models and Vector Stores. (用于AI模型和矢量存储的Spring Boot自动配置和启动器。)
7、Function calling (函数调用)
You can declare java.util.Function
implementations to OpenAI models for use in their prompt responses. You can directly provide these functions as objects or refer to their names if registered as a @Bean within the application context. This feature minimizes unnecessary code and enables the AI model to ask for more information to fulfill its response.
(您可以声明java.util.Function的OpenAl模型的函数实现,用于其提示响应。如果在应用程序上下文中注册为@Bean,则可以直接将这些函数作为对象提供,或者引用它们的名称。这一功能最大限度地减少了不必要的代码,并使人工智能模型能够要求更多信息来完成其响应;)
Models supported are(支持的模型)
- OpenAI
- Azure OpenAI
- VertexAI
- Mistral AI
- Anthropic Claude
8、ETL framework for Data Engineering(用于数据工程的ETL框架)
- The core functionality of our ETL framework is to facilitate the transfer of documents to model providers using a Vector Store. The ETL framework is based on Java functional programming concepts, helping you chain together multiple steps.(ETL框架的核心功能是使用Vector Store促进文档向模型提供者的传输。ETL框架基于Java函数式编程概念,可帮助您将多个步骤链接在一起;)
- We support reading documents in various formats, including PDF, JSON, and more.(支持阅读各种格式的文档,包括PDF、JSON等;)
- The framework allows for data manipulation to suit your needs. This often involves splitting documents to adhere to context window limitations and enhancing them with keywords for improved document retrieval effectiveness.(该框架允许数据操作以满足您的需求。这通常包括拆分文档以遵守上下文窗口限制,并使用关键字增强它们以提高文档检索效率;)
- Finally, processed documents are stored in the Vector Database, making them accessible for future retrieval.(最后,处理后的文档存储在矢量数据库中,以便将来检索)
9、Extensive reference documentation, sample applications, and workshop/course material.(广泛的参考文档、示例应用程序和研讨会/课程材料;)
Future releases will build upon this foundation to provide access to additional AI Models, for example, the Gemini multi-modal modal just released by Google, a framework for evaluating the effectiveness of your AI application, more convenience APIs, and features to help solve the “query/summarize my documents” use cases. Check GitHub for details on upcoming releases.(未来的版本将在此基础上提供对其他人工智能模型的访问,例如,谷歌刚刚发布的Gemini多模式模态,一个评估人工智能应用程序有效性的框架,更方便的AP!,以及帮助解决“查询/汇总我的文档”用例的功能。有关即将发布的版本的详细信息,请查看GitHub;)
三、开发Spring AI程序的准备
程序中需要使用openai API Key,去访问外部AP相关接口,没有这个就无法调用。需要注册官方网站账户,充值购买,或者淘宝购买。
1、本机电脑要可以访问OpenAI网站 https://openai.com/;
2、要有OpenAI的 API Key;(注册账户或者购买)
3、API-Key(API Key长这样):sk-3sfER03LDLG3SDFsdlwe283JSdw023lkrmrHDND32fmREKFD
拓展:在不购买 open ai api key的情况下,本地使用 ollama 大模型工具去搭建一个 AI环境
以上是基于 open ai 进行的AI相关验证所需环境,也可以基于 ollama(本地大家一个AI大模型环境,不需要 open ai api key) 大模型工具去进行AI相关的验证;
文档请参考:Spring AI(大模型工具Ollama介绍)