Skip to content
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

Extract provider data properly (attempt 2) #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ashwinb
Copy link
Contributor

@ashwinb ashwinb commented Sep 29, 2024

In the previous design, the server endpoint at the top-most level extracted the headers from the request and set provider data (e.g., private keys) that the implementations could retrieve using get_request_provider_data().

However, as Yogish has shown in #138, this is not sufficient. Consider the /agents API -- Together uses the standard "meta-reference" implementation for it but the inference provider is set to be Together. When an incoming request arrives, no "provider data validator" is registered for Agents because Agents isn't using the Together provider at all. However, when the agent calls inference as its dependency, the inference implementation does need the Together API key.

The solution is straightforward:

  • the server at the top-level does not have the correct context to validate the headers. what it should only do is extract them, json-decode them and stash the resulting dict into a thread-local.
  • the provider implementation when it needs the data, queries it using an instance method on the implementation. The instance method works via a utility mixin (NeedsRequestProviderData).
  • this mixin is able to query the underlying provider spec, get to it the required validator class and parse the correct keys from there.

This design is more general and also allows for multiple providers needing multiple private keys to co-exist peacefully with each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants