43 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 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
avi tal 238d1c713d Fixes #974 - returning score driven by cosine similarity by (1 - distance) instead of distance (#1048)
Fixing the returned value of cosine similarity by (1 - distance)

Co-authored-by: avi.tal <avi.tal@appsflyer.com>
2024-10-23 23:09:51 -07:00
Travis Cline 5e330db179 pgvector restore WithConnectionURL option (#832)
pgvector: restore WithConnectionURL option
2024-05-11 21:56:58 +00:00
Joey Chilson e1e409249d vectorstores/pgvector: support both pgx and pgxpool. (#802) 2024-05-07 00:26:01 -04:00
Travis Cline b6ba6693d3 tooling: Update minimum go version to 1.22, update golangci-lint (#722)
* go: Update to go 1.22, update golangci-lint config

* lint: Address various lint issues

* chains: fix lint complaint in TestApplyWithCanceledContext

* lint: Address addtional lint issues

* lint: Address addtional lint issues

* tools: update golangci-lint to 1.57
2024-03-26 20:31:20 +00:00
Abirdcfly 9986fd3519 vectorstores: fix pgvector issues and add more test (#617)
1. add pgvector into test
2. add OPENAI_API_KEY and GENAI_API_KEY into test
3. deprecate pgvector table name Sanitize function
4. reset pgvector Search sql and make TestDeduplicater rerun
5. add test TestWithAllOptions for test all option
6. because of StuffDocuments.joinDocuments ignore document's metadata, update some tests

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2024-03-07 17:57:03 -08:00
Manuel de la Peña 3320490573 feat: run integration tests for vector databases using testcontainers-go modules 2024-03-06 17:54:36 +01:00
Travis Cline edc9740951 Merge pull request #548 from Abirdcfly/pgvector-dims
vectorstores: fix pgvector return nothing when embedding table has ve…
2024-02-03 16:22:52 -08:00
Travis Cline f89be09664 Merge pull request #589 from pieterclaerhout/pgvector-hnsw-index
vectorstores: Added the option to specify a HNSW index for improving performance
2024-02-03 15:36:02 -08:00
Pieter Claerhout a3e99c4d0e Removed the custom ID option for embeddings when using PGVector 2024-01-30 09:30:15 +01:00
Pieter Claerhout 51fa84f2b1 Merge branch 'pgvector-hnsw-index' of https://github.com/pieterclaerhout/langchaingo into pgvector-hnsw-index 2024-01-30 09:26:22 +01:00
Pieter Claerhout a3fc30a69e Fixed a linting error 2024-01-30 09:26:13 +01:00
Pieter Claerhout ded588c037 Merge branch 'main' into pgvector-hnsw-index 2024-01-30 09:03:12 +01:00
Abirdcfly 4b13c46ae6 vectorstores: fix pgvector return nothing when embedding table has vector with different dimensions
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2024-01-30 12:04:55 +08:00
Travis Cline b54eb1f897 Merge pull request #579 from pieterclaerhout/pgvector-dimensions-option
vectorstores: Added an option to specify the vector dimensions for the embeddings
2024-01-29 11:13:59 -08:00
Pieter Claerhout 26ab80073d Made the vector dimensions optional 2024-01-29 10:18:55 +01:00
Pieter Claerhout e984f4538e Added the option to specify a HNSW index for improving performance
You can read more about this type of index on:

https://github.com/pgvector/pgvector#hnsw
2024-01-29 10:13:52 +01:00
Pieter Claerhout 66ce332570 Added the missing comment on the exported WithCollectionMetadata function 2024-01-29 09:56:53 +01:00
Pieter Claerhout 3809be9815 Added an option to specify the vector dimensions for the embeddings 2024-01-29 09:56:22 +01:00
Pieter Claerhout e661df27a7 Merge branch 'main' into pgvector-deduplicator-support 2024-01-27 08:47:46 +01:00
Pieter Claerhout 43037084f8 Added the missing closing of the database rows 2024-01-27 08:35:13 +01:00
Travis Cline 0dd2484fd4 Merge pull request #557 from pieterclaerhout/pgvector-collection-metadata-option
vectorstores: Added an option to PGVector to set the collection metadata
2024-01-26 20:53:32 -08:00
Travis Cline 84f67fbd85 Merge pull request #559 from pieterclaerhout/pgvector-unique-collection-name
vectorstores: Added a unique constraint for the collection name when using PGVector
2024-01-26 20:51:01 -08:00
Travis Cline d8de65f432 Merge branch 'main' into pgvector-collection-metadata-option 2024-01-26 20:50:06 -08:00
Pieter Claerhout 82b39db1d5 Code cleanup 2024-01-26 13:25:37 +01:00
Pieter Claerhout b30e84e891 Removed an unused function parameter 2024-01-26 13:25:34 +01:00
Pieter Claerhout d39656fb28 Removed a dangling fmt.Println statement 2024-01-26 13:22:27 +01:00
Pieter Claerhout 2d31af9f04 Implemented support for deduplicating documents when adding for PGVector 2024-01-26 12:35:01 +01:00
Pieter Claerhout 034304384e Fixed the failing tests 2024-01-26 11:13:23 +01:00
Pieter Claerhout c2733d6aa3 Wrapped the PGVector store init function in a single transaction
Fixes #562
2024-01-26 11:04:02 +01:00
Pieter Claerhout dc0e5f7419 Code formatting 2024-01-26 09:24:31 +01:00
Pieter Claerhout c3e92ebc28 Added a unique constraint for the collection name 2024-01-26 09:24:24 +01:00
Pieter Claerhout 9df73afafd Cleaned up code formatting 2024-01-26 08:38:51 +01:00
Pieter Claerhout e364d1df35 Added an option to PGVector to set the collection metadata
There was no way to set the collection metadata even though the struct had a field for it.

Therefor, I added an option so you can specify the metadata. If the collection already exists, the metadata gets updated.
2024-01-26 08:38:38 +01:00
Abirdcfly 070ff5dffe vectorstores: pgvector add option WithConn
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2024-01-10 00:43:30 +08:00
Travis Cline 693bd1eb59 pgvector: return error directly 2023-12-28 17:28:00 -08:00
Jay Lalakiya 5c345a14a7 vectorstores: Add ids to the return when adding documents in any vectorstore (#448)
* Add ids to the return when adding documents in any vectorstore

* fixes lint checks

* examples: Point vectorstore examples to branch

---------

Co-authored-by: Travis Cline <travis.cline@gmail.com>
2023-12-28 17:11:54 -08:00
Mehul Shah dcae4f66a6 pgvector: Fix DropTable Function (#441)
drop embedding table before collection table

Co-authored-by: Mehul <mehul@gndctl.com>
2023-12-20 11:50:24 -08:00
Rey David Dominguez Soto 6ad961ac14 pgvector: support postgres schema (#439) 2023-12-20 11:34:16 -08:00
Abirdcfly ed0536f392 vectorstores: add pgvector (#377)
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2023-12-12 16:31:09 -08:00