mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 15:43:54 +00:00
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:
parent
ab6b41937a
commit
64d5108f99
@ -77,6 +77,7 @@
|
||||
"\n",
|
||||
"Before initializing your agent, the following environmental variables need to be set:\n",
|
||||
"\n",
|
||||
"* **GITLAB_URL** - The URL hosted Gitlab. Defaults to \"https://gitlab.com\". \n",
|
||||
"* **GITLAB_PERSONAL_ACCESS_TOKEN**- The personal access token you created in the last step\n",
|
||||
"* **GITLAB_REPOSITORY**- The name of the Gitlab repository you want your bot to act upon. Must follow the format {username}/{repo-name}.\n",
|
||||
"* **GITLAB_BRANCH**- The branch where the bot will make its commits. Defaults to 'main.'\n",
|
||||
@ -111,6 +112,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Set your environment variables using os.environ\n",
|
||||
"os.environ[\"GITLAB_URL\"] = \"https://gitlab.example.org\"\n",
|
||||
"os.environ[\"GITLAB_PERSONAL_ACCESS_TOKEN\"] = \"\"\n",
|
||||
"os.environ[\"GITLAB_REPOSITORY\"] = \"username/repo-name\"\n",
|
||||
"os.environ[\"GITLAB_BRANCH\"] = \"bot-branch-name\"\n",
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user