% zoltraak "WebAPIを利用したアプリケーションを開発する" -c dev_func
Traceback (most recent call last):
File "/Users/jasagiri/workspace/.venv/bin/zoltraak", line 8, in
sys.exit(main())
^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/cli.py", line 49, in main
process_text_input(args) # - テキスト入力を処理する関数を呼び出す
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/cli.py", line 165, in process_text_input
md_file_path = generate_md_file_name(text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/cli.py", line 192, in generate_md_file_name
response = claude.generate_response("claude-3-haiku-20240307",file_name_prompt, 100, 0.7)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/llms/claude.py", line 20, in generate_response
response = client.messages.create(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_utils/_utils.py", line 277, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/resources/messages.py", line 904, in create
return self._post(
^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 1249, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 931, in request
return self._request(
^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 952, in _request
request = self._build_request(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 460, in _build_request
headers = self._build_headers(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 418, in _build_headers
headers = httpx.Headers(headers_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/httpx/_models.py", line 76, in init
normalize_header_value(v, encoding),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/httpx/_utils.py", line 53, in normalize_header_value
return value.encode(encoding or "ascii")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
手順書をpoetry向けにアレンジして、インストールして、試しています。 下記エラーが出て実行できませんでした。
Webを検索してでてきた、envにPYTHONIOENCODING=utf-8を設定するなどしてみましたが解消しませんでした。
下記対応方法でエラーは解消したのですが、zoltraakのパッケージ内の話ではないので、正しい修正なのか不安です。 ライブラリの使い方が間違っているかもしれないので、zoltraak側で対応できるようなら対応をお願いいたします。
もしくは、環境設定の問題なら、確認箇所や設定等ご教示いただければと思います。
対応方法
.venv/lib/python3.12/site-packages/httpx/_utils.py の 53行目を変更
環境
MacBook Air M2 2022 macOS Sonoma 14.5 done poetry python 3.12.3
エラーメッセージ
% zoltraak "WebAPIを利用したアプリケーションを開発する" -c dev_func Traceback (most recent call last): File "/Users/jasagiri/workspace/.venv/bin/zoltraak", line 8, in
sys.exit(main())
^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/cli.py", line 49, in main
process_text_input(args) # - テキスト入力を処理する関数を呼び出す
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/cli.py", line 165, in process_text_input
md_file_path = generate_md_file_name(text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/cli.py", line 192, in generate_md_file_name
response = claude.generate_response("claude-3-haiku-20240307",file_name_prompt, 100, 0.7)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/zoltraak/llms/claude.py", line 20, in generate_response
response = client.messages.create(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_utils/_utils.py", line 277, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/resources/messages.py", line 904, in create
return self._post(
^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 1249, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 931, in request
return self._request(
^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 952, in _request
request = self._build_request(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 460, in _build_request
headers = self._build_headers(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/anthropic/_base_client.py", line 418, in _build_headers
headers = httpx.Headers(headers_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/httpx/_models.py", line 76, in init
normalize_header_value(v, encoding),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jasagiri/workspace/.venv/lib/python3.12/site-packages/httpx/_utils.py", line 53, in normalize_header_value
return value.encode(encoding or "ascii")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)