Skip to content

ThomasLeconte/spring-ai-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring AI test

API to interact with the Mistral "LARGE" model of Spring, using their API via Spring and adding context if necessary via document search.

Installation

Mistral AI

To use the Mistral API, you must register on the Mistral website and obtain an API key. Then, you must enter it in the spring.ai.mistralai.api-key property in one of the configuration files.

ChromaDB

The project is based on ChromaDB, a vector database. To install the Chroma client, simply follow these instructions:

pip install chromadb

Then, you need to launch a new instance of ChromaDB:

chroma run --host localhost --port 8000 --path ./my_chroma_data

Tavily

To use the Tavily web search API, you need to register on the Tavily website and obtain an API key. Then, you need to enter it in the tavily.api-key property in one of the configuration files.

Main features

Chat

Depending of route used, LLM will get previous context from conversation with an "in-memory" database (If you restart API, memory is cleared).
It can use a RAG for search into ChromaDB to get more context, or search on the web with Tavily. If required, the API has a little "reasoning" feature for LLM which is composed of 2 steps : make a detailed plan, and explain it precisely.

Document import

The API allows you to import documents into the ChromaDB database. During import, document follow these steps:

  • Split into chunks
  • Enrich metadata with summary of previous, current and next chunk to make better retrieval in the future
  • Extract main keywords of document

Document search

When API is used to search document, it will search into ChromaDB database. It will return the most relevant documents according to the search query. Documents with a retrieval score of > 0.8 are fully returned to the final prompt, and the others are all joined to be summarized to not send irrelevant informations.

Smart agent workflow

Ask a question though the /api/v1/streaming-chat route, and a workflow will be created automatically to anwser your question, based on the agents declared with the SmartAgentFlowFactory bean.

Usage

The API has a GET route /api/v1/streaming-chat that allows you to communicate with the Mistral "LARGE" model. It is possible to search by document or a web search by entering the associated booleans in the body of the request.

Before you can use the document search, you need to add documents to the ChromaDB database. To do this, simply make a POST request to /api/v1/documents with the desired file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages