Skip to content

Repository files navigation

Raycast AI Chat Backend

Status: Archived / Maintenance Mode

Purpose: portfolio demonstration (architecture + engineering execution).

License: LICENSE and PORTFOLIO_NOTICE.md

English

Overview

FastAPI backend for Raycast-focused quick Q&A workflows, built with Azure OpenAI, SQLite, and Qdrant.

Main goals:

  • Low-latency daily Q&A
  • Stable streaming behavior
  • Controlled optional deep reasoning
  • Practical long-term memory retrieval

Public Snapshot Scope

This public repository intentionally excludes local/private operational assets:

  • scripts/ (local ops scripts)
  • tests/ (private/internal validation set)
  • .env, local data files, and local archives

Use PUBLIC_RELEASE_CHECKLIST.md before publishing updates.

Core Capabilities

  • Chat APIs
    • POST /api/chat/message (non-streaming)
    • POST /api/chat/stream (SSE streaming)
  • Strategy pipeline
    • auto and manual strategy modes
    • task-based decisions for deep thinking, web search, and long-term memory retrieval
  • Memory system
    • SQLite for conversation history
    • Qdrant for semantic long-term memory and negative-feedback memory
  • Runtime diagnostics
    • GET /api/chat/runtime/health
    • GET /api/chat/memory/health
  • Feedback loop
    • POST /api/chat/feedback

Streaming Behavior

  • Primary stream transport: Azure/OpenAI v1 /responses
    • incremental event: response.output_text.delta
    • completion event: response.completed (with [DONE] fallback support)
  • Compatibility behavior:
    • emits legacy mirror chunk / error events for older clients
    • automatically falls back to v1 /chat/completions when responses is unsupported (typical 400/404/422)
  • Response headers:
    • X-Conversation-Id
    • X-Stream-Deep-Thinking-Applied

Raycast Extension Behavior

Current extension request mode:

  • always sends strategy_mode="manual"
  • exposes two toggles only:
    • Deep Thinking
    • Web Search

API Surface

System:

  • GET /
  • GET /api/health
  • GET /health (alias)

Conversation:

  • POST /api/chat/message
  • POST /api/chat/stream
  • GET /api/chat/conversations
  • GET /api/chat/conversations/{conversation_id}
  • DELETE /api/chat/conversations/{conversation_id}

Strategy / Runtime:

  • GET /api/chat/reasoning-stats
  • POST /api/chat/strategy/preview
  • GET /api/chat/runtime/health

Memory / Feedback:

  • GET /api/chat/memory/health
  • GET /api/chat/memory/stats
  • GET /api/chat/memory/list
  • GET /api/chat/memory/search
  • DELETE /api/chat/memory/reset (ALLOW_MEMORY_RESET=true required)
  • POST /api/chat/feedback

Configuration

Required:

  • AZURE_OPENAI_ENDPOINT
  • AZURE_OPENAI_API_KEY
  • AZURE_OPENAI_DEPLOYMENT_NAME
  • AZURE_OPENAI_EMBEDDING_DEPLOYMENT

Model routing defaults:

  • DEFAULT_MODEL=gpt-5.1-chat
  • CS_SPECIALIST_MODEL=DeepSeek-R1-0528

See .env.example for full settings.

Run

Local:

uv sync
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

Docker:

docker compose up -d --build

Health checks:

curl http://127.0.0.1:8000/api/health
curl http://127.0.0.1:8000/api/chat/runtime/health
curl http://127.0.0.1:8000/api/chat/memory/health

Tracked Repository Layout (Public Snapshot)

raycast/
├── app/
├── Raycast_Extension/
├── docker-compose.yml
├── Dockerfile
├── pyproject.toml
├── requirements.txt
├── uv.lock
├── ARCHITECTURE.md
├── METRICS.md
├── PUBLIC_RELEASE_CHECKLIST.md
├── PORTFOLIO_NOTICE.md
├── LICENSE
└── README.md

Additional Docs


日本語

概要

本プロジェクトは、Raycast 向けの高速 Q&A 用バックエンドです。
技術スタックは FastAPI + Azure OpenAI + SQLite + Qdrant です。

目的:

  • 日常利用での低遅延応答
  • 安定したストリーミング
  • 必要時のみ深い推論を有効化
  • 実用的な長期記憶の再利用

公開リポジトリの範囲

この公開スナップショットには、以下のローカル資産は含めていません:

  • scripts/(ローカル運用スクリプト)
  • tests/(内部検証用)
  • .env、ローカルデータ、ローカルアーカイブ

公開前チェックは PUBLIC_RELEASE_CHECKLIST.md を参照してください。

主な機能

  • 対話 API
    • POST /api/chat/message(非ストリーミング)
    • POST /api/chat/stream(SSE ストリーミング)
  • 戦略パイプライン
    • auto / manual モード
    • タスク特性に応じて deep thinking / web search / 長期記憶参照を制御
  • 記憶
    • 会話履歴: SQLite
    • 長期記憶・負フィードバック記憶: Qdrant
  • 運用診断
    • GET /api/chat/runtime/health
    • GET /api/chat/memory/health
  • フィードバック
    • POST /api/chat/feedback

ストリーミング挙動

  • 主経路: Azure/OpenAI v1 /responses
    • 増分イベント: response.output_text.delta
    • 完了イベント: response.completed[DONE] フォールバック対応)
  • 互換性対策:
    • 旧クライアント向けに chunk / error ミラーイベントを出力
    • responses 非対応時(主に 400/404/422)は v1 /chat/completions に自動フォールバック
  • レスポンスヘッダ:
    • X-Conversation-Id
    • X-Stream-Deep-Thinking-Applied

Raycast 拡張の現状

  • リクエストは常に strategy_mode="manual" を送信
  • UI のトグルは 2 つのみ:
    • Deep Thinking
    • Web Search

実行方法

ローカル:

uv sync
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

Docker:

docker compose up -d --build

ヘルスチェック:

curl http://127.0.0.1:8000/api/health
curl http://127.0.0.1:8000/api/chat/runtime/health
curl http://127.0.0.1:8000/api/chat/memory/health

関連ドキュメント

About

Archived portfolio snapshot of a FastAPI backend for Raycast AI Chat workflows with Azure OpenAI, SSE streaming, SQLite history, and Qdrant memory.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages