90 Commits

Author SHA1 Message Date
HJJ 33e7f8f55d tools/scraper: add max pages limit for scraper functionality
Add MaxPages option to limit the number of pages scraped to prevent infinite loops and resource exhaustion. Includes tests.
2025-09-08 19:28:30 +02:00
Travis Cline 6d42f059f1 tools/scraper: fix context cancellation hanging (#1383)
tools/scraper: fix context cancellation to prevent hanging

Fixes issue where web scraper would hang indefinitely even when
context was cancelled. The problem was that c.Wait() was called
unconditionally after checking context cancellation.

Changes:
- Wrap c.Wait() in goroutine with completion channel
- Use select statement to race context cancellation vs completion
- Ensures scraper properly respects context timeouts/cancellation
2025-08-29 15:49:39 +02:00
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
Laurence Morgan c10cbc455c duckduckgo: descriptive error message 2025-05-21 16:17:55 +01:00
Simon Klinkert a9d2531e2e Comment should end in a period 2025-01-06 15:18:41 +01:00
Simon Klinkert bbd85f1fbf handle callbacks 2025-01-06 15:14:46 +01:00
Simon Klinkert cc536e60c5 comment public symbols 2025-01-06 15:11:28 +01:00
Simon Klinkert 957b5a027a gofmt 2025-01-05 23:07:20 +01:00
Simon Klinkert 4b3988740b review changes 2025-01-05 22:46:37 +01:00
Simon Klinkert dca2a9c973 add doc.go 2025-01-05 22:34:07 +01:00
Simon Klinkert ff93722af1 api key as option 2025-01-05 22:32:31 +01:00
Simon Klinkert 2589eec221 Implement perplexity agent tool
This PR enables AI Agents to use perplexity AI in order to retrieve data
from the web.
2024-11-07 21:39:01 +01:00
vdpoora ab19eb6161 scraper: fix concurrent scraped links map access (#813) 2024-05-04 19:01:14 -04:00
Augustinas Malinauskas ab8bf7a728 tools: serpapi api key option (#773)
feat: serpapi api key options
2024-04-18 14:00:48 -07:00
Alexandre E. Souza 1f45c812f9 chains: Update mysql testcontainer image (#739)
feat: update mysql image
2024-04-01 17:28:28 -07:00
Alexandre E. Souza 7bbb2d8285 tools/sqldataase: update postgres image (#740)
feat: update postgres image
2024-04-01 17:28:08 -07:00
Raj Jaiswal 7fb9a139e3 llms/cloudflare: Implement Cloudflare Workers AI LLM (#679)
* Add Cloudflare Workers AI LLM

* lint fixes

* text generation: support streaming response

* add tests

* review fixes

* minor http client fix
2024-03-24 13:40:11 -07:00
Travis Cline e1453556f7 tests: Add skipping if docker is not present 2024-02-20 15:33:18 -08:00
Manuel de la Peña 8e3b9c3fa1 chore: keep original env var for already running databases 2024-01-22 08:36:40 +01:00
Travis Cline 0485ecee1e Merge branch 'main' into testcontainers-go 2024-01-21 15:20:22 -08:00
Manuel de la Peña a77e095cd5 feat: add Postgres tests using testcontainers-go 2024-01-16 17:22:54 -05:00
Manuel de la Peña 766a89d055 feat: add MySQL tests using testcontainers-go 2024-01-16 17:17:22 -05:00
lujingxuan d7ed9806ca Merge remote-tracking branch 'origin/main' into feat_add_openai_function_agent 2023-12-30 23:39:12 +08:00
chyroc 534f75725e Feat: callbacks.Handler support handle error (#457)
Feat: support HandleLLMError for llms.LLM
2023-12-28 15:22:05 -08:00
lujingxuan 9dd6da65e6 add openai functions agent 2023-12-26 17:29:14 +08:00
Ismail ec6cbd9644 serpapi: remove unnecessary replacement from url (#344) 2023-12-04 22:38:29 -08:00
Ismail 80f9027554 fix: golangci-lint v1.55 errors 2023-12-04 22:38:28 -08:00
Travis Cline c5b84faa54 callbacks: Include context 2023-08-25 19:14:02 -07:00
FluffyKebab 03ad4b7799 add callbacks to tools, vectorsores and agents 2023-08-25 19:00:21 -07:00
Travis Cline aa97aec400 Merge pull request #256 from Struki84/tools/metaphor
Tools/metaphor
2023-08-25 18:51:54 -07:00
Simun Strukan 7dce8070b1 Added comments for methods and symbols 2023-08-24 15:27:28 +02:00
Simun Strukan 25e4f05bbd fixing lint issues... 2023-08-19 14:52:59 +02:00
Simun Strukan c03a53757b Small formating and fixes 2023-08-19 00:42:35 +02:00
Simun Strukan e5ac42c5cd Added a general Metaphor api tool that can create a more complex api calls to Metaphor Search API 2023-08-15 23:05:43 +02:00
Simun Strukan 1ee4bf6ece Removed the custom client added metahpor-go official client 2023-08-15 17:15:49 +02:00
Simun Strukan a26806e841 Fixing lint issues... 2023-08-12 23:04:11 +02:00
Simun Strukan 03fe6a1ea3 Fixing link issues... 2023-08-12 22:53:16 +02:00
Simun Strukan ac728bb866 Added metaphor client 2023-08-12 22:23:02 +02:00
Simun Strukan ad1b8d4826 Added links and documents tools interface impl 2023-08-12 21:56:27 +02:00
Simun Strukan 9257244f11 Added tool interface impl, for search tool 2023-08-12 21:52:36 +02:00
Simun Strukan cab0cd220b Added metaphor tool structure 2023-08-12 21:44:15 +02:00
Simun Strukan f32f5b0b61 Added doc.go 2023-08-12 19:17:15 +02:00
Simun Strukan 4061999e0e Added missing GoDocs 2023-08-12 19:15:21 +02:00
Simun Strukan 9afeef2d3b Loaded optaions and defualt values... 2023-08-12 19:14:34 +02:00
Simun Strukan a7e6f2db28 Added GoDocs for options methods 2023-08-12 19:07:13 +02:00
Simun Strukan 12bae87bab Added scraper options 2023-08-12 18:54:44 +02:00