Skip to content

Gaotax2006 [ Elixir ] Fix #99: Add LLM Provider Abstraction Layer#747

Open
gtx20060124-bot wants to merge 6 commits into
Spectral-Finance:mainfrom
gtx20060124-bot:issues/99
Open

Gaotax2006 [ Elixir ] Fix #99: Add LLM Provider Abstraction Layer#747
gtx20060124-bot wants to merge 6 commits into
Spectral-Finance:mainfrom
gtx20060124-bot:issues/99

Conversation

@gtx20060124-bot

Copy link
Copy Markdown

Fixes #99

Create a universal LLM provider abstraction layer with auto-selection, smart fallback (circuit breaker), cost monitoring, response caching, and a provider registry system.

Files changed

  • lux/lib/lux/llm.ex\n- lux/lib/lux/llm/providers.ex\n- lux/test/unit/lux/llm/providers_test.exs\n

Acceptance checklist

  • Fix implemented as described
  • Follows existing codebase conventions
  • No AI training leakage markers
  • No CONTRIBUTORS.json modifications
  • No build artifacts committed

gtx20060124-bot and others added 6 commits June 18, 2026 00:44
- UDF protocol chart data fetching
- Technical indicators: SMA, EMA, RSI, MACD, Bollinger, Stochastic, ATR
- Signal generation from combined indicators
- Multi-timeframe analysis with consolidation
- Strategy backtesting (SMA crossover, RSI)
- Alert evaluation (oversold, overbought, MA crossover, Bollinger breakout)
- Market analysis via TradingView scanner API
…n, fallback, cost tracking, and caching

- Lux.LLM.Providers: registry, circuit breaker, cost monitoring, caching
- Auto-select provider by model name or task type (:fast, :cheap, :reasoning)
- Smart fallback chains with circuit breaker (5 failures → open, 30s timeout)
- ETS-based cost tracking with per-provider aggregation
- MD5-keyed response cache with configurable TTL
- Updated Lux.LLM default delegation from OpenAI -> Providers
- Comprehensive unit tests for all components
@MyTH-zyxeon

Copy link
Copy Markdown

Review pass for #99 acceptance.

I think this needs a focused fix before it is merge-ready:

  1. The new default path can crash before any provider call. Lux.LLM now delegates to Lux.LLM.Providers, but Providers.call/3 calls get_cached/1 before ensure_init!/0, so a normal cold Lux.LLM.call(prompt, tools, opts) can hit :ets.lookup(:lux_llm_cache, ...) before the ETS table exists. The tests call Providers.init() in setup, so they do not cover the new default delegate path.

  2. Even after init, Providers.call/3 normalizes options to a keyword list and then uses Map.put(opts, :model, model) before invoking the provider. Keyword lists are not maps, so the first non-cached provider call can raise BadMapError instead of returning the {:ok, response} / {:error, reason} contract.

  3. This PR also adds lux/lib/lux/lenses/tradingview/lens.ex, which is outside the LLM Provider Abstraction Layer $600 #99 LLM provider abstraction scope and overlaps the TradingView bounty surface. It also appears to contain compile/runtime hazards, for example the postfix profit_loss = ... if length(log) > 0 assignment and the with {:ok} <- {:ok, nil} guard in signals/1. I would split or remove that file from this PR.

  4. The cache key is only prompt|tools|model, so calls that differ by provider, task type, temperature, messages, json_schema, tool_choice, timeout, or fallback/cache options can collide and return a response generated under different semantics.

Suggested acceptance gate: remove the unrelated TradingView change, keep the options representation consistent through provider invocation, initialize ETS before any lookup, and add tests for cold Lux.LLM.call/3, a mocked provider fallback path, and cache-key separation without making a live provider request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLM Provider Abstraction Layer $600

2 participants