fix: allow reset rag service chromadb (#1491)
This commit is contained in:
13
README.md
13
README.md
@@ -34,7 +34,7 @@
|
||||
|
||||
<https://github.com/user-attachments/assets/86140bfd-08b4-483d-a887-1b701d9e37dd>
|
||||
|
||||
## Sponsorship
|
||||
## Sponsorship ❤️
|
||||
|
||||
If you like this project, please consider supporting me on Patreon, as it helps me to continue maintaining and improving it:
|
||||
|
||||
@@ -657,7 +657,7 @@ Avante provides a RAG service, which is a tool for obtaining the required contex
|
||||
|
||||
```lua
|
||||
rag_service = {
|
||||
enabled = false, -- Enables the RAG service, requires OPENAI_API_KEY to be set
|
||||
enabled = false, -- Enables the RAG service
|
||||
host_mount = os.getenv("HOME"), -- Host mount path for the rag service
|
||||
provider = "openai", -- The provider to use for RAG service (e.g. openai or ollama)
|
||||
llm_model = "", -- The LLM model to use for RAG service
|
||||
@@ -666,9 +666,14 @@ rag_service = {
|
||||
},
|
||||
```
|
||||
|
||||
Please note that since the RAG service uses OpenAI for embeddings, you must set `OPENAI_API_KEY` environment variable!
|
||||
If your rag_service provider is `openai`, then you need to set the `OPENAI_API_KEY` environment variable!
|
||||
|
||||
If your rag_service provider is `ollama`, you need to set the endpoint to `http://localhost:11434` (note there is no `/v1` at the end) or any address of your own ollama server.
|
||||
|
||||
If your rag_service provider is `ollama`, when `llm_model` is empty, it defaults to `llama3`, and when `embed_model` is empty, it defaults to `nomic-embed-text`. Please make sure these models are available in your ollama server.
|
||||
|
||||
Additionally, RAG Service also depends on Docker! (For macOS users, OrbStack is recommended as a Docker alternative).
|
||||
|
||||
`host_mount` is the path that will be mounted to the container, and the default is the home directory. The mount is required
|
||||
for the RAG service to access the files in the host machine. It is up to the user to decide if you want to mount the whole
|
||||
`/` directory, just the project directory, or the home directory. If you plan using avante and RAG event for projects
|
||||
@@ -676,6 +681,8 @@ stored outside your home directory, you will need to set the `host_mount` to the
|
||||
|
||||
The mount will be read only.
|
||||
|
||||
After changing the rag_service configuration, you need to manually delete the rag_service container to ensure the new configuration is used: `docker rm -fv avante-rag-service`
|
||||
|
||||
## Web Search Engines
|
||||
|
||||
Avante's tools include some web search engines, currently support:
|
||||
|
||||
@@ -47,7 +47,7 @@ function M.launch_rag_service(cb)
|
||||
if M.get_rag_service_runner() == "docker" then
|
||||
local image = M.get_rag_service_image()
|
||||
local data_path = M.get_data_path()
|
||||
local cmd = string.format("docker ps -a | grep '%s'", container_name)
|
||||
local cmd = string.format("docker ps | grep '%s'", container_name)
|
||||
local result = vim.fn.system(cmd)
|
||||
if result ~= "" then
|
||||
Utils.debug(string.format("container %s already running", container_name))
|
||||
@@ -68,8 +68,13 @@ function M.launch_rag_service(cb)
|
||||
else
|
||||
Utils.debug(string.format("container %s not found, starting...", container_name))
|
||||
end
|
||||
result = vim.fn.system(string.format("docker ps -a | grep '%s'", container_name))
|
||||
if result ~= "" then
|
||||
Utils.info(string.format("container %s already started but not running, stopping...", container_name))
|
||||
M.stop_rag_service()
|
||||
end
|
||||
local cmd_ = string.format(
|
||||
"docker run --rm -d -p %d:8000 --name %s -v %s:/data -v %s:/host:ro -e DATA_DIR=/data -e RAG_PROVIDER=%s -e %s_API_KEY=%s -e %s_API_BASE=%s -e RAG_LLM_MODEL=%s -e RAG_EMBED_MODEL=%s %s",
|
||||
"docker run -d -p %d:8000 --name %s -v %s:/data -v %s:/host:ro -e ALLOW_RESET=TRUE -e DATA_DIR=/data -e RAG_PROVIDER=%s -e %s_API_KEY=%s -e %s_API_BASE=%s -e RAG_LLM_MODEL=%s -e RAG_EMBED_MODEL=%s %s",
|
||||
port,
|
||||
container_name,
|
||||
data_path,
|
||||
@@ -111,7 +116,7 @@ function M.launch_rag_service(cb)
|
||||
Utils.debug(string.format("launching %s with nix...", container_name))
|
||||
|
||||
local cmd = string.format(
|
||||
"cd %s && PORT=%d DATA_DIR=%s RAG_PROVIDER=%s %s_API_KEY=%s %s_API_BASE=%s RAG_LLM_MODEL=%s RAG_EMBED_MODEL=%s sh run.sh %s",
|
||||
"cd %s && ALLOW_RESET=TRUE PORT=%d DATA_DIR=%s RAG_PROVIDER=%s %s_API_KEY=%s %s_API_BASE=%s RAG_LLM_MODEL=%s RAG_EMBED_MODEL=%s sh run.sh %s",
|
||||
rag_service_dir,
|
||||
port,
|
||||
service_path,
|
||||
|
||||
Reference in New Issue
Block a user