62 Commits

Author SHA1 Message Date
Travis Cline 6c217b3865 test: improve test coverage and optimize storage with gzip compression (#1378)
* embeddings/vertexai,memory: remove deprecated PaLM test and add recordings

Remove deprecated VertexAI PaLM embeddings test (PaLM API deprecated August 2024).
Add missing test recordings for memory/token buffer tests.

* vectorstores/redisvector: regenerate test recordings and compress

Regenerate test recordings for Docker container compatibility.
Compress large recordings (>50KB) with gzip for space efficiency.

* vectorstores/chroma: regenerate test recordings and compress

Regenerate test recordings for Docker container compatibility.
Compress large recordings (>50KB) with gzip for space efficiency.

* vectorstores/milvus: add deprecation notice and compress recordings

Add deprecation notice for Milvus vectorstore.
Compress test recordings with gzip for space efficiency.

* vectorstores/opensearch: regenerate test recordings and compress

Regenerate test recordings for Docker container compatibility.
Fix test to properly set up service_role for local tests.
Compress large recordings with gzip for space efficiency.

* vectorstores/weaviate: regenerate test recordings and compress

Regenerate test recordings for Docker container compatibility.
Compress large recordings (>50KB) with gzip for space efficiency.

* vectorstores/{pgvector,alloydb,cloudsql}: regenerate and compress recordings

Regenerate test recordings for Docker container compatibility.
Compress large recordings (>50KB) with gzip for space efficiency.
Covers pgvector, AlloyDB, and CloudSQL PostgreSQL vectorstores.

* tools/wikipedia: regenerate test recordings

Update test recordings with current Wikipedia API responses.
2025-08-23 19:06:20 +02:00
Travis Cline dd61fd90f4 test: improve test resilience and update provider APIs (#1377)
test: improve test resilience with better HTTP recording handling

Add hasExistingRecording helper to detect available recordings and skip tests
gracefully when recordings are unavailable. Replace generic credential checks
with specific recording validation and provide clear error messages.
2025-08-22 18:13:13 +02:00
Travis Cline 99951bca92 httprr: improve test recording stability and add utilities (#1368)
* build: add examples-updater tool and update examples to v0.1.14-pre.1

Add a new tool to automate updating langchaingo version references in example
projects and use it to update all examples to v0.1.14-pre.1. The tool also
removes temporary replace directives that are no longer needed.

- Add update-examples Makefile target that runs the new tool
- Create internal/devtools/examples-updater implementation
- Update all example go.mod files to reference v0.1.14-pre.1
- Remove replace directives in googleai and vertex examples
- Update dependencies in main go.mod/go.sum

* httprr: improve header normalization and test container setup

Add header normalization to make HTTP recordings more stable:
- Add normalizeGoogleAPIClientHeader and normalizeVersionHeader functions
- Normalize User-Agent, x-goog-api-client and other version headers
- Remove OpenAI-Project header for consistency
- Preserve body for both replay lookup and recording
- Add comprehensive tests for header normalization

Improve testcontainer environment detection:
- Better handling of non-standard Docker socket paths
- Disable Ryuk reaper by default for resource efficiency
- Add verbose logging option via environment variable

* httputil: add ApiKeyTransport for query parameter API keys

Add a reusable ApiKeyTransport that adds API keys to URL query parameters:
- Create ApiKeyTransport implementation in httputil package
- Add comprehensive tests for the new transport
- Refactor googleai_test.go to use the shared transport
- Update chains/llm_test.go to use ApiKeyTransport with proper key scrubbing

This improves how API keys are handled with client libraries that don't
properly set keys when using custom HTTP clients, particularly useful
with httprr for testing Google API integrations.

* openai: remove duplicate MaxTokens field assignment

Remove redundant assignment where both MaxTokens and MaxCompletionTokens
were being set to the same value. MaxCompletionTokens is the preferred
field name that reflects OpenAI's API changes, while MaxTokens was
previously kept for backward compatibility.

* vectorstores/maridadb: add test infrastructure for MariaDB vectorstore

Add TestMain function for MariaDB vectorstore tests that ensures the proper
test environment is set up using the testctr package. This enables consistent
test container setup and teardown for MariaDB integration tests.

* all: normalize all httprr recordings for consistency

Update test recordings across all packages to use normalized headers:
- Standardize User-Agent to 'langchaingo-httprr'
- Normalize version information in x-goog-api-client headers
- Remove OpenAI-Project headers for consistency
- Fix deprecated Anthropic completion API tests
- Update HuggingFace test recordings with valid responses

These changes make test recordings stable across dependency updates
and different environments, preventing test failures from version changes.

* devtools: add utility tool for normalizing httprr test recordings

Add a command-line tool that standardizes version information in httprr recordings:
- Normalizes x-goog-api-client headers to use placeholder versions
- Standardizes x-amz-user-agent headers for consistency
- Replaces Go version strings with generic placeholders
- Supports dry-run mode to preview changes without modifying files
- Includes verbose output option for detailed change reporting

This tool helps maintain consistent test recordings across different environments
and dependency versions, preventing test failures from version changes.

* llms/openai: update OpenAI embedding test to use text-embedding-3-small model

Update the embedding test to use the current text-embedding-3-small model:
- Change model from text-embedding-ada-002 to text-embedding-3-small
- Adjust dimensions parameter from 1234 to 256 to match model capabilities
- Update test recording with appropriate response data

This change ensures tests remain compatible with OpenAI's current embedding
models and prevents test failures from API version changes.
2025-08-18 19:41:52 +02:00
Travis Cline 77504b877f all: expand test coverage (#1312)
* scripts: cleanup test scripts
* lint: add test pattern and architectural linting
* internal/httprr: expand httprr testing
* test: add comprehensive unit test coverage
* docs: add comprehensive testing guide to CONTRIBUTING.md
* examples: standardize module versions and cleanup dependencies
* all: re-record several httprr recordings
2025-06-16 18:14:02 +02:00
Travis Cline c544fb77bd all: add broad httprr coverage, update dependencies, organize go.mod file, bump to 1.23 (#1299)
* all: add broad httprr coverage, update dependencies, organize go.mod file, bump to 1.23

update go version to 1.23
add lots of test coverage via httprr recordings
update dependencies and organize go.mod
add testutil/testctr which helps work around a testcontainers-go+colima bug
expand the huggingface implementation and tests
expand capabilities of the ollama package
2025-06-04 11:41:45 -07:00
Travis Cline bf1667feaf lint: fixup lint settings (#1018) 2024-09-13 04:39:28 +00:00
Travis Cline 4c89af684b Fix up weaviate tests (#885)
* weaviate: Fix weaviate tests, openai embedding model threading

* testcontainers: Update to 0.31
2024-06-15 03:52:42 +00:00
Joey Chilson 8d815c613d embeddings: add voyageai embedder (#792)
* embeddings: add voyageai embedder

* updated code docs
2024-05-07 00:26:40 -04:00
Alexandre E. Souza 03b5a69679 embeddings: Add Jina (#809)
* feat: add jina embeddings
2024-05-07 00:24:26 -04:00
Souyama a51062f84b embeddings: Add Amazon Bedrock embeddings (#643)
* Add bedrock embedding provider

* Add bedrock tests

---------

Co-authored-by: Travis Cline <travis.cline@gmail.com>
2024-03-06 23:03:19 +00:00
ion232 3fd341c5e9 embeddings: fix variable typo in huggingface_test 2024-01-26 23:38:26 +00:00
Daniel Bos 6982a619f2 embeddings: add cybertron local embeddings
Added a new package 'cybertron' under 'embeddings' to run embedding
models locally. This includes the main 'cybertron.go' file, a test
file 'cybertron_test.go', and an 'options.go' file for providing
various options for the client.

Resolves #494
2024-01-23 10:06:22 +08:00
Eli Bendersky 61b3cda5d2 googleai: move the PaLM provider into googleai (#541)
Now it's consistent with the other Google AI providers

Re #410
2024-01-22 10:30:58 -08:00
Daniel Bos da638df86f embeddings: add adapter for EmbedderClient interface
An adapter for the EmbedderClient interface has been added. This allows
the use of ordinary functions as Embedder Clients. This change provides
flexibility in implementing the EmbedderClient interface, as it allows
any function with the appropriate signature to be used as an
EmbedderClient.
2024-01-19 10:47:54 +08:00
Eli Bendersky 97397f1441 Move openai chat client functionality to its LLM, remove separate Chat
The chat llm client calls use the newer OpenAI API to implement the
same functionality
2024-01-17 04:51:53 -08:00
Jay Lalakiya cda1c2f278 embeddings: Fix issue caused by new implementation of BatchTexts function (#475)
* Fix issues due to BatchText

---------

Co-authored-by: Travis Cline <travis.cline@gmail.com>
2024-01-01 17:39:07 -08:00
Jay Lalakiya 351b8b52b1 embeddings: Fix BatchTexts function (#453)
* Fix BatchTexts function in embeddings

* Add test cases for util func added
2023-12-23 13:47:11 -08:00
Jeremy 00f364f27f embeddings: remove TEI embeddings client. (#396)
* remove tei embeddings
2023-12-09 13:48:32 -08:00
Eli Bendersky 357a3b5d3b embeddings: add example of proper usage, and tweak doc.go accordingly (#393)
* embeddings: add example of proper usage, and tweak doc.go accordingly

For #379

* Appease lint and add comment
2023-12-04 22:38:29 -08:00
Eli Bendersky 4bb28402cf embeddings: use NewEmbedder for Ernie embeddings (#392)
For #379

Updates examples go.mod because it's used in an example
2023-12-04 22:38:29 -08:00
Eli Bendersky f2439a3cf9 embeddings: use NewEmbedder for Vertex embeddings (#391)
For #379
2023-12-04 22:38:29 -08:00
Eli Bendersky 7dd3fd2a1c embeddings: new NewEmbedder for Ollama embeddings
The only use of Ollama embeddings is an example - update it too and
go.mod versions
2023-12-04 22:38:29 -08:00
Eli Bendersky fc033c3471 embeddings: use NewEmbedder for OpenAI embeddings (#385)
This is the first use of the refactoring made in #374 -- removing the
embeddings/openai directory entirely, since it can be now implemented
with NewEmbedder without duplicating code. The test was moved one
dir down and works with the new setup.

This is a model that can be used to similarly refactor the other
embeddings/* subdirs.

This is a large PR because it also updates example go.mods

For #379
2023-12-04 22:38:29 -08:00
Jeremy 669c93d31d embeddings: TEI input truncation (enhancement) (#384)
add option to truncate tei embedding input
2023-12-04 22:38:29 -08:00
Jeremy 721e152d74 vectorstores: add Milvus (#352)
* adding milvus vector store

* adding hugging face text embedings

* adding milvus vector store example
2023-12-04 22:38:29 -08:00
Eli Bendersky 3d030fcbb3 embeddings: refactor embedding interfaces to enable creation from Chat and LLM (#374)
* Refactor embedding interfaces to enable creation from Chat and LLM

* embedding: add test that verifies assignability
2023-12-04 22:38:29 -08:00
Eli Bendersky 1702d7317e embeddings: use EmbedderClient for ernie embeddings (#363)
also removes unused internal method

For #356
2023-12-04 22:38:29 -08:00
Eli Bendersky 7ad3f13436 embeddings: remove unnecessary mostly-duplicated implementations (#362) 2023-12-04 22:38:29 -08:00
Eli Bendersky f529ffe5f8 embeddings: use EmbedderClient for openai embeddings (#359)
Applies the refactored code in #357 to remove duplicated code here.

Updates #356
2023-12-04 22:38:29 -08:00
Eli Bendersky 0a47b26808 embeddings: use EmbedderClient for ollama embeddings (#360)
Applies the refactored code in #357 to remove duplicated code here.

Updates #356
2023-12-04 22:38:29 -08:00
Eli Bendersky 982626a08d embeddings: refactor EmbedderClient interface to reduce code duplication (#358)
Starting with the vertex embedder, but this is applicable to others too
2023-12-04 22:38:29 -08:00
Eli Bendersky 9ab665a05a embedding/openai: fix method-dependent embedding discrepancy (#357)
Fix method-dependent embedding discrepancy for OpenAI

For #356
2023-12-04 22:38:29 -08:00
Ismail 80f9027554 fix: golangci-lint v1.55 errors 2023-12-04 22:38:28 -08:00
Cyril Peponnet 3fd51d9358 Adding ollama support (#327)
* Adding ollama support

* Address linting issues

* Disable default templating of model if any to avoid messing up custom prompts

* Added Ollama chatModel

* Adding ollama embeddings

* Added examples and fix the chat template for llama2

* examples: Fixup module names in ollama examples

* ollama: Small lint fix

---------

Co-authored-by: Travis Cline <travis.cline@gmail.com>
2023-12-04 22:38:28 -08:00
Travis Cline c94abc8e1e embeddings/vertexai: fix small api issue 2023-09-24 15:40:18 -07:00
Travis Cline 1c87838fe7 embeddings: use float32 throughout (#297)
* embeddings: use float32 throughout

* floats: more conversions

* exapmles: Add vertexai embeddings example
2023-09-24 22:32:18 +00:00
David 4abef1ec25 ernie embedder throw ErrEmbedderWrongNumberVectors #268 (#269) 2023-08-28 19:00:29 -07:00
David fed81aba73 add option func 2023-08-24 00:05:31 +00:00
Travis Cline 5338f91f54 Merge branch 'main' into main 2023-08-23 14:30:13 -07:00
David 6d8f0e790e feat: add Baidu LLM ERNIE 2023-08-23 19:47:13 +00:00
zivkovicn db5b41877d vertexai-chat | lint 2023-08-22 21:02:54 +02:00
zivkovicn 27ee775f12 vertexai-chat | updating logic 2023-08-22 17:30:22 +02:00
zivkovicn fbf9de856c embeddings-azure-openai | lint 2023-08-17 19:50:43 +02:00
zivkovicn 508171f161 embeddings-azure-openai | fixing issues 2023-08-17 19:45:52 +02:00
zivkovicn 35391ceb00 feature-huggingface-embeddings | huggingface embeddings 2023-08-10 17:41:31 +02:00
zivkovicn d204242b93 refactor-and-fix-openaichat | lint 2023-07-28 22:58:55 +02:00
zivkovicn a54934f416 refactor-and-fix-openaichat | fix 2023-07-28 21:52:41 +02:00
zivkovicn 5f72c3c01f feat-embeddings-split-with-options | lint 2023-07-18 15:04:57 +02:00
zivkovicn 6899975676 feat-embeddings-split-with-options | lint 2023-07-18 15:02:35 +02:00
zivkovicn 238739e2d7 feat-embeddings-split-with-options | feat: updating embeddings 2023-07-18 14:57:45 +02:00