Skip to content

BrainForge LLM Integration#62

Open
NeonCharlie-24 wants to merge 17 commits into
devfrom
feat/brainforge-integration
Open

BrainForge LLM Integration#62
NeonCharlie-24 wants to merge 17 commits into
devfrom
feat/brainforge-integration

Conversation

@NeonCharlie-24
Copy link
Copy Markdown
Collaborator

@NeonCharlie-24 NeonCharlie-24 commented May 6, 2026

Description

Integrates BrainForge as a backend that dynamically discovers and registers its expert personas as advisors. Personas are fetched from the BrainForge API, merged with static YAML personas, and periodically re-synced. Includes auth management, an OpenAI-compatible LLM client, orchestrator safety fixes, and unit tests.

Issues

Closes #49

Other Notes

  • BrainForge credentials are read from env vars (.env). Will need to add:
    • BRAINFORGE_USERNAME=guest
    • BRAINFORGE_PASSWORD=password
      to .env to run.
  • NucleotidingsLLM returns a 500 error. All other personas/models have been tested with curl and return responses as expected.
  • The periodic re-sync of personas introduced async edge cases that have been addressed, including ensuring the orchestrator uses the active provider's LLM (Gemini, vLLM) for routing decisions rather than pulling from an arbitrary persona, which could inadvertently select a BrainForge model.

@NeonCharlie-24 NeonCharlie-24 changed the title BrainForge LLM Backend Integration BrainForge LLM Integration May 6, 2026
@NeonCharlie-24 NeonCharlie-24 force-pushed the feat/brainforge-integration branch from 3e6e450 to 5fbac1b Compare May 12, 2026 19:58
@NeonCharlie-24 NeonCharlie-24 marked this pull request as ready for review May 12, 2026 20:10
@NeonCharlie-24 NeonCharlie-24 requested a review from NeonDaniel May 12, 2026 20:16
Copy link
Copy Markdown
Member

@NeonDaniel NeonDaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few implementation notes; main issue to address is the quality of responses from BrainForge models. I left a couple suggestions inline below, based mostly on this particular response:

NeonAI
12:02 PM
Thought
Exploring the core team at Neon AI, we find a group of highly skilled individuals dedicated to advancing AI technology.

What to do
Exploring the core team at Neon AI, we find a group of highly skilled individuals dedicated to advancing…
The team includes experts in machine learning, natural language processing, and computer vision, all committed to making AI…
Notable members such as Richard Leeds, Elon Gasper, and Clary Gasper bring a wealth of experience and innovation…
Next step
Exploring the core team at Neon AI, we find a group of highly skilled individuals dedicated to advancing…

Comment thread multi_llm_chatbot_backend/app/config.py Outdated
Comment thread multi_llm_chatbot_backend/app/config.py Outdated
Comment thread multi_llm_chatbot_backend/app/llm/improved_brainforge_client.py
@NeonCharlie-24 NeonCharlie-24 requested a review from NeonDaniel May 18, 2026 19:14
@NeonDaniel NeonDaniel changed the base branch from main to dev May 19, 2026 00:46
@NeonDaniel NeonDaniel added this to the 2.1 milestone May 19, 2026
@NeonCharlie-24
Copy link
Copy Markdown
Collaborator Author

Ah ok I passed extra_body.structured_outputs and got much better results! I also implemented some manual formatting specifically for the Brainforge model outputs and bypassed _ensure_compact_shape, which I think was causing the truncation.

@NeonCharlie-24 NeonCharlie-24 removed the request for review from NeonDaniel May 21, 2026 00:45
@NeonCharlie-24
Copy link
Copy Markdown
Collaborator Author

The logic to skip _ensure_compact_shape was brittle (just a hardcoded string search) and not aligned with the other clients' response processing. Instead, I added maxLength constraints to the JSON schema to keep the field lengths within _ensure_compact_shape's truncation limits. This way BrainForge responses flow through the same post-processing path as every other provider without being clipped.

I also doubled max_tokens for BrainForge requests. The original token budget was causing some responses to be truncated before the JSON could close, resulting in malformed outputs.

I think this mostly solves the BrainForge response issue while maintaining parity with the other providers!

@NeonCharlie-24 NeonCharlie-24 requested a review from NeonDaniel May 21, 2026 01:14
Copy link
Copy Markdown
Member

@NeonDaniel NeonDaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple nits; otherwise changes look good and worked locally for me

Comment thread multi_llm_chatbot_backend/app/core/brainforge_sync.py Outdated
Comment thread multi_llm_chatbot_backend/app/core/brainforge_sync.py Outdated
…ardcoded yaml config personas on app startup.
…s at the brainforge endpoint. checking every 10 minutes.
…tion and added guard against stale personas causing a crash in chat stream.
…st results so far for Neon AI assistant model.
…ses to be passed though _ensure_compact_shape without truncation.
@NeonCharlie-24 NeonCharlie-24 force-pushed the feat/brainforge-integration branch from c050e11 to ad704d3 Compare May 22, 2026 18:28
@NeonCharlie-24 NeonCharlie-24 requested a review from NeonDaniel May 22, 2026 18:36
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.

[FEAT] Support BrainForge LLM Backend

3 participants