Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ChatBranch is a web-based AI chat application that organizes conversations as trees. It focuses on clear navigation, precise branching, and practical collaboration features.

Notifications You must be signed in to change notification settings

daishir0/ChatBranch

Repository files navigation

ChatBranch

Overview

ChatBranch is a web-based AI chat application that organizes conversations as trees. It focuses on clear navigation, precise branching, and practical collaboration features.

Highlights

  • Conversation trees with user/assistant messages and branching
  • Three-dots action menus for messages and threads (clean UI)
  • Deep links (permalinks) to start from any point, including root-start links
  • Thread-specific persona (system prompt) per conversation thread
  • File attachments as additional context for AI responses
  • Token usage summary (cumulative) on assistant nodes
  • Rich rendering (Markdown, code highlight, KaTeX, Mermaid)
  • Mobile-optimized UX, real-time thread search, dark/light theme

setting persona www

Installation

Prerequisites

  • PHP 8.2+ (required for OpenAI library)
  • Apache/Nginx
  • PDO SQLite, cURL, JSON PHP extensions
  • Composer (for dependencies including OpenAI library)
  • Write permission to the app directory

Step-by-step

  1. Clone and place under your web root
git clone https://github.com/daishir0/ChatBranch.git
sudo cp -r ChatBranch /var/www/html/ChatBranch
cd /var/www/html/ChatBranch
  1. Install dependencies (required for OpenAI integration and Office/PDF parsing)
# Install Composer if not available
curl -sS https://getcomposer.org/installer | php

# Install all dependencies including OpenAI PHP client
php composer.phar install
  1. Set ownership/permission (adjust user/group for your server)
sudo chown -R apache:apache /var/www/html/ChatBranch  # CentOS/RHEL/Amazon Linux
# or
sudo chown -R www-data:www-data /var/www/html/ChatBranch  # Ubuntu/Debian
sudo chmod 755 /var/www/html/ChatBranch
  1. Open the app in a browser
  • Navigate to http://your-domain/ChatBranch/ and follow the setup wizard
  • Enter Basic Auth credentials and your OpenAI API key
  • After installation, delete setup.php for security

Configuration tips: config.php includes auth (Basic Auth), openai.api_key, system.base_url, and system.timezone.

OpenAI Integration: This application uses the industry-standard openai-php/client library for robust OpenAI API integration with support for multiple model series. Context compression is disabled to provide transparent error handling for token limits.

Supported AI Models

  • GPT-5 Series: Latest reasoning models with advanced capabilities
    • gpt-5-mini (recommended): Balanced performance and cost
    • gpt-5: Most advanced reasoning model
  • GPT-4 Series: High-performance models with multimodal capabilities
    • gpt-4o-mini: Fast and efficient for general tasks
    • gpt-4o: High-performance with multimodal capabilities
    • gpt-4o-search-preview: GPT-4o with real-time web search
    • gpt-4o-mini-search-preview: GPT-4o Mini with real-time web search
  • o1 Series: Advanced reasoning models for complex problems
    • o1-preview: Advanced reasoning for complex problems
    • o1-mini: Optimized for coding and math
  • GPT-3.5 Series: Fast and cost-effective models
    • gpt-3.5-turbo: Fast and cost-effective for simple tasks

Web Search Feature: Select any Search Preview model (gpt-4o-search-preview or gpt-4o-mini-search-preview) to automatically enable real-time web search capabilities. The AI can access current information and provide up-to-date responses with source citations.

Usage

Starting a new chat

  • Click “New Chat” and send your first message
  • Keyboard: Enter=send (PC), Shift+Enter=new line; on mobile, Enter inserts a new line

New Tree Mode (root-start in existing thread)

  • Click 🆕 to enter New Tree mode; your next send creates a root-level user message (no parent)
  • The placeholder panel also provides “Copy root-start link”

Threads (left sidebar)

  • Search in real time; toggle archive view
  • Each thread row has a three-dots menu:
    • ✏️ Edit name
    • 📦 Archive / 📤 Unarchive
    • 🗑️ Delete

Messages (three-dots menu)

  • User message actions:
    • 📋 Copy
    • 🔗 Copy permalink (deep link to this message)
    • ✏️ Edit (regenerates the child AI response)
    • 🌿 Branch (creates an alternative user message at the same parent = sibling branch)
    • 🗑️ Delete (removes the message and all descendants)
  • Assistant message actions:
    • 📋 Copy

