Skip to content

Commit 0766fe8

Browse files
martramdrxy
authored andcommitted
gitlab api wrapper[patch]: fix create_file eats the first letter (#153)
If a tool creates a file, the first letter of the content disappears. The same happens with create_pull_request. Co-authored-by: Mason Daugherty <[email protected]>
1 parent 52c6280 commit 0766fe8

File tree

1 file changed

+2
-4
lines changed
  • libs/community/langchain_community/utilities

1 file changed

+2
-4
lines changed

libs/community/langchain_community/utilities/gitlab.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ def create_pull_request(self, pr_query: str) -> str:
166166
commits are already in the master branch"""
167167
else:
168168
try:
169-
title = pr_query.split("\n")[0]
170-
body = pr_query[len(title) + 2 :]
169+
title, body = pr_query.split("\n", 1)
171170
pr = self.gitlab_repo_instance.mergerequests.create(
172171
{
173172
"source_branch": self.gitlab_branch,
@@ -218,8 +217,7 @@ def create_file(self, file_query: str) -> str:
218217
f"to the {self.gitlab_base_branch} branch, which is protected. "
219218
"Please create a new branch and try again."
220219
)
221-
file_path = file_query.split("\n")[0]
222-
file_contents = file_query[len(file_path) + 2 :]
220+
file_path, file_contents = file_query.split("\n", 1)
223221
try:
224222
self.gitlab_repo_instance.files.get(file_path, self.gitlab_branch)
225223
return f"File already exists at {file_path}. Use update_file instead"

0 commit comments

Comments
 (0)