Skip to content

Commit b4a6c73

Browse files
authored
Merge pull request #24 from igtm/feature/igtm-jjha
publish pypi
2 parents cd48ad4 + d3924e6 commit b4a6c73

File tree

7 files changed

+326
-84
lines changed

7 files changed

+326
-84
lines changed

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2025 igtm
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19+
OR OTHER DEALINGS IN THE SOFTWARE.

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# sdist に必要なファイルを含めるための設定
2+
include README.md
3+
include LICENSE
4+
include pyproject.toml
5+
recursive-include llm_coder *.py

README.ja.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# llm-coder
2+
3+
[English README available here](./README.md)
4+
5+
llm による自立型 Cli コーディングエージェントライブラリ llm-coder
6+
7+
ユーザーの指示通りコーディングし、自前の linter や formatter や test コードを評価フェーズに実行でき、通るまで修正します。
8+
llm api のインターフェースは litellm ライブラリを使用。Claude や OpenAI など自由な LLM を利用できます。
9+
モデルや API キーの設定方法は litellm のプロバイダ設定に準拠します。
10+
詳細は https://docs.litellm.ai/docs/providers を参照してください。
11+
12+
## インストール方法
13+
14+
### PyPI からインストール
15+
16+
```bash
17+
pip install llm-coder
18+
```
19+
20+
### ソースからインストール
21+
22+
1. リポジトリをクローンします:
23+
24+
```bash
25+
git clone https://github.com/igtm/llm-coder.git
26+
cd llm-coder
27+
```
28+
29+
2. 開発モードでパッケージをインストールします:
30+
31+
```bash
32+
pip install -e .
33+
```
34+
35+
これにより、プロジェクトディレクトリ内で `llm-coder` コマンドが利用可能になります。
36+
37+
## 使い方
38+
39+
インストール後、以下のコマンドで CLI ツールを実行できます:
40+
41+
```bash
42+
llm-coder <プロンプト> [オプション...]
43+
```
44+
45+
## 利用可能なオプション
46+
47+
```
48+
positional arguments:
49+
prompt 実行するプロンプト (省略時は標準入力から。TOMLファイルでも指定可能)
50+
51+
options:
52+
-h, --help ヘルプメッセージを表示して終了
53+
--config CONFIG TOML設定ファイルのパス (デフォルト: llm-coder-config.toml)
54+
--model MODEL, -m MODEL
55+
使用するLLMモデル (デフォルト: gpt-4.1-nano)
56+
--temperature TEMPERATURE, -t TEMPERATURE
57+
LLMの温度パラメータ (デフォルト: 0.5)
58+
--max-iterations MAX_ITERATIONS, -i MAX_ITERATIONS
59+
最大実行イテレーション数 (デフォルト: 10)
60+
--allowed-dirs ALLOWED_DIRS [ALLOWED_DIRS ...]
61+
ファイルシステム操作を許可するディレクトリ(スペース区切りで複数指定可) (デフォルト: ['.', 'playground'])
62+
--repository-description-prompt REPOSITORY_DESCRIPTION_PROMPT
63+
LLMに渡すリポジトリの説明プロンプト (デフォルト: TOMLファイルまたは空)
64+
--output OUTPUT, -o OUTPUT
65+
実行結果を出力するファイルパス (デフォルト: なし、標準出力のみ)
66+
--conversation-history CONVERSATION_HISTORY, -ch CONVERSATION_HISTORY
67+
エージェントの会話履歴を出力するファイルパス (デフォルト: なし)
68+
--request-timeout REQUEST_TIMEOUT
69+
LLM APIリクエスト1回あたりのタイムアウト秒数 (デフォルト: 60)
70+
```
71+
72+
### 使用例
73+
74+
```sh
75+
# 基本的な使い方
76+
llm-coder "Create a python script that outputs 'hello world'"
77+
78+
# モデルを指定
79+
llm-coder --model claude-3-opus-20240229 "Create a python script that outputs 'hello world'"
80+
81+
# 温度と最大イテレーション数を指定
82+
llm-coder --temperature 0.7 --max-iterations 5 "Create a python script that outputs 'hello world'"
83+
84+
# 許可するディレクトリを指定
85+
llm-coder --allowed-dirs . ./output ./src "Create a python script that outputs 'hello world'"
86+
87+
# リクエストタイムアウトを指定
88+
llm-coder --request-timeout 120 "Create a python script that outputs 'hello world'"
89+
90+
# 実行結果をファイルに出力
91+
llm-coder --output result.txt "Create a python script that outputs 'hello world'"
92+
93+
# 会話履歴をファイルに出力
94+
llm-coder --conversation-history conversation.txt "Create a python script that outputs 'hello world'"
95+
96+
# 実行結果と会話履歴の両方をファイルに出力
97+
llm-coder --output result.txt --conversation-history conversation.txt "Create a python script that outputs 'hello world'"
98+
```
99+
100+
## 設定
101+
102+
設定はコマンドライン引数または TOML ファイルを通じて行うことができます。
103+
104+
**設定の優先順位**: コマンドライン引数 > TOML 設定ファイル > ハードコードされたデフォルト値
105+
106+
### TOML 設定ファイルの例
107+
108+
デフォルトでは `llm-coder-config.toml` という名前の設定ファイルが読み込まれます。カスタム設定ファイルは `--config` オプションで指定できます。
109+
110+
```toml
111+
# グローバル設定
112+
model = "claude-3-opus-20240229"
113+
prompt = "Create a python script that outputs 'hello world'"
114+
temperature = 0.5
115+
max_iterations = 10
116+
request_timeout = 60
117+
allowed_dirs = ["."]
118+
repository_description_prompt = "このリポジトリはPythonのユーティリティツールです"
119+
# output = "result.txt"
120+
# conversation_history = "conversation.txt"
121+
```
122+
123+
設定ファイルを使用する場合:
124+
125+
```sh
126+
# デフォルトの設定ファイル (llm-coder-config.toml) を使用
127+
llm-coder
128+
129+
# カスタム設定ファイルを指定
130+
llm-coder --config my_config.toml
131+
```
132+
133+
### 開発中の直接実行
134+
135+
インストールせずに開発中に `cli.py` を直接実行することも可能です。挙動を試す用の `playground` ディレクトリを用意していますが、スクリプトの実行はプロジェクトのルートディレクトリから行う必要があります。
136+
137+
プロジェクトのルートディレクトリ (`llm-coder` ディレクトリのトップ) から以下のコマンドを実行してください:
138+
139+
```bash
140+
# プロジェクトのルートディレクトリにいることを確認
141+
uv run python -m llm-coder.cli <引数...>
142+
```
143+
144+
例:
145+
146+
```bash
147+
# プロジェクトのルートディレクトリにいることを想定
148+
uv run python -m llm-coder.cli "Create a python script that outputs 'hello world'"
149+
```
150+
151+
## llm-coder-litellm コマンドの使用方法
152+
153+
`llm-coder-litellm` コマンドは LiteLLM ライブラリを直接使用して LLM の completion API を呼び出すためのシンプルなラッパーです。
154+
155+
```bash
156+
llm-coder-litellm --model <モデル名> [オプション...] "プロンプト"
157+
```
158+
159+
### 利用可能なオプション
160+
161+
```text
162+
usage: llm-coder-litellm [-h] --model MODEL [--temperature TEMPERATURE] [--max_tokens MAX_TOKENS] [--top_p TOP_P] [--n N] [--stream] [--stop [STOP ...]]
163+
[--presence_penalty PRESENCE_PENALTY] [--frequency_penalty FREQUENCY_PENALTY] [--user USER] [--response_format RESPONSE_FORMAT]
164+
[--seed SEED] [--timeout TIMEOUT] [--output OUTPUT] [--extra EXTRA]
165+
[prompt]
166+
167+
litellm completion API ラッパー
168+
169+
positional arguments:
170+
prompt プロンプト(省略時は標準入力)
171+
172+
options:
173+
-h, --help show this help message and exit
174+
--model MODEL モデル名
175+
--temperature TEMPERATURE
176+
温度パラメータ (デフォルト: 0.2)
177+
--max_tokens MAX_TOKENS
178+
max_tokens
179+
--top_p TOP_P top_p
180+
--n N n
181+
--stream ストリーム出力
182+
--stop [STOP ...] ストップ語
183+
--presence_penalty PRESENCE_PENALTY
184+
presence_penalty
185+
--frequency_penalty FREQUENCY_PENALTY
186+
frequency_penalty
187+
--user USER user
188+
--response_format RESPONSE_FORMAT
189+
response_format (json など)
190+
--seed SEED seed
191+
--timeout TIMEOUT リクエストタイムアウト秒数 (デフォルト: 60)
192+
--output OUTPUT, -o OUTPUT
193+
出力ファイル
194+
--extra EXTRA 追加のJSONパラメータ
195+
```
196+
197+
### 使用例
198+
199+
```bash
200+
# 基本的な使い方
201+
llm-coder-litellm --model gpt-4.1-nano "Generate a summary of the following text"
202+
203+
# 温度を指定
204+
llm-coder-litellm --model gpt-4.1-nano --temperature 0.7 "Generate a summary of the following text"
205+
206+
# 出力をファイルに保存
207+
llm-coder-litellm --model gpt-4.1-nano --output summary.txt "Generate a summary of the following text"
208+
```

0 commit comments

Comments
 (0)