AI最新ニュース 2026.05.13
【2026年5月】Ollama v0.30.0・LangChain 1.3.0・Claude Code /goalモード|最新アップデートまとめ
2026年5月の主要アップデートまとめ
| ツール | バージョン | 主な変更 |
|---|---|---|
| Ollama | v0.23.3+ | macOS 26 MLXバグ修正・GPU自動検出改善 |
| LangChain | 1.3.0 | Stream API刷新・新インターフェース |
| langchain-core | 0.3.86 | 基盤クラスの更新 |
| Claude Code | v2.1.132+ | /goalモード・API課金警告追加 |
Ollamaアップデート:macOS 26対応
# macOS(Homebrew)
brew upgrade ollama
# Linux(インストールスクリプト)
curl -fsSL https://ollama.com/install.sh | sh
# バージョン確認
ollama --version
# → ollama version 0.23.3
# MLXが正しく動作するか確認(Apple Silicon)
ollama run llama3.2:3b "hello"
Ollamaで主要モデルを使う
# ollama_client.py
# Ollamaのコスト0の本番的な使い方
import httpx
import json
def ollama_chat(prompt: str, model: str = "llama3.2:3b") -> str:
"""OllamaのローカルLLMにリクエストを送る(APIコスト:ゼロ)"""
response = httpx.post(
"http://localhost:11434/api/generate",
json={
"model": model,
"prompt": prompt,
"stream": False,
},
timeout=60.0,
)
return response.json()["response"]
def ollama_stream(prompt: str, model: str = "llama3.2:3b"):
"""ストリーミングで出力する"""
with httpx.stream(
"POST",
"http://localhost:11434/api/generate",
json={"model": model, "prompt": prompt, "stream": True},
timeout=60.0,
) as response:
for line in response.iter_lines():
if line:
data = json.loads(line)
if not data.get("done"):
yield data["response"]
# 使用例
result = ollama_chat("日本の首都を教えてください")
print(result)
# ストリーミング
for chunk in ollama_stream("PythonでFizzBuzzを書いて"):
print(chunk, end="", flush=True)
# 利用可能なモデル一覧
import subprocess
result = subprocess.run(["ollama", "list"], capture_output=True, text=True)
print(result.stdout)
LangChain 1.3.0:Stream API刷新
# langchain_1_3_update.py
# LangChain 1.3.0でのストリーミングの書き方
# pip install "langchain==1.3.0" "langchain-core==0.3.86" "langchain-anthropic"
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage
# モデル設定
model = ChatAnthropic(model="claude-haiku-4-5-20251001")
# ✅ 1.3.0以降の書き方
for chunk in model.stream([HumanMessage(content="1から10まで数えてください")]):
print(chunk.content, end="", flush=True)
print()
# バッチ処理(複数プロンプトを一度に)
messages_batch = [
[HumanMessage(content="Python の良いところは?")],
[HumanMessage(content="TypeScript の良いところは?")],
]
results = model.batch(messages_batch)
for r in results:
print(r.content[:100])
# バージョン確認
import langchain, langchain_core
print(f"langchain: {langchain.__version__}")
print(f"langchain-core: {langchain_core.__version__}")
Claude Code:/goalモードとBilling Warning
# /goalモード: 長時間タスクをバックグラウンドで実行
claude
> /goal このリポジトリ全体にユニットテストを追加して
# バックグラウンドで実行が始まる
# → [進捗] src/api/user.py のテストを作成中...
# → [完了] 15ファイルにテストを追加しました
# API課金アラートの設定
claude config set billingAlertThresholdUSD 10 # $10を超えたら警告
claude config get billingAlertThresholdUSD
# → 10
# 現在の利用状況確認
claude billing status
# claude_cost_monitor.py
# Claude CodeのAPIコストをPythonで監視する(webhook通知付き)
import anthropic
import os
from dataclasses import dataclass, field
@dataclass
class BillingMonitor:
threshold_usd: float = 10.0
current_usd: float = 0.0
# Claude Sonnet 4.5料金
INPUT_PRICE = 3.00 # $/1M
OUTPUT_PRICE = 15.00 # $/1M
def record(self, usage: object) -> None:
cost = (
usage.input_tokens * self.INPUT_PRICE +
usage.output_tokens * self.OUTPUT_PRICE
) / 1_000_000
self.current_usd += cost
if self.current_usd >= self.threshold_usd * 0.9:
print(f"⚠️ 警告: 利用額 ${self.current_usd:.3f} がしきい値の90%に達しました")
if self.current_usd >= self.threshold_usd:
raise Exception(f"❌ 利用額上限 ${self.threshold_usd} を超えました")
monitor = BillingMonitor(threshold_usd=5.0)
client = anthropic.Anthropic()
def guarded_call(prompt: str) -> str:
response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=256,
messages=[{"role": "user", "content": prompt}]
)
monitor.record(response.usage)
return response.content[0].text
guarded_call("Pythonで足し算をする関数を書いて")
print(f"現在の利用額: ${monitor.current_usd:.4f}")
あわせて読みたい
- OllamaでローカルLLMを構築|VRAM・トークン計算ガイド
- Claude Code インストール完全ガイド【2026年版】
- xAI・AnthropicのGPUリソース共有契約|ローカルAIへの影響