llm-dialog-manager 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llm_dialog_manager/__init__.py +1 -1
- llm_dialog_manager/agent.py +34 -0
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.2.dist-info}/METADATA +1 -1
- llm_dialog_manager-0.3.2.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.2.dist-info}/LICENSE +0 -0
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.2.dist-info}/WHEEL +0 -0
- {llm_dialog_manager-0.3.1.dist-info → llm_dialog_manager-0.3.2.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,30 @@ class Agent:
|
|
271
281
|
messages = json.load(file)
|
272
282
|
self.history = ChatHistory(messages)
|
273
283
|
|
284
|
+
def load_repo(self, repo_name: Optional[str] = None, commit_hash: Optional[str] = None):
|
285
|
+
"""eg: repo_name: xihajun/llm_dialog_manager"""
|
286
|
+
if repo_name:
|
287
|
+
if commit_hash:
|
288
|
+
repo_url = f"https://github.com/{repo_name}/archive/{commit_hash}.zip"
|
289
|
+
else:
|
290
|
+
repo_url = f"https://github.com/{repo_name}/archive/refs/heads/main.zip"
|
291
|
+
|
292
|
+
if not repo_url:
|
293
|
+
raise ValueError("Either repo_url or both username and repo_name must be provided")
|
294
|
+
|
295
|
+
response = requests.get(repo_url)
|
296
|
+
if response.status_code == 200:
|
297
|
+
repo_content = ""
|
298
|
+
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
|
299
|
+
for file_info in z.infolist():
|
300
|
+
if not file_info.is_dir() and file_info.filename.endswith(('.py', '.txt')):
|
301
|
+
with z.open(file_info) as f:
|
302
|
+
content = f.read().decode('utf-8')
|
303
|
+
repo_content += f"{file_info.filename}\n```\n{content}\n```\n"
|
304
|
+
self.repo_content.append(repo_content)
|
305
|
+
else:
|
306
|
+
raise ValueError(f"Failed to download repository from {repo_url}")
|
307
|
+
|
274
308
|
if __name__ == "__main__":
|
275
309
|
|
276
310
|
# write a test for detect finding agent
|
@@ -0,0 +1,9 @@
|
|
1
|
+
llm_dialog_manager/__init__.py,sha256=u9m9_3UUibXqNSRzkf63lAbkw_l5RmGcxlVOhmeShlg,86
|
2
|
+
llm_dialog_manager/agent.py,sha256=o0ayPp9eS_8Vx78GYMPlIxHrK1UHTbu_I3dEsk4Agdo,13268
|
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.2.dist-info/LICENSE,sha256=vWGbYgGuWpWrXL8-xi6pNcX5UzD6pWoIAZmcetyfbus,1064
|
6
|
+
llm_dialog_manager-0.3.2.dist-info/METADATA,sha256=-DNhRHechHF38K6DGrHCeHVTj2JX3sxw4ZYFQr6Sj5I,4152
|
7
|
+
llm_dialog_manager-0.3.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
8
|
+
llm_dialog_manager-0.3.2.dist-info/top_level.txt,sha256=u2EQEXW0NGAt0AAHT7jx1odXZ4rZfjcgbmJhvKFuMkI,19
|
9
|
+
llm_dialog_manager-0.3.2.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
|