provider-factory

star 35

Provider Factory skill for the OpenCode ecosystem

MarceloClaro By MarceloClaro schedule Updated 6/8/2026

name: provider-factory version: "1.0.0" kind: python category: system affinity: {llm_client: 0.95, maswos-v5-nexus: 0.85, agent-node-pipeline: 0.80} description: Provider Factory skill for the OpenCode ecosystem

ProviderFactory — Multi-LLM com Fallback Automatico

Origem

Extraido de SandeClaw (specs/architecture.md secao 2.7, PRD.md RF-03). SandeClaw e um agente pessoal Telegram-first que opera 100% local.

Como Funciona

Fabrica que instancia provedores LLM (Gemini, DeepSeek, Groq) por configuracao. Cada provedor tem prioridade; se o primario falhar, o proximo assume automaticamente com retry + backoff exponencial.

LLM_PROVIDERS=gemini,deepseek  (variavel de ambiente)
      |
ProviderFactory.from_env()
      |
   .chat(messages)
      |
   [gemini tenta 3x com backoff]
      |-- falhou --> [deepseek tenta 3x]
                        |-- falhou --> RuntimeError
                        |-- OK --> resposta

Valor para OpenCode

  • Unificacao: Substitui chamadas dispersas a APIs de LLM por interface unica
  • Resiliencia: Fallback transparente evita interrupcao quando API primaria falha
  • Extensibilidade: Adicionar novo provedor = registrar classe + variavel de env
  • Compatibilidade: Protocolo SupportsChat — qualquer skill que precise de LLM pode receber uma ProviderFactory sem alteracoes

Uso

from skills.provider_factory.scripts.provider_factory import ProviderFactory

factory = ProviderFactory.from_env("LLM_")
response = factory.chat([{"role": "user", "content": "Explique ReAct"}])

Configuracao (.env)

LLM_PROVIDERS=gemini,deepseek
LLM_GEMINI_API_KEY=AIza...
LLM_GEMINI_MODEL=gemini-2.0-flash
LLM_GEMINI_PRIORITY=0
LLM_DEEPSEEK_API_KEY=sk-...
LLM_DEEPSEEK_MODEL=deepseek-chat
LLM_DEEPSEEK_PRIORITY=1

Ficheiros

  • scripts/provider_factory.py — implementacao completa (197 linhas)
Install via CLI
npx skills add https://github.com/MarceloClaro/OpenCode_Ecosystem --skill provider-factory
Repository Details
star Stars 35
call_split Forks 17
navigation Branch main
article Path SKILL.md
More from Creator
MarceloClaro
MarceloClaro Explore all skills →