- **Description:** Our PR is an integration of a Steam API Tool that makes recommendations on steam games based on user's Steam profile and provides information on games based on user provided queries. - **Issue:** the issue # our PR implements: https://github.com/langchain-ai/langchain/issues/12120 - **Dependencies:** python-steam-api library, steamspypi library and decouple library - **Tag maintainer:** @baskaryan, @hwchase17 - **Twitter handle:** N/A Hello langchain Maintainers, We are a team of 4 University of Toronto students contributing to langchain as part of our course [CSCD01 (link to course page)](https://cscd01.com/work/open-source-project). We hope our changes help the community. We have run make format, make lint and make test locally before submitting the PR. To our knowledge, our changes do not introduce any new errors. Our PR integrates the python-steam-api, steamspypi and decouple packages. We have added integration tests to test our python API integration into langchain and an example notebook is also provided. Our amazing team that contributed to this PR: @JohnY2002, @shenceyang, @andrewqian2001 and @muntaqamahmood Thank you in advance to all the maintainers for reviewing our PR! --------- Co-authored-by: Shence <ysc1412799032@163.com> Co-authored-by: JohnY2002 <johnyuan0526@gmail.com> Co-authored-by: Andrew Qian <andrewqian2001@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: JohnY <94477598+JohnY2002@users.noreply.github.com>
Langchain Tests
Unit Tests
Unit tests cover modular logic that does not require calls to outside APIs. If you add new logic, please add a unit test.
To run unit tests:
make test
To run unit tests in Docker:
make docker_tests
Integration Tests
Integration tests cover logic that requires making calls to outside APIs (often integration with other services). If you add support for a new external API, please add a new integration test.
warning Almost no tests should be integration tests.
Tests that require making network connections make it difficult for other developers to test the code.
Instead favor relying on responses library and/or mock.patch to mock
requests using small fixtures.
To install dependencies for integration tests:
poetry install --with test_integration
To run integration tests:
make integration_tests
Prepare
The integration tests exercise several search engines and databases. The tests aim to verify the correct behavior of the engines and databases according to their specifications and requirements.
To run some integration tests, such as tests located in
tests/integration_tests/vectorstores/, you will need to install the following
software:
- Docker
- Python 3.8.1 or later
Any new dependencies should be added by running:
# add package and install it after adding:
poetry add tiktoken@latest --group "test_integration" && poetry install --with test_integration
Before running any tests, you should start a specific Docker container that has all the
necessary dependencies installed. For instance, we use the elasticsearch.yml container
for test_elasticsearch.py:
cd tests/integration_tests/vectorstores/docker-compose
docker-compose -f elasticsearch.yml up
For environments that requires more involving preparation, look for *.sh. For instance,
opensearch.sh builds a required docker image and then launch opensearch.
Prepare environment variables for local testing:
- copy
tests/integration_tests/.env.exampletotests/integration_tests/.env - set variables in
tests/integration_tests/.envfile, e.gOPENAI_API_KEY
Additionally, it's important to note that some integration tests may require certain
environment variables to be set, such as OPENAI_API_KEY. Be sure to set any required
environment variables before running the tests to ensure they run correctly.
Recording HTTP interactions with pytest-vcr
Some of the integration tests in this repository involve making HTTP requests to external services. To prevent these requests from being made every time the tests are run, we use pytest-vcr to record and replay HTTP interactions.
When running tests in a CI/CD pipeline, you may not want to modify the existing cassettes. You can use the --vcr-record=none command-line option to disable recording new cassettes. Here's an example:
pytest --log-cli-level=10 tests/integration_tests/vectorstores/test_pinecone.py --vcr-record=none
pytest tests/integration_tests/vectorstores/test_elasticsearch.py --vcr-record=none
Run some tests with coverage:
pytest tests/integration_tests/vectorstores/test_elasticsearch.py --cov=langchain --cov-report=html
start "" htmlcov/index.html || open htmlcov/index.html
Coverage
Code coverage (i.e. the amount of code that is covered by unit tests) helps identify areas of the code that are potentially more or less brittle.
Coverage requires the dependencies for integration tests:
poetry install --with test_integration
To get a report of current coverage, run the following:
make coverage