Provider factory

From MarceloClaro/OpenCode_Ecosystem · View interactive version

Provider factory is an AI agent skill from the GitHub repository MarceloClaro/OpenCode_Ecosystem. Provider Factory skill for the OpenCode ecosystem

How to use this skill

Skill file

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

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.