Commit Graph

21 Commits

Author SHA1 Message Date
Sergey Kozyrenko 058e344d90 fix(vertex,bedrock): saturate max tokens instead of wrapping to a negative limit
WithMaxTokens above MaxInt32 wrapped: 3_000_000_000 became -1294967296 on the
Vertex generation config (max output tokens, candidate count and top-k) and on
the Converse inference config. The googleai adapter already saturated, so the
same call succeeded there and failed on the sibling doors.

The saturating conversion moves to internal/numutil so the three doors share one
implementation. The Vertex generation config is extracted into a function so the
conversion has a seam a test can reach.

Not changed: the thinking-budget conversion in googleai, where GetTokens is
already clamped to MaxReasoningTokens and cannot overflow.

PAGI-132
2026-08-23 00:32:07 +07:00
Sergey Kozyrenko c55e0ff989 test(googleai): record fixtures through a gateway
Re-recording googleai fixtures takes a direct vendor key, which not every
contributor has. Route the test transport through GOOGLE_BASE_URL so a
compatible proxy serves the same endpoints; the rewrite sits below the
recorder, so the trace still carries the vendor URL and replays offline.

A proxy adds its own X-Litellm-* response headers, one of which reports the
key's accumulated spend. Scrub them out of the trace, and fail
TestRecordingsCarryNoProxyHeaders if such a header ever reaches testdata.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 16:04:01 +07:00
Dmitry Ng 1b1c761d98 chore: remove unmaintained legacy LLM providers
Breaking Changes:
- Remove Cloudflare Workers AI provider
- Remove Cohere provider
- Remove Ernie (Baidu) provider
- Remove Llamafile provider
- Remove Local provider
- Remove Maritaca provider
- Remove Watsonx (IBM) provider
- Remove compliance testing suite

This removes dead code that was no longer maintained, tested, or actively used. Users should migrate to actively supported providers like OpenAI, Anthropic, Google AI, Bedrock, or Ollama for local deployments.

Documentation:
- Remove provider integration pages
- Update parity matrix
- Update search index
- Remove provider examples
2026-03-11 18:55:16 +03:00
Dmitry Ng fc989b35d1 httputil: Implement circular buffer for identical requests in httprr
- Added support for recording and replaying multiple identical requests, allowing each to return different responses in a defined order.
- Introduced `replayEntry` struct to manage response cycling for identical requests.
- Updated documentation to reflect new circular buffer behavior and usage examples for cache testing scenarios.
- Enhanced tests to validate the circular response behavior for both GET and POST requests.

This change improves the testing capabilities for scenarios where identical requests yield varying responses, such as caching mechanisms.
2026-01-26 13:42:49 +03:00
Dmitry Ng aa2dd71269 Merge branch 'main' into release/v0.1.14-update.1 2026-01-24 02:07:00 +03:00
Travis Cline 480112bee0 internal/httprr, vectorstores/azureaisearch: fix race conditions in tests (#1381)
test: fix race conditions in httprr and azureaisearch tests

Add thread-safe access to global record flag in httprr package and prevent
tests that modify global state from running in parallel. Fix race condition
in Azure AI Search tests by properly capturing request counter in a local
variable before use.
2025-08-29 15:48:17 +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
Dmitry Ng a87f33d1a8 fix: lint and test issues, freeze docker images versions 2025-07-12 15:05:38 +03:00
Dmitry Ng eee90d9059 fix: multiple linter issues and logic in tests 2025-06-23 13:43:06 +03:00
Dmitry Ng 019056baba feat: setup repository for fork 2025-06-22 02:27:21 +03:00
Dmitry Ng fbd4bc67ec fix: open issues in the tests 2025-06-22 01:55:59 +03: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 94f289e427 httprr: add httprr package (#1296)
* httprr: add HTTP record/replay framework with default API key scrubbing

- Add httprr package for deterministic HTTP testing
- Implement default scrubbing for common API key headers

* httputil: reorganize transport layer and add logging infrastructure

- Replace debug transports with structured logging via slog
- Add comprehensive user agent handling with version info
- Improve transport layer organization and documentation
- Maintain backward compatibility with deprecated types
- Add JSON debug transport with color output support
2025-06-04 08:35:32 -07:00
Travis Cline bf1667feaf lint: fixup lint settings (#1018) 2024-09-13 04:39:28 +00:00
wei fe22d8ecd3 memory: Add mongodb memory implementation (#810)
* feat(internal): add mongodb client

* feat(memory): add mongodb memory
2024-05-04 19:39:05 -04:00
Eli Bendersky 25b04d4ba1 Move utility function (#552) 2024-01-25 06:15:30 -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
chyroc 55f772c21a Docs: fix comment typo (#442)
* Docs: fix comment typo

* docs: a llm -> an LLM

---------

Co-authored-by: Travis Cline <travis.cline@gmail.com>
2023-12-20 19:57:37 +00:00
Tobi a1c677d8fa chains: improve sequential chain init error messages 2023-07-23 23:25:22 +01:00
Tobi c096f01be6 chains: minor refactoring 2023-07-21 13:24:13 +01:00