feat(tests): use testcontainers-go's Ollama module for running tests with Ollama#1079
feat(tests): use testcontainers-go's Ollama module for running tests with Ollama#1079mdelapenya wants to merge 12 commits intotmc:mainfrom
Conversation
…go's Ollama module It uses a small model (llama3.2:1b) so that it's performant in CPUs
…s-go's Ollama module It uses a small model (llama3.2:1b) so that it's performant in CPUs
Given the threshold is hight, is expected to receive less documents
…go's Ollama module It uses a small model (llama3.2:1b) so that it's performant in CPUs
…iners-go's Ollama module It uses a small model (llama3.2:1b) so that it's performant in CPUs
|
@codefromthecrypt @devalexandre I think this would close #994. Could you please take a look? |
|
on the benefits of this, not just do we skip less tests, but we also understand failure cases common for local model serving runtimes. This includes aspects about the service (e.g. ollama only recently supports streaming with tool calls) and also open models. I use all-minilm:33m and qwen2.5:0.5B in simple tests, or the normal size qwen2.5 if the test is a little hard to control. Also, there's an alternative to testcontainers-go which is running ollama directly. While that's not the aim of this PR it has some pros and cons to it, and possibly something to note as an alternative considered. |
|
@codefromthecrypt you are probably interested in testcontainers/testcontainers-go#2906 😉 |
|
@mdelapenya thanks I subscribed. Not sure if they will accept it or prior art around native process management. However, it does feel like it can workaround the lifecycle issue if accepted. |
* main: (62 commits) feat: implement StreamingReasoningFunc for reasoning models (tmc#1125) anthropic: Add support for multi content part and images content in human messages. (tmc#1141) Fix Discord link to not expire, added more .gitignore (tmc#1134) examples: Update to v0.1.13-pre.1 (tmc#1140) ci: enhance docs publishing workflow (tmc#1139) fix docs publishing, use v3 of upload artifact fix docs publishing fix test, comments fix example code extra field initial commit for deepseek reasoning GODRIVER-3336 Remove readme in favor to go docs docs: Update Discord invite link in README bugfix/vectorstores: weaviate: use correct client creator Update field path linting fixes linting fixes linting fixes minor fixes after feedback from @FluffyKebab deps: update mistral go version ...
PR Checklist
memory: add interfaces for X, Yorutil: add whizzbang helpers).Fixes #123).golangci-lintchecks.What does this PR do?
It uses Testcontainers for Go's Ollama module enabling the execution of the integration tests that interact with a local LLM. Before this PR, tests are skipped in the case 1) there is no OPENAI key in the env, 2) there is not OLLAMA_URL/OLLAMA_MODEL in the env.
This PR bypasses that limitation using the Ollama module in a container, using a small LLM like llama3.2:1b, which fits easily in CPUs instead of GPUs.
To run the docker images for Ollama, we are using
mdelapenya's Docker Hub, where I push already backed Ollama images with the models already loaded, so the build times gets reduced only to the pull time. Please check https://hub.docker.com/r/mdelapenya/llama3.2, and the repository that generates the Docker images: https://github.com/mdelapenya/dockerize-ollama-models/This PR tries to honour the current approach: if the env vars exist, they will be used, so users can test with their own local environment if needed.
Why is it important?
Adds the ability to test locally, avoiding the skipping of lots of tests at CI time.
Other concers
Weaviate tests are failing for me with the current model I chose, not sure if with OpenAI it will work as expected. Also they fail in the chains call, as the relevant documents seem to be not used in the chain call, therefore, the model always responds with
"I don't know", making the tests to fail. Can anybody check with OpenAI?