Skip to content

Commit 235f877

Browse files
committed
publish pypi
1 parent cd48ad4 commit 235f877

File tree

7 files changed

+310
-77
lines changed

7 files changed

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

0 commit comments

Comments
 (0)