Skip to content

feat(llama-index): llama-index-llms-blockrun, paying on Base or Solana - #79

Merged
VickyXAI merged 1 commit into
mainfrom
feat/llama-index-integration
Oct 2, 2026
Merged

VickyXAI merged 1 commit into
mainfrom
feat/llama-index-integration

Conversation

@VickyXAI

@VickyXAI VickyXAI commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What

llama-index-llms-blockrun — a LlamaIndex LLM for any BlockRun chat model, living at integrations/llama-index-llms-blockrun and published as its own PyPI package.

from llama_index.llms.blockrun import BlockRun

llm = BlockRun(model="openai/gpt-5.5")                  # USDC on Base
llm = BlockRun(model="openai/gpt-5.5", chain="solana")  # USDC on Solana

Why a package and not an OpenAILike snippet

Context: run-llama/llama_index#23236. OpenAILike(api_base=..., api_key="fake") reaches the gateway and stops at the first 402 — nothing in the OpenAI client can sign a payment. LlamaIndex's CONTRIBUTING now asks for new provider integrations to live in their own repo and publish independently, so it lives here, next to the SDK it wraps, and CI tests it against this checkout.

Design

  • chain="base" → LLMClient / AsyncLLMClient; chain="solana" → SolanaLLMClient / AsyncSolanaLLMClient ([solana] extra). Payment, max_cost_per_call and retry rules stay in the SDK.
  • FunctionCallingLLM: chat, stream, async, tool calling, predict_and_call, FunctionAgent. Serialization reuses llama-index-llms-openai's to_openai_message_dicts.
  • Private key is a PrivateAttr — never serialized by to_dict() / callbacks.
  • temperature unset by default (reasoning models reject non-default values).
  • context_window read once from /v1/models; cached, falls back with a warning.
  • Solana's client has no **extra: unknown params are refused up front by name.
  • One async client per event loop (httpx.AsyncClient across asyncio.run() → "Event loop is closed").
  • ThinkingBlocks stripped before serializing (llama-index-llms-openai 0.6.5 raises on them).

CI / release

  • New llama-index CI job: floor pins (core 0.14.5, openai 0.6.5, py3.10) and current (py3.12).
  • publish-llama-index.yml publishes on releases tagged llama-index-llms-blockrun-v*; publish.yml now skips those tags. SDK sdist excludes integrations/.
  • Needs once on PyPI: a trusted publisher for llama-index-llms-blockrun → repo BlockRunAI/blockrun-llm, workflow publish-llama-index.yml, environment pypi.

Verification

  • 51 unit tests, passing on current deps (py3.13) and at the floor pins (py3.10); black, ruff, mypy clean; SDK unit suite 977 passed.
  • Live, both chains, deepseek/deepseek-chat: chat, stream, acomplete, astream_chat, predict_and_call, and a FunctionAgent run (1234 × 4567 = 5,635,678).

🤖 Generated with Claude Code

A LlamaIndex LLM for any BlockRun chat model, published from
integrations/llama-index-llms-blockrun as its own PyPI package.

OpenAILike(api_base=..., api_key="fake") reaches the gateway and stops at
the first 402: nothing in the OpenAI client can sign the payment. BlockRun
hands every request to this SDK instead, so payment, spend caps and the
no-double-pay retry rules are the SDK's, not a second copy of them.

- chain="base" (default) uses LLMClient/AsyncLLMClient; chain="solana" uses
  SolanaLLMClient/AsyncSolanaLLMClient (the [solana] extra).
- FunctionCallingLLM: chat, stream, async, tool calling, predict_and_call,
  FunctionAgent. Messages serialize through llama-index-llms-openai's own
  to_openai_message_dicts.
- The private key is a PrivateAttr, never a field, so to_dict()/to_json()
  and callback logs cannot carry it.
- temperature is unset by default: several reasoning models accept only
  their own.
- context_window is read once from /v1/models; failure is cached and falls
  back to LlamaIndex's default with a warning.
- Solana's client takes no **extra, so an unknown request parameter is
  refused up front, naming it, instead of a TypeError inside the SDK.
- One async client per running event loop: an httpx.AsyncClient cached
  across asyncio.run() calls fails with "Event loop is closed".
- ThinkingBlocks are stripped before serializing: llama-index-llms-openai
  0.6.5 raises on them.

CI gets a llama-index job at the floor pins (core 0.14.5, openai 0.6.5,
py3.10) and at current (py3.12), against this checkout of the SDK. Releases
tagged llama-index-llms-blockrun-v* publish through publish-llama-index.yml;
publish.yml skips them, and the SDK sdist now excludes integrations/.

Verified live on both chains with deepseek/deepseek-chat: chat, stream,
acomplete, astream_chat, predict_and_call and a FunctionAgent run.
@VickyXAI
VickyXAI merged commit c5757a0 into main Oct 2, 2026
6 checks passed
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.

1 participant