llm-dialog-manager 0.3.1__py3-none-any.whl → 0.3.4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- llm_dialog_manager/__init__.py +1 -1
- llm_dialog_manager/agent.py +33 -0
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.4.dist-info}/METADATA +1 -1
- llm_dialog_manager-0.3.4.dist-info/RECORD +9 -0
- llm_dialog_manager-0.3.1.dist-info/RECORD +0 -9
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.4.dist-info}/LICENSE +0 -0
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.4.dist-info}/WHEEL +0 -0
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.4.dist-info}/top_level.txt +0 -0
llm_dialog_manager/__init__.py
CHANGED
llm_dialog_manager/agent.py
CHANGED
@@ -6,6 +6,9 @@ from typing import List, Dict, Optional
|
|
6
6
|
import logging
|
7
7
|
from pathlib import Path
|
8
8
|
import random
|
9
|
+
import requests
|
10
|
+
import zipfile
|
11
|
+
import io
|
9
12
|
|
10
13
|
# Third-party imports
|
11
14
|
import anthropic
|
@@ -234,8 +237,15 @@ class Agent:
|
|
234
237
|
self.history = ChatHistory(messages)
|
235
238
|
self.memory_enabled = memory_enabled
|
236
239
|
self.api_key = api_key
|
240
|
+
self.repo_content = []
|
237
241
|
|
238
242
|
def add_message(self, role, content):
|
243
|
+
repo_content = ""
|
244
|
+
while self.repo_content:
|
245
|
+
repo = self.repo_content.pop()
|
246
|
+
repo_content += f"<repo>\n{repo}\n</repo>\n"
|
247
|
+
|
248
|
+
content = repo_content + content
|
239
249
|
self.history.add_message(content, role)
|
240
250
|
|
241
251
|
def generate_response(self, max_tokens=3585, temperature=0.7):
|
@@ -271,6 +281,29 @@ class Agent:
|
|
271
281
|
messages = json.load(file)
|
272
282
|
self.history = ChatHistory(messages)
|
273
283
|
|
284
|
+
def add_repo(self, repo_url: Optional[str] = None, username: Optional[str] = None, repo_name: Optional[str] = None, commit_hash: Optional[str] = None):
|
285
|
+
if username and repo_name:
|
286
|
+
if commit_hash:
|
287
|
+
repo_url = f"https://github.com/{username}/{repo_name}/archive/{commit_hash}.zip"
|
288
|
+
else:
|
289
|
+
repo_url = f"https://github.com/{username}/{repo_name}/archive/refs/heads/main.zip"
|
290
|
+
|
291
|
+
if not repo_url:
|
292
|
+
raise ValueError("Either repo_url or both username and repo_name must be provided")
|
293
|
+
|
294
|
+
response = requests.get(repo_url)
|
295
|
+
if response.status_code == 200:
|
296
|
+
repo_content = ""
|
297
|
+
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
|
298
|
+
for file_info in z.infolist():
|
299
|
+
if not file_info.is_dir() and file_info.filename.endswith(('.py', '.txt')):
|
300
|
+
with z.open(file_info) as f:
|
301
|
+
content = f.read().decode('utf-8')
|
302
|
+
repo_content += f"{file_info.filename}\n```\n{content}\n```\n"
|
303
|
+
self.repo_content.append(repo_content)
|
304
|
+
else:
|
305
|
+
raise ValueError(f"Failed to download repository from {repo_url}")
|
306
|
+
|
274
307
|
if __name__ == "__main__":
|
275
308
|
|
276
309
|
# write a test for detect finding agent
|
@@ -0,0 +1,9 @@
|
|
1
|
+
llm_dialog_manager/__init__.py,sha256=L-vxURJQtPwajtaFFl8gFI-xAsggFXNNY3aOqlVIViU,86
|
2
|
+
llm_dialog_manager/agent.py,sha256=ruZWlSZZ6jBr8x8I-lWdsjiSP44BTYTR9fBS0FuE-Rc,13310
|
3
|
+
llm_dialog_manager/chat_history.py,sha256=xKA-oQCv8jv_g8EhXrG9h1S8Icbj2FfqPIhbty5vra4,6033
|
4
|
+
llm_dialog_manager/key_manager.py,sha256=shvxmn4zUtQx_p-x1EFyOmnk-WlhigbpKtxTKve-zXk,4421
|
5
|
+
llm_dialog_manager-0.3.4.dist-info/LICENSE,sha256=vWGbYgGuWpWrXL8-xi6pNcX5UzD6pWoIAZmcetyfbus,1064
|
6
|
+
llm_dialog_manager-0.3.4.dist-info/METADATA,sha256=6XPZd3oGCVC8YS-EVHII1EFFsnml1kS2VgRYoVsNaIQ,4152
|
7
|
+
llm_dialog_manager-0.3.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
8
|
+
llm_dialog_manager-0.3.4.dist-info/top_level.txt,sha256=u2EQEXW0NGAt0AAHT7jx1odXZ4rZfjcgbmJhvKFuMkI,19
|
9
|
+
llm_dialog_manager-0.3.4.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
llm_dialog_manager/__init__.py,sha256=NOEzUBSgPngSq5JIrDD7jEpusmMi4kes3PSc4pLJCnE,86
|
2
|
-
llm_dialog_manager/agent.py,sha256=m3LhktFjC8mDNx_TCm31QS09ZcUbKqcpW7QKrdfLsQc,11779
|
3
|
-
llm_dialog_manager/chat_history.py,sha256=xKA-oQCv8jv_g8EhXrG9h1S8Icbj2FfqPIhbty5vra4,6033
|
4
|
-
llm_dialog_manager/key_manager.py,sha256=shvxmn4zUtQx_p-x1EFyOmnk-WlhigbpKtxTKve-zXk,4421
|
5
|
-
llm_dialog_manager-0.3.1.dist-info/LICENSE,sha256=vWGbYgGuWpWrXL8-xi6pNcX5UzD6pWoIAZmcetyfbus,1064
|
6
|
-
llm_dialog_manager-0.3.1.dist-info/METADATA,sha256=hpaL6HcQTUvqlwLLnwtXuj_yzLEkyN-KXeWL3RRld7U,4152
|
7
|
-
llm_dialog_manager-0.3.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
8
|
-
llm_dialog_manager-0.3.1.dist-info/top_level.txt,sha256=u2EQEXW0NGAt0AAHT7jx1odXZ4rZfjcgbmJhvKFuMkI,19
|
9
|
-
llm_dialog_manager-0.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|