Deep links (permalinks)

  • Message permalink (user messages only): ?thread=<threadId>&message=<messageId>
    • Copy from the message menu (🔗 Copy permalink)
    • On open: the app opens the thread and displays the path to that message; your next send continues from the end of the displayed path
  • Root-start link: ?thread=<threadId>&start=root
    • Copy in New Tree mode (🔗 Copy root-start link)
    • On open: the app enters New Tree mode in the target thread and the next send creates a root message (parent_message_id=null)
  • Authentication: if Basic Auth prompts, the browser retries the same URL after auth, so deep-link intent is preserved

Files

  • Attach files via 📎; supported formats include PDF/Office/text
  • Attached content is injected into the AI context as additional user messages

Tree view and rendering

  • 🌳 toggles the tree panel (vis-network)
  • Markdown, code highlight, KaTeX, and Mermaid are supported

Token usage

  • Assistant nodes show cumulative token usage along the path

Internationalization

  • English and Japanese are included; add more under lang/

Troubleshooting

  • Ensure PHP 8.2+ and extensions (PDO SQLite, cURL, JSON) are enabled
  • Run php composer.phar install to install required dependencies
  • Check directory permissions and server user
  • Remove setup.php after installation
  • For token limit errors: the app now shows clear error messages instead of auto-compressing context

Publication

ChatBranch — The AI Conversation Platform that Changes How We Think (Ready Tensor)

  • URL: https://app.readytensor.ai/publications/chatbranch-the-ai-conversation-platform-that-changes-how-we-think-HFKsqg1ERUig
  • Key takeaways:
    • Parallel exploration with branching/sub-branching (e.g., Strategy, Risk, Financial) keeps context while diverging lines of inquiry
    • Visual conversation trees help teams see the full decision landscape and maintain shared understanding
    • Robust relational design (threads/messages/parents) preserves structure for analysis and review; cumulative token usage informs cost/length
    • Practical workflows: sibling branching from any user message; root-start links to begin fresh paths in the same thread
    • Business value: reduces context switching and meetings, increases traceability, speeds up consensus and strategic decisions

License

MIT


ChatBranch(日本語)

概要

ChatBranch は、会話をツリーで管理する Web ベースの AI チャットです。分岐のしやすさ、ナビゲーション性、実用的な連携機能に重点を置いています。

主なポイント

  • 会話ツリーと分岐(ユーザー/AI メッセージ)
  • 三点メニューでメッセージ/スレッド操作を集約
  • 任意位置から開始できるパーマリンク(ルート開始リンク含む)
  • スレッドごとのペルソナ(thread system prompt)
  • ファイル添付は AI の文脈として利用
  • AI ノードに累積トークン使用量を表示
  • Markdown/コード/KaTeX/Mermaid 対応
  • モバイル最適化、リアルタイム検索、ダーク/ライトテーマ

インストール

前提

  • PHP 8.2+(OpenAI ライブラリに必要)
  • Apache/Nginx
  • PDO SQLite / cURL / JSON 拡張
  • Composer(OpenAI ライブラリを含む依存関係管理用)
  • アプリディレクトリへの書き込み権限

手順

  1. 配置
git clone https://github.com/daishir0/ChatBranch.git
sudo cp -r ChatBranch /var/www/html/ChatBranch
cd /var/www/html/ChatBranch
  1. 依存関係インストール(OpenAI 統合とドキュメント解析に必要)
# Composer がない場合はインストール
curl -sS https://getcomposer.org/installer | php

# OpenAI PHP クライアントを含むすべての依存関係をインストール
php composer.phar install
  1. 権限
sudo chown -R apache:apache /var/www/html/ChatBranch  # CentOS/RHEL/Amazon Linux
# または
sudo chown -R www-data:www-data /var/www/html/ChatBranch  # Ubuntu/Debian
sudo chmod 755 /var/www/html/ChatBranch
  1. ブラウザでアクセス
  • http://your-domain/ChatBranch/ → セットアップウィザード
  • Basic 認証と OpenAI API キーを設定
  • セットアップ後は setup.php を必ず削除

config.php の主な設定: auth(Basic 認証), openai.api_key, system.base_url, system.timezone

OpenAI 統合: このアプリケーションは業界標準の openai-php/client ライブラリを使用して、複数のモデルシリーズに対応した堅牢な OpenAI API 統合を提供します。コンテキスト圧縮は無効化され、トークン制限に対する透明なエラーハンドリングを提供します。

