-
Notifications
You must be signed in to change notification settings - Fork 1
feat(voice): conversational trading AI via Telegram + web dashboard #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eddiebelaval
wants to merge
3
commits into
main
Choose a base branch
from
feature/deepstack-voice
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """ | ||
| DeepStack Voice Configuration | ||
|
|
||
| Non-secret settings for the voice system. Secrets live in deepstack-voice.env. | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| # ── Paths ────────────────────────────────────────────────────────── | ||
|
|
||
| PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
| ENV_FILE = os.path.join(PROJECT_ROOT, "deepstack-voice.env") | ||
| TRADING_BRAIN_PATH = os.path.join(PROJECT_ROOT, "docs", "TRADING_BRAIN.md") | ||
| SOUL_PATH = os.path.join(PROJECT_ROOT, "docs", "SOUL.md") | ||
| TRADE_JOURNAL_DB = os.path.join( | ||
| os.path.expanduser("~"), | ||
| "clawd", | ||
| "projects", | ||
| "kalshi-trading", | ||
| "trade_journal.db", | ||
| ) | ||
| DEEPSTACK_CONFIG_PATH = os.path.join(PROJECT_ROOT, "config", "config.yaml") | ||
| KALSHI_BOT_CONFIG_PATH = os.path.join( | ||
| os.path.expanduser("~"), | ||
| "clawd", | ||
| "projects", | ||
| "kalshi-trading", | ||
| "config.yaml", | ||
| ) | ||
| RISK_LIMITS_PATH = os.path.join(PROJECT_ROOT, "config", "risk_limits.yaml") | ||
|
|
||
| # State directory | ||
| STATE_DIR = os.path.join(PROJECT_ROOT, "data", "voice-state") | ||
| OFFSET_FILE = os.path.join(STATE_DIR, "telegram-offset.txt") | ||
| LOCK_DIR = os.path.join(STATE_DIR, "listener.lockdir") | ||
| CONVERSATION_LOG = os.path.join(STATE_DIR, "conversations.jsonl") | ||
|
|
||
| # Logs | ||
| LOG_DIR = os.path.join(PROJECT_ROOT, "logs") | ||
| LISTENER_LOG = os.path.join(LOG_DIR, "voice-listener.log") | ||
|
|
||
| # ── Telegram ─────────────────────────────────────────────────────── | ||
|
|
||
| TELEGRAM_API_BASE = "https://api.telegram.org" | ||
| POLL_TIMEOUT = 30 # seconds for long-polling | ||
| MAX_MESSAGE_LENGTH = 4000 # Telegram limit | ||
|
|
||
| # ── Claude Models ────────────────────────────────────────────────── | ||
|
|
||
| BRAIN_MODEL = "claude-sonnet-4-5-20250929" | ||
| BRAIN_MAX_TOKENS = 1024 | ||
| BRAIN_TIMEOUT = 30 # seconds | ||
|
|
||
| PARSE_MODEL = "claude-haiku-4-5-20251001" | ||
| PARSE_MAX_TOKENS = 100 | ||
| PARSE_TIMEOUT = 5 # seconds | ||
|
|
||
| # ── ElevenLabs TTS (used by Bash listener) ──────────────────────── | ||
|
|
||
| ELEVENLABS_MODEL = "eleven_turbo_v2_5" | ||
| ELEVENLABS_API_URL = "https://api.elevenlabs.io/v1/text-to-speech" | ||
|
|
||
| # ── Deepgram (used by Bash listener) ────────────────────────────── | ||
|
|
||
| DEEPGRAM_TRANSCRIPTION_URL = "https://api.deepgram.com/v1/listen" | ||
| DEEPGRAM_TTS_URL = "https://api.deepgram.com/v1/speak" | ||
|
|
||
| # ── Error Handling ───────────────────────────────────────────────── | ||
|
|
||
| ERROR_BACKOFF_BASE = 5 # seconds | ||
| ERROR_BACKOFF_MAX = 300 # 5 minutes | ||
| MAX_CONSECUTIVE_ERRORS = 10 | ||
|
|
||
| # NL parsing system prompt for Claude Haiku | ||
| NL_PARSE_SYSTEM = ( # noqa: E501 | ||
| "You classify trading-related messages into intent types.\n" | ||
| 'Return ONLY valid JSON: {"type": "<intent>", ' | ||
| '"args": [...], "confidence": "high|medium|low"}\n\n' | ||
| "Intent types:\n" | ||
| "- market_status: current market conditions, portfolio, P&L\n" | ||
| "- explain_trade: why a trade was made, reasoning\n" | ||
| "- strategy_question: how a strategy works, risk rules\n" | ||
| "- what_if: hypothetical scenarios\n" | ||
| "- portfolio_check: balance, positions, orders\n" | ||
| "- signal_alert: DeepSignals (dark pool, insider, congress, PCR)\n" | ||
| "- trade_journal: logging a trade, reviewing history\n" | ||
| "- general_chat: greetings, meta questions, anything else\n\n" | ||
| "Examples:\n" | ||
| '"how\'s my portfolio?" -> ' | ||
| '{"type": "portfolio_check", "args": [], ' | ||
| '"confidence": "high"}\n' | ||
| '"explain the mean reversion strategy" -> ' | ||
| '{"type": "strategy_question", ' | ||
| '"args": ["mean_reversion"], "confidence": "high"}\n' | ||
| '"any dark pool activity today?" -> ' | ||
| '{"type": "signal_alert", "args": ["dark_pool"], ' | ||
| '"confidence": "high"}\n' | ||
| '"what if SPY drops 5% tomorrow?" -> ' | ||
| '{"type": "what_if", "args": ["SPY", "drop", "5%"], ' | ||
| '"confidence": "high"}\n' | ||
| '"log: bought INXD YES at 45c" -> ' | ||
| '{"type": "trade_journal", ' | ||
| '"args": ["bought INXD YES at 45c"], ' | ||
| '"confidence": "high"}\n' | ||
| '"hey, you there?" -> ' | ||
| '{"type": "general_chat", "args": [], ' | ||
| '"confidence": "high"}' | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """DeepStack Voice - Conversational trading AI via Telegram and web dashboard.""" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Anthropic Claude API current model IDs claude-sonnet claude-haiku 2025💡 Result:
Anthropic’s Claude API model IDs (as used in 2025) for Sonnet and Haiku are:
Claude Sonnet 4
claude-sonnet-4-0(docs.anthropic.com)claude-sonnet-4-20250514(docs.anthropic.com)Claude Haiku 3.5
claude-3-5-haiku-latest(docs.anthropic.com)claude-3-5-haiku-20241022(docs.anthropic.com)(Older Haiku still listed in docs:
claude-3-haiku-20240307.) (docs.anthropic.com)Citations:
Update model identifiers to valid Anthropic API models.
The model strings
claude-sonnet-4-5-20250929andclaude-haiku-4-5-20251001are invalid and will cause API errors. Use one of these valid alternatives:claude-sonnet-4-0(recommended alias) orclaude-sonnet-4-20250514(snapshot)claude-3-5-haiku-latest(recommended alias) orclaude-3-5-haiku-20241022(snapshot)🤖 Prompt for AI Agents