-
Notifications
You must be signed in to change notification settings - Fork 2
Integration framework API #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c076548 to
2068bd1
Compare
| ### 1. Create the integration directory structure | ||
|
|
||
| ```bash | ||
| mkdir -p lib/braintrust/contrib/trustybrain_llm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should keep github in the path for new stuff.
clutchski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should include moving the instrumentation to this method so we can verify it actually works.
my question is how does it handle the muitple libraries that use require 'openai'
|
Can you also show exactly how users will call this? |
realark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd second Matt's feedback about moving the existing instrumentation over to call this feature done, but if you'd like to get this on to main first then follow-up that SGTM
|
No problem: I can hold off onto merging this until we can prove one integration works well on top of it. (This was my intent anyway!) I'd like to clarify on the integration paths/require behavior though. As these are two separate issues. Integrations can "subscribe" to a # After triggered by `require 'openai'`...
# Check which OpenAI gem's code is actually loaded by inspecting $LOADED_FEATURES
# (both gems can be in Gem.loaded_specs, but only one's code can be loaded)
openai_load_path = $LOADED_FEATURES.find { |f| f.end_with?("/openai.rb") }
return unless Gem.loaded_specs["ruby-openai"] && openai_load_path&.include?("ruby-openai")In regards to directory names, embedding repository metadata is not idiomatic to Ruby. I would suggest two options: Option 1: Name integrations by rubygems.org name (simplest)
Option 2: Subdivide by source
My recommendation: Option 1 is the simplest, most idiomatic solution, as Option 2 only adds benefit in a low-probability hypothetical scenario. Let me know your thoughts! |
b395f81 to
b5153ca
Compare
b5153ca to
d6c6d33
Compare
|
Closing this while I reformulate PRs. |
Integration framework API
Purpose & Benefits
This PR lays the foundation for auto-instrumentation of AI libraries (OpenAI, Anthropic, etc.) by introducing an integration framework that provides a consistent, scalable pattern for integrations.
This PR introduces the framework only (registry, base classes, generator). No actual library integrations yet—those come later.
Adding New Integrations
Contributors can now scaffold new integrations with a single command:
This generates:
See
CONTRIBUTING.mdfor full documentation.Design & Key Principles
Architecture (at a glance)
Key Design Decisions
Integrationschema acts as a single source of metadata for the integration, suitable for programmatic usage (to be leveraged by auto instrumentation in the near future.)