対応AIモデル

  • GPT-5 シリーズ: 高度な機能を持つ最新の推論モデル
    • gpt-5-mini(推奨): パフォーマンスとコストのバランス
    • gpt-5: 最も高度な推論モデル
  • GPT-4 シリーズ: マルチモーダル機能を持つ高性能モデル
    • gpt-4o-mini: 一般的なタスクに高速で効率的
    • gpt-4o: マルチモーダル機能を持つ高性能モデル
    • gpt-4o-search-preview: リアルタイム Web 検索機能付き GPT-4o
    • gpt-4o-mini-search-preview: リアルタイム Web 検索機能付き GPT-4o Mini
  • o1 シリーズ: 複雑な問題に対応する高度な推論モデル
    • o1-preview: 複雑な問題に対応する高度な推論
    • o1-mini: コーディングと数学に最適化
  • GPT-3.5 シリーズ: 高速でコスト効率の良いモデル
    • gpt-3.5-turbo: シンプルなタスクに高速でコスト効率的

Web 検索機能: Search Preview モデル(gpt-4o-search-preview または gpt-4o-mini-search-preview)を選択すると、リアルタイム Web 検索機能が自動的に有効になります。AI は最新の情報にアクセスし、ソース付きの最新の回答を提供できます。

使い方

新規チャット

  • 「New Chat」から送信
  • キーボード: PC は Enter=送信 / Shift+Enter=改行、モバイルは Enter=改行

新規ツリーモード(既存スレッドのルート開始)

  • 🆕 で New Tree モードに入り、次の送信で親なしのルートユーザーメッセージを作成
  • プレースホルダーに「ルートから開始リンクをコピー」を表示

スレッド(左)

  • リアルタイム検索、アーカイブ表示切替
  • 行の三点メニュー:
    • ✏️ 名前編集
    • 📦 アーカイブ / 📤 解除
    • 🗑️ 削除

メッセージ(三点メニュー)

  • ユーザーメッセージ:
    • 📋 コピー
    • 🔗 パーマリンクをコピー(このメッセージへのリンク)
    • ✏️ 編集(子の AI 応答を再生成)
    • 🌿 分岐(同じ親を持つ別案=兄弟分岐を作成)
    • 🗑️ 削除(配下ごと削除)
  • AI メッセージ:
    • 📋 コピー

パーマリンク(Deep Link)

  • メッセージ: ?thread=<threadId>&message=<messageId>
    • ユーザーメッセージのメニューからコピー
    • 開くとそのメッセージまでのパスを表示。以後の送信は表示中パスの末尾から継続
  • ルート開始: ?thread=<threadId>&start=root
    • New Tree モードでコピー
    • 開くと新規ツリーモードで親なし投稿開始(parent_message_id=null)
  • 認証: Basic 認証後も同じ URL で再リクエストされるため、リンクの意図は保持されます

ファイル

  • 📎 で添付。PDF/Office/テキスト等に対応
  • 添付の内容は AI への追加ユーザーメッセージとして文脈に注入

ツリー/表示

  • 🌳 でツリー表示(vis-network)
  • Markdown/コード/数式/図に対応

トークン

  • AI ノードにその経路の累積トークン使用量を表示

国際化

  • 英語/日本語を同梱。lang/ に追加可能

トラブルシューティング

  • PHP 8.2+ と拡張(PDO SQLite, cURL, JSON)を有効化
  • php composer.phar install で必要な依存関係をインストール
  • ディレクトリ権限/サーバーユーザーを確認
  • セットアップ後に setup.php を削除
  • トークン制限エラー: 自動圧縮の代わりに明確なエラーメッセージを表示するように変更

技術記事(Publication)

ChatBranch — The AI Conversation Platform that Changes How We Think(Ready Tensor)

  • URL: https://app.readytensor.ai/publications/chatbranch-the-ai-conversation-platform-that-changes-how-we-think-HFKsqg1ERUig
  • 要点:
    • 分岐/サブ分岐により、戦略・リスク・財務など複数観点を並行検討しつつ文脈を保持
    • 会話ツリーの可視化で、意思決定の全体像を共有・整理しやすい
    • スレッド/メッセージ/親子関係の堅牢なデータ設計により、構造化された記録と分析が可能(累積トークン情報も有用)
    • 実務フロー: 任意のユーザーメッセージから兄弟分岐、同一スレッドのルート開始リンクで新規パスを開始
    • ビジネス価値: 文脈切替や会議回数を削減し、トレーサビリティを高め、合意形成と戦略決定を加速

ライセンス

MIT

About

ChatBranch is a web-based AI chat application that organizes conversations as trees. It focuses on clear navigation, precise branching, and practical collaboration features.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •