2023-12-26 21:01:42 +00:00
|
|
|
from langchain_core.pydantic_v1 import SecretStr
|
|
|
|
from pytest import CaptureFixture
|
|
|
|
|
|
|
|
from langchain_community.llms.predibase import Predibase
|
|
|
|
|
|
|
|
|
|
|
|
def test_api_key_is_string() -> None:
|
2024-03-30 00:38:13 +00:00
|
|
|
llm = Predibase(model="my_llm", predibase_api_key="secret-api-key")
|
2023-12-26 21:01:42 +00:00
|
|
|
assert isinstance(llm.predibase_api_key, SecretStr)
|
|
|
|
|
|
|
|
|
|
|
|
def test_api_key_masked_when_passed_via_constructor(
|
|
|
|
capsys: CaptureFixture,
|
|
|
|
) -> None:
|
2024-03-30 00:38:13 +00:00
|
|
|
llm = Predibase(model="my_llm", predibase_api_key="secret-api-key")
|
2024-02-10 00:13:30 +00:00
|
|
|
print(llm.predibase_api_key, end="") # noqa: T201
|
2023-12-26 21:01:42 +00:00
|
|
|
captured = capsys.readouterr()
|
|
|
|
|
|
|
|
assert captured.out == "**********"
|
community: extend Predibase integration to support fine-tuned LLM adapters (#19979)
- [x] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
- Example: "community: add foobar LLM"
- [x] **PR message**: ***Delete this entire checklist*** and replace
with
- **Description:** Langchain-Predibase integration was failing, because
it was not current with the Predibase SDK; in addition, Predibase
integration tests were instantiating the Langchain Community `Predibase`
class with one required argument (`model`) missing. This change updates
the Predibase SDK usage and fixes the integration tests.
- **Twitter handle:** `@alexsherstinsky`
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
---------
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-04-08 18:54:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_specifying_adapter_id_argument() -> None:
|
|
|
|
llm = Predibase(model="my_llm", predibase_api_key="secret-api-key")
|
|
|
|
assert not llm.adapter_id
|
|
|
|
|
|
|
|
llm = Predibase(
|
2024-04-12 15:32:00 +00:00
|
|
|
model="my_llm",
|
|
|
|
predibase_api_key="secret-api-key",
|
|
|
|
adapter_id="my-hf-adapter",
|
|
|
|
)
|
|
|
|
assert llm.adapter_id == "my-hf-adapter"
|
|
|
|
assert llm.adapter_version is None
|
|
|
|
|
|
|
|
llm = Predibase(
|
|
|
|
model="my_llm",
|
|
|
|
adapter_id="my-other-hf-adapter",
|
|
|
|
predibase_api_key="secret-api-key",
|
|
|
|
)
|
|
|
|
assert llm.adapter_id == "my-other-hf-adapter"
|
|
|
|
assert llm.adapter_version is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_specifying_adapter_id_and_adapter_version_arguments() -> None:
|
|
|
|
llm = Predibase(model="my_llm", predibase_api_key="secret-api-key")
|
|
|
|
assert not llm.adapter_id
|
|
|
|
|
|
|
|
llm = Predibase(
|
|
|
|
model="my_llm",
|
|
|
|
predibase_api_key="secret-api-key",
|
|
|
|
adapter_id="my-hf-adapter",
|
|
|
|
adapter_version=None,
|
community: extend Predibase integration to support fine-tuned LLM adapters (#19979)
- [x] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
- Example: "community: add foobar LLM"
- [x] **PR message**: ***Delete this entire checklist*** and replace
with
- **Description:** Langchain-Predibase integration was failing, because
it was not current with the Predibase SDK; in addition, Predibase
integration tests were instantiating the Langchain Community `Predibase`
class with one required argument (`model`) missing. This change updates
the Predibase SDK usage and fixes the integration tests.
- **Twitter handle:** `@alexsherstinsky`
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
---------
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-04-08 18:54:29 +00:00
|
|
|
)
|
|
|
|
assert llm.adapter_id == "my-hf-adapter"
|
2024-04-12 15:32:00 +00:00
|
|
|
assert llm.adapter_version is None
|
community: extend Predibase integration to support fine-tuned LLM adapters (#19979)
- [x] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
- Example: "community: add foobar LLM"
- [x] **PR message**: ***Delete this entire checklist*** and replace
with
- **Description:** Langchain-Predibase integration was failing, because
it was not current with the Predibase SDK; in addition, Predibase
integration tests were instantiating the Langchain Community `Predibase`
class with one required argument (`model`) missing. This change updates
the Predibase SDK usage and fixes the integration tests.
- **Twitter handle:** `@alexsherstinsky`
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
---------
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-04-08 18:54:29 +00:00
|
|
|
|
|
|
|
llm = Predibase(
|
|
|
|
model="my_llm",
|
|
|
|
adapter_id="my-other-hf-adapter",
|
2024-04-12 15:32:00 +00:00
|
|
|
adapter_version=3,
|
community: extend Predibase integration to support fine-tuned LLM adapters (#19979)
- [x] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
- Example: "community: add foobar LLM"
- [x] **PR message**: ***Delete this entire checklist*** and replace
with
- **Description:** Langchain-Predibase integration was failing, because
it was not current with the Predibase SDK; in addition, Predibase
integration tests were instantiating the Langchain Community `Predibase`
class with one required argument (`model`) missing. This change updates
the Predibase SDK usage and fixes the integration tests.
- **Twitter handle:** `@alexsherstinsky`
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
---------
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-04-08 18:54:29 +00:00
|
|
|
predibase_api_key="secret-api-key",
|
|
|
|
)
|
|
|
|
assert llm.adapter_id == "my-other-hf-adapter"
|
2024-04-12 15:32:00 +00:00
|
|
|
assert llm.adapter_version == 3
|