Merge branch 'release/0.3.0'
Browse files- .CodeLumiaignore +4 -1
- README.md +9 -3
- __CodeLumiai.md +0 -349
- app.py +6 -2
- docs/SourceSageDocs.md +1 -1
- docs/demo.gif +3 -0
- docs/page_front.md +3 -0
- modules/file_operations.py +10 -2
- modules/markdown_operations.py +2 -2
- tmp/OSWorld +1 -0
.CodeLumiaignore
CHANGED
@@ -169,4 +169,7 @@ LICENSE
|
|
169 |
.github
|
170 |
*.png
|
171 |
*.jpg
|
172 |
-
*.ipynb
|
|
|
|
|
|
|
|
169 |
.github
|
170 |
*.png
|
171 |
*.jpg
|
172 |
+
*.ipynb
|
173 |
+
*.sqlite
|
174 |
+
*.jpg
|
175 |
+
requirements.txt
|
README.md
CHANGED
@@ -54,12 +54,18 @@ CodeLumiaを使用して、プロジェクトのドキュメンテーション
|
|
54 |
|
55 |
## 更新履歴
|
56 |
|
57 |
-
### [[2024/04/13] CodeLumia v0.
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
- コードのリファクタリングによる可読性と保守性の向上
|
60 |
- リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
|
61 |
- ユーザーインターフェースの改善とドキュメンテーションの拡充
|
62 |
-
- CI/CDの設定とREADME
|
63 |
|
64 |
### [2024/04/12] CodeLumia v0.1.0
|
65 |
- 初回リリース
|
|
|
54 |
|
55 |
## 更新履歴
|
56 |
|
57 |
+
### [[2024/04/13] CodeLumia v0.3.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.3.0)
|
58 |
+
- アプリケーションの機能強化とドキュメントデザインの更新
|
59 |
+
- デモGIFの更新
|
60 |
+
- `.CodeLumiaignore`のフォーマット更新とリファクタリング
|
61 |
+
- READMEとSourceSageDocsの大幅な更新
|
62 |
+
- GIFファイルのGit LFSでの追跡と誤記修正
|
63 |
+
-
|
64 |
+
### [[2024/04/13] CodeLumia v0.2.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.2.0)
|
65 |
- コードのリファクタリングによる可読性と保守性の向上
|
66 |
- リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
|
67 |
- ユーザーインターフェースの改善とドキュメンテーションの拡充
|
68 |
+
- CI/CDの設定とREADMEファイルの更新---
|
69 |
|
70 |
### [2024/04/12] CodeLumia v0.1.0
|
71 |
- 初回リリース
|
__CodeLumiai.md
DELETED
@@ -1,349 +0,0 @@
|
|
1 |
-
# << NotebookForgeBeta>>
|
2 |
-
## NotebookForgeBeta File Tree
|
3 |
-
|
4 |
-
```
|
5 |
-
NotebookForgeBeta/
|
6 |
-
create_jupyter_notebook.py
|
7 |
-
README.md
|
8 |
-
app.py
|
9 |
-
example/
|
10 |
-
example01.md
|
11 |
-
script/
|
12 |
-
activate-notebook-forge.bat
|
13 |
-
activate-notebook-forge.sh
|
14 |
-
docs/
|
15 |
-
|
16 |
-
```
|
17 |
-
|
18 |
-
## create_jupyter_notebook.py
|
19 |
-
|
20 |
-
```python
|
21 |
-
import json
|
22 |
-
import re
|
23 |
-
|
24 |
-
def create_jupyter_notebook(markdown_file, output_file):
|
25 |
-
with open(markdown_file, 'r', encoding="utf-8") as file:
|
26 |
-
markdown_content = file.read()
|
27 |
-
|
28 |
-
cells = []
|
29 |
-
chunks = re.split(r'(#+\s.*)', markdown_content)
|
30 |
-
|
31 |
-
for i in range(len(chunks)):
|
32 |
-
chunk = chunks[i].strip()
|
33 |
-
if chunk:
|
34 |
-
if chunk.startswith('#'):
|
35 |
-
cells.append({
|
36 |
-
'cell_type': 'markdown',
|
37 |
-
'source': [chunk]
|
38 |
-
})
|
39 |
-
else:
|
40 |
-
code_chunks = re.split(r'```python\n(.*?)```', chunk, flags=re.DOTALL)
|
41 |
-
for j in range(len(code_chunks)):
|
42 |
-
if j % 2 == 0 and code_chunks[j].strip():
|
43 |
-
cells.append({
|
44 |
-
'cell_type': 'markdown',
|
45 |
-
'source': code_chunks[j].strip().split('\n')
|
46 |
-
})
|
47 |
-
elif j % 2 == 1:
|
48 |
-
code_lines = code_chunks[j].strip().split('\n')
|
49 |
-
cells.append({
|
50 |
-
'cell_type': 'code',
|
51 |
-
'execution_count': None,
|
52 |
-
'metadata': {},
|
53 |
-
'outputs': [],
|
54 |
-
'source': code_lines
|
55 |
-
})
|
56 |
-
|
57 |
-
notebook = {
|
58 |
-
'nbformat': 4,
|
59 |
-
'nbformat_minor': 0,
|
60 |
-
'metadata': {
|
61 |
-
'colab': {
|
62 |
-
'provenance': []
|
63 |
-
},
|
64 |
-
'kernelspec': {
|
65 |
-
'name': 'python3',
|
66 |
-
'display_name': 'Python 3'
|
67 |
-
},
|
68 |
-
'language_info': {
|
69 |
-
'name': 'python'
|
70 |
-
}
|
71 |
-
},
|
72 |
-
'cells': cells
|
73 |
-
}
|
74 |
-
|
75 |
-
with open(output_file, 'w') as file:
|
76 |
-
json.dump(notebook, file, indent=2)
|
77 |
-
|
78 |
-
if __name__ == '__main__':
|
79 |
-
|
80 |
-
# 使用例
|
81 |
-
markdown_file = 'example/example01.md'
|
82 |
-
output_file = 'example/example01.ipynb'
|
83 |
-
create_jupyter_notebook(markdown_file, output_file)
|
84 |
-
```
|
85 |
-
|
86 |
-
## README.md
|
87 |
-
|
88 |
-
```markdown
|
89 |
-
---
|
90 |
-
title: NotebookForgeDemo
|
91 |
-
emoji: 📉
|
92 |
-
colorFrom: blue
|
93 |
-
colorTo: pink
|
94 |
-
sdk: streamlit
|
95 |
-
sdk_version: 1.33.0
|
96 |
-
app_file: app.py
|
97 |
-
pinned: false
|
98 |
-
license: mit
|
99 |
-
---
|
100 |
-
|
101 |
-
<p align="center">
|
102 |
-
<img src="https://raw.githubusercontent.com/Sunwood-ai-labs/NotebookForgeBeta/main/docs/NotebookForge_icon.jpg" width="100%">
|
103 |
-
<br>
|
104 |
-
<h1 align="center">NotebookForge</h1>
|
105 |
-
|
106 |
-
</p>
|
107 |
-
|
108 |
-
|
109 |
-
## Introduction
|
110 |
-
NotebookForgeは、マークダウンファイルをJupyter Notebookに変換するPythonツールです。主な特徴と利点は以下の通りです。
|
111 |
-
|
112 |
-
- マークダウンファイル内のPythonコードブロックを適切なセルタイプ(コードセルまたはマークダウンセル)に自動変換
|
113 |
-
- 通常のテキストはマークダウンセルに変換
|
114 |
-
- 生成されたNotebookは指定された出力ファイルに保存
|
115 |
-
- シンプルで使いやすいインターフェース
|
116 |
-
|
117 |
-
NotebookForgeを使用することで、マークダウンファイルで書かれたドキュメントやチュートリアルを簡単にJupyter Notebook形式に変換できます。これにより、対話的な実行環境を提供しつつ、マークダウンの読みやすさと書きやすさを維持できます。
|
118 |
-
|
119 |
-
>このリポジトリは[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage)を活用しており、リリースノートやREADME、コミットメッセージの9割は[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage) + [claude.ai](https://claude.ai/)で生成しています。
|
120 |
-
|
121 |
-
## Demo
|
122 |
-
NotebookForgeの使用例として、Cohere APIのClassifyエンドポイントについての解説をマークダウンで書き、Jupyter Notebookに変換しました。
|
123 |
-
|
124 |
-
- [example/example01.md](example/example01.md): 変換元のマークダウンファイル
|
125 |
-
- [example/example01.ipynb](example/example01.ipynb): 変換後のJupyter Notebookファイル
|
126 |
-
|
127 |
-
このようにNotebookForgeを使うことで、APIドキュメントやチュートリアルを対話的なNotebook形式で提供できます。
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
## Updates
|
132 |
-
|
133 |
-
- [2024/04/11] [NotebookForge v1.0.0](https://github.com/Sunwood-ai-labs/NotebookForgeBeta/releases/tag/v1.0.0)
|
134 |
-
- Streamlitベースのウェブアプリを実装
|
135 |
-
- ユーザーフレンドリーなGUIでマークダウンからノートブックへの変換を実行可能に
|
136 |
-
- 生成されたノートブックをダウンロードする機能を追加
|
137 |
-
- Hugging Faceでのデモアプリをリリース
|
138 |
-
- [NotebookForgeDemo](https://huggingface.co/spaces/MakiAi/NotebookForgeDemo)にてアプリを公開
|
139 |
-
- ノートブック生成ロジックの最適化
|
140 |
-
- ドキュメントの拡充
|
141 |
-
- マークダウン解析時のバグを修正
|
142 |
-
|
143 |
-
- [2024/04/10] [NotebookForge v0.2.0](https://github.com/Sunwood-ai-labs/NotebookForgeBeta/releases/tag/v0.2.0)
|
144 |
-
- Cohere APIのClassifyエンドポイントについての解説をサンプルに追加
|
145 |
-
- READMEファイルを追加し、プロジェクトの概要とツールの使い方を記載
|
146 |
-
- `example`ディレクトリを新設し、サンプルファイルを整理
|
147 |
-
- サンプルコードのインデントを修正し可読性を向上
|
148 |
-
|
149 |
-
|
150 |
-
## Getting Started
|
151 |
-
### インストール
|
152 |
-
NotebookForgeを使用するには、Python 3.11以上が必要です。以下のコマンドでNotebookForge用のConda環境を作成し、アクティベートします。
|
153 |
-
|
154 |
-
```bash
|
155 |
-
conda create -n notebook-forge python=3.11
|
156 |
-
conda activate notebook-forge
|
157 |
-
```
|
158 |
-
|
159 |
-
### 使用方法
|
160 |
-
1. コードブロックを含むマークダウンファイルを用意します。(例: `example/example01.md`)
|
161 |
-
|
162 |
-
2. 以下のコマンドを実行し、マークダウンファイルをJupyter Notebookに変換します。
|
163 |
-
```bash
|
164 |
-
python create_jupyter_notebook.py
|
165 |
-
```
|
166 |
-
|
167 |
-
3. 変換後のNotebookファイルが生成されます。(例: `example/example01.ipynb`)
|
168 |
-
|
169 |
-
### カスタマイズ
|
170 |
-
`create_jupyter_notebook.py`スクリプトの以下の部分を変更することで、入出力ファイルのパスをカスタマイズできます。
|
171 |
-
|
172 |
-
```python
|
173 |
-
markdown_file = 'example/example01.md'
|
174 |
-
output_file = 'example/example01.ipynb'
|
175 |
-
create_jupyter_notebook(markdown_file, output_file)
|
176 |
-
```
|
177 |
-
|
178 |
-
## Contributing
|
179 |
-
NotebookForgeへの貢献を歓迎します。バグ報告、機能要望、プルリクエストをお待ちしております。
|
180 |
-
|
181 |
-
## License
|
182 |
-
NotebookForgeはMITライセンスの下で公開されています。詳細は[LICENSE](LICENSE)ファイルを参照してください。
|
183 |
-
|
184 |
-
## Acknowledgements
|
185 |
-
|
186 |
-
NotebookForgeの開発にあたり、以下のオープンソースプロジェクトを参考にさせていただきました。
|
187 |
-
|
188 |
-
- [Jupyter Notebook](https://jupyter.org/)
|
189 |
-
- [nbformat](https://github.com/jupyter/nbformat)
|
190 |
-
|
191 |
-
```
|
192 |
-
|
193 |
-
## app.py
|
194 |
-
|
195 |
-
```python
|
196 |
-
import streamlit as st
|
197 |
-
from create_jupyter_notebook import create_jupyter_notebook
|
198 |
-
import base64
|
199 |
-
|
200 |
-
def download_notebook(notebook_file):
|
201 |
-
with open(notebook_file, 'rb') as file:
|
202 |
-
notebook_data = file.read()
|
203 |
-
b64 = base64.b64encode(notebook_data).decode()
|
204 |
-
href = f'<a href="data:application/octet-stream;base64,{b64}" download="{notebook_file}">ノートブックをダウンロード</a>'
|
205 |
-
return href
|
206 |
-
|
207 |
-
def main():
|
208 |
-
|
209 |
-
st.markdown('''
|
210 |
-
|
211 |
-
<p align="center">
|
212 |
-
<img src="https://raw.githubusercontent.com/Sunwood-ai-labs/NotebookForgeBeta/main/docs/NotebookForge_icon.jpg" width="50%">
|
213 |
-
<br>
|
214 |
-
<h1 align="center">NotebookForge</h1>
|
215 |
-
<h3 align="center">~Markdown to Jupyter Notebook Converter~</h3>
|
216 |
-
|
217 |
-
</p>
|
218 |
-
|
219 |
-
''', unsafe_allow_html=True)
|
220 |
-
markdown_content = st.text_area('Markdownファイルの内容を貼り付けてください', height=400)
|
221 |
-
|
222 |
-
if st.button('変換'):
|
223 |
-
if markdown_content.strip():
|
224 |
-
with open('temp_markdown.md', 'w', encoding='utf-8') as file:
|
225 |
-
file.write(markdown_content)
|
226 |
-
|
227 |
-
output_file = 'output_notebook.ipynb'
|
228 |
-
create_jupyter_notebook('temp_markdown.md', output_file)
|
229 |
-
|
230 |
-
st.success('ノートブックが生成されました。')
|
231 |
-
st.markdown(download_notebook(output_file), unsafe_allow_html=True)
|
232 |
-
else:
|
233 |
-
st.warning('Markdownファイルの内容を入力してください。')
|
234 |
-
|
235 |
-
if __name__ == '__main__':
|
236 |
-
main()
|
237 |
-
```
|
238 |
-
|
239 |
-
## example/example01.md
|
240 |
-
|
241 |
-
```markdown
|
242 |
-
# Cohere APIのClassifyエンドポイントとは
|
243 |
-
|
244 |
-
Classifyエンドポイントは、テキストを事前に定義されたクラス(カテゴリ)に分類するための機能です。いくつかの例を使って、生成モデルからクラス分類器を作成します。内部的には、few-shot分類プロンプトを構築し、それを使って入力テキストを分類します。
|
245 |
-
|
246 |
-
## Classifyエンドポイントの使用例
|
247 |
-
|
248 |
-
顧客サポートチケットの分類に使えます。例えば、保険会社に届く顧客メールを以下の4つのタイプに自動分類できます。
|
249 |
-
|
250 |
-
- 保険証券の詳細を探す
|
251 |
-
- アカウント設定の変更
|
252 |
-
- 保険金請求と状況確認
|
253 |
-
- 保険の解約
|
254 |
-
|
255 |
-
これにより、サポートチームは手動で情報を分析してルーティングする手間を省けます。
|
256 |
-
|
257 |
-
## Classifyエンドポイントの使い方
|
258 |
-
|
259 |
-
### 1. Cohere SDKのインストール
|
260 |
-
|
261 |
-
まず、Cohere SDKをインストールします。
|
262 |
-
|
263 |
-
```bash
|
264 |
-
pip install cohere
|
265 |
-
```
|
266 |
-
|
267 |
-
### 2. Cohere clientの設定
|
268 |
-
|
269 |
-
次に、Cohere clientを設定します。
|
270 |
-
|
271 |
-
```python
|
272 |
-
import cohere
|
273 |
-
co = cohere.Client(api_key)
|
274 |
-
```
|
275 |
-
|
276 |
-
### 3. 学習用の例の追加
|
277 |
-
|
278 |
-
学習用の例を追加します。各例はテキストとそれに対応するラベル(���ラス)で構成されます。各クラスに最低2つの例が必要です。
|
279 |
-
|
280 |
-
```python
|
281 |
-
from cohere.responses.classify import Example
|
282 |
-
|
283 |
-
examples=[
|
284 |
-
Example("保険証券はどこで見つけられますか?", "保険証券の詳細を探す"),
|
285 |
-
Example("保険証券のコピーをダウンロードする方法は?", "保険証券の詳細を探す"),
|
286 |
-
...
|
287 |
-
]
|
288 |
-
```
|
289 |
-
|
290 |
-
### 4. 分類対象テキストの追加
|
291 |
-
|
292 |
-
分類したいテキストを入力として追加します。
|
293 |
-
|
294 |
-
```python
|
295 |
-
inputs=["パスワードを変更したいのですが",
|
296 |
-
"私の保険で処方薬はカバーされていますか?"
|
297 |
-
]
|
298 |
-
```
|
299 |
-
|
300 |
-
### 5. Classifyエンドポイントの呼び出し
|
301 |
-
|
302 |
-
Classifyエンドポイントを呼び出して分類します。モデルのタイプを指定します(デフォルトはlarge)。
|
303 |
-
|
304 |
-
```python
|
305 |
-
response = co.classify(
|
306 |
-
model='large',
|
307 |
-
inputs=inputs,
|
308 |
-
examples=examples)
|
309 |
-
|
310 |
-
print(response.classifications)
|
311 |
-
```
|
312 |
-
|
313 |
-
## レスポンスの例
|
314 |
-
|
315 |
-
```json
|
316 |
-
{
|
317 |
-
"results": [
|
318 |
-
{
|
319 |
-
"text": "パスワードを変更したいのですが",
|
320 |
-
"prediction": "アカウント設定の変更",
|
321 |
-
"confidence": 0.82,
|
322 |
-
...
|
323 |
-
},
|
324 |
-
{
|
325 |
-
"text": "私の保険で処方薬はカバーされていますか?",
|
326 |
-
"prediction": "保険証券の詳細を探す",
|
327 |
-
"confidence": 0.75,
|
328 |
-
...
|
329 |
-
}
|
330 |
-
]
|
331 |
-
}
|
332 |
-
```
|
333 |
-
|
334 |
-
以上が、Cohere APIのClassifyエンドポイントの概要と基本的な使い方です。テキスト分類タスクを手軽に実装できる便利な機能といえるでしょう。
|
335 |
-
```
|
336 |
-
|
337 |
-
## script/activate-notebook-forge.bat
|
338 |
-
|
339 |
-
```
|
340 |
-
conda activate notebook-forge
|
341 |
-
```
|
342 |
-
|
343 |
-
## script/activate-notebook-forge.sh
|
344 |
-
|
345 |
-
```bash
|
346 |
-
#!/bin/bash
|
347 |
-
conda activate notebook-forge
|
348 |
-
```
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -25,17 +25,21 @@ st.markdown("---")
|
|
25 |
# リポジトリのURLを入力するテキストボックス
|
26 |
repo_url = st.text_input("リポジトリのURL:")
|
27 |
st.markdown("---")
|
|
|
28 |
|
29 |
# .gitignoreのパターンを編集するサイドバー
|
30 |
st.sidebar.title(".gitignore Patterns")
|
31 |
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=600).split("\n")
|
|
|
|
|
|
|
32 |
|
33 |
if repo_url:
|
34 |
repo_name = repo_url.split("/")[-1].split(".")[0]
|
35 |
repo_path = clone_repository(repo_url, repo_name)
|
36 |
|
37 |
-
file_tree = get_file_tree(repo_path, ignore_patterns)
|
38 |
-
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns)
|
39 |
|
40 |
# マークダウンファイルを保存
|
41 |
output_name = "/tmp/__CodeLumiai"
|
|
|
25 |
# リポジトリのURLを入力するテキストボックス
|
26 |
repo_url = st.text_input("リポジトリのURL:")
|
27 |
st.markdown("---")
|
28 |
+
st.markdown("[Full Text](#full-text)")
|
29 |
|
30 |
# .gitignoreのパターンを編集するサイドバー
|
31 |
st.sidebar.title(".gitignore Patterns")
|
32 |
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=600).split("\n")
|
33 |
+
# 探索の最大深度を入力するテキストボックス
|
34 |
+
max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=2, step=1)
|
35 |
+
|
36 |
|
37 |
if repo_url:
|
38 |
repo_name = repo_url.split("/")[-1].split(".")[0]
|
39 |
repo_path = clone_repository(repo_url, repo_name)
|
40 |
|
41 |
+
file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
|
42 |
+
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth)
|
43 |
|
44 |
# マークダウンファイルを保存
|
45 |
output_name = "/tmp/__CodeLumiai"
|
docs/SourceSageDocs.md
CHANGED
@@ -2,5 +2,5 @@
|
|
2 |
|
3 |
```bash
|
4 |
|
5 |
-
sourcesage --repository CodeLumia --owner Sunwood-ai-labs
|
6 |
```
|
|
|
2 |
|
3 |
```bash
|
4 |
|
5 |
+
sourcesage --repository CodeLumia --owner Sunwood-ai-labs --ignore .SourceSageignore
|
6 |
```
|
docs/demo.gif
ADDED
Git LFS Details
|
docs/page_front.md
CHANGED
@@ -10,3 +10,6 @@
|
|
10 |
</h3>
|
11 |
|
12 |
</p>
|
|
|
|
|
|
|
|
10 |
</h3>
|
11 |
|
12 |
</p>
|
13 |
+
|
14 |
+
|
15 |
+
|
modules/file_operations.py
CHANGED
@@ -1,13 +1,16 @@
|
|
1 |
import os
|
2 |
import fnmatch
|
3 |
|
4 |
-
def get_file_tree(repo_path, ignore_patterns):
|
5 |
file_tree = ""
|
6 |
for root, dirs, files in os.walk(repo_path):
|
7 |
# .gitignoreに一致するディレクトリを無視
|
8 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
9 |
|
10 |
level = root.replace(repo_path, "").count(os.sep)
|
|
|
|
|
|
|
11 |
indent = " " * 4 * (level)
|
12 |
file_tree += f"{indent}{os.path.basename(root)}/\n"
|
13 |
subindent = " " * 4 * (level + 1)
|
@@ -17,11 +20,16 @@ def get_file_tree(repo_path, ignore_patterns):
|
|
17 |
file_tree += f"{subindent}{f}\n"
|
18 |
return file_tree
|
19 |
|
20 |
-
def process_files(repo_path, ignore_patterns):
|
21 |
file_contents = []
|
22 |
for root, dirs, files in os.walk(repo_path):
|
23 |
# .gitignoreに一致するディレクトリを無視
|
24 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
|
|
|
|
|
|
|
|
|
|
25 |
for file in files:
|
26 |
# .gitignoreに一致するファイルを無視
|
27 |
if not any(fnmatch.fnmatch(file, pattern) for pattern in ignore_patterns):
|
|
|
1 |
import os
|
2 |
import fnmatch
|
3 |
|
4 |
+
def get_file_tree(repo_path, ignore_patterns, max_depth):
|
5 |
file_tree = ""
|
6 |
for root, dirs, files in os.walk(repo_path):
|
7 |
# .gitignoreに一致するディレクトリを無視
|
8 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
9 |
|
10 |
level = root.replace(repo_path, "").count(os.sep)
|
11 |
+
if level > max_depth:
|
12 |
+
continue
|
13 |
+
|
14 |
indent = " " * 4 * (level)
|
15 |
file_tree += f"{indent}{os.path.basename(root)}/\n"
|
16 |
subindent = " " * 4 * (level + 1)
|
|
|
20 |
file_tree += f"{subindent}{f}\n"
|
21 |
return file_tree
|
22 |
|
23 |
+
def process_files(repo_path, ignore_patterns, max_depth):
|
24 |
file_contents = []
|
25 |
for root, dirs, files in os.walk(repo_path):
|
26 |
# .gitignoreに一致するディレクトリを無視
|
27 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
28 |
+
|
29 |
+
level = root.replace(repo_path, "").count(os.sep)
|
30 |
+
if level > max_depth:
|
31 |
+
continue
|
32 |
+
|
33 |
for file in files:
|
34 |
# .gitignoreに一致するファイルを無視
|
35 |
if not any(fnmatch.fnmatch(file, pattern) for pattern in ignore_patterns):
|
modules/markdown_operations.py
CHANGED
@@ -2,14 +2,14 @@ import json
|
|
2 |
from modules.file_operations import get_file_tree, process_files
|
3 |
import os
|
4 |
|
5 |
-
def create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns):
|
6 |
markdown_content = f"# << {repo_name}>> \n## {repo_name} File Tree\n\n```\n{file_tree}\n```\n\n"
|
7 |
|
8 |
# 拡張子と言語のマッピングを読み込む
|
9 |
with open("docs/language_map.json", "r") as f:
|
10 |
language_map = json.load(f)
|
11 |
|
12 |
-
file_contents = process_files(repo_path, ignore_patterns)
|
13 |
for file_path, content in file_contents:
|
14 |
_, file_extension = os.path.splitext(file_path)
|
15 |
language = language_map.get(file_extension, "")
|
|
|
2 |
from modules.file_operations import get_file_tree, process_files
|
3 |
import os
|
4 |
|
5 |
+
def create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth):
|
6 |
markdown_content = f"# << {repo_name}>> \n## {repo_name} File Tree\n\n```\n{file_tree}\n```\n\n"
|
7 |
|
8 |
# 拡張子と言語のマッピングを読み込む
|
9 |
with open("docs/language_map.json", "r") as f:
|
10 |
language_map = json.load(f)
|
11 |
|
12 |
+
file_contents = process_files(repo_path, ignore_patterns, max_depth)
|
13 |
for file_path, content in file_contents:
|
14 |
_, file_extension = os.path.splitext(file_path)
|
15 |
language = language_map.get(file_extension, "")
|
tmp/OSWorld
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit b9ae9b72b2b997c2ebd3978d1b1bd340db1e9abb
|