Feature: GitLab url from ENV (#14221)

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** add gitlab url from env, 
  - **Issue:** no issue,
  - **Dependencies:** no,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
balaba-max
2023-12-06 06:41:36 +03:00
committed by GitHub
parent ab6b41937a
commit 64d5108f99
2 changed files with 11 additions and 1 deletions

View File

@@ -38,6 +38,10 @@ class GitLabAPIWrapper(BaseModel):
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api key and python package exists in environment."""
gitlab_url = get_from_dict_or_env(
values, "gitlab_url", "GITLAB_URL", default=None
)
gitlab_repository = get_from_dict_or_env(
values, "gitlab_repository", "GITLAB_REPOSITORY"
)
@@ -62,7 +66,11 @@ class GitLabAPIWrapper(BaseModel):
"Please install it with `pip install python-gitlab`"
)
g = gitlab.Gitlab(private_token=gitlab_personal_access_token)
g = gitlab.Gitlab(
url=gitlab_url,
private_token=gitlab_personal_access_token,
keep_base_url=True,
)
g.auth()