Dashboard Passthrough View

View for the Dashboard prompt passthrough endpoint.

This module provides an authenticated Django view that renders a React-based page accepting raw JSON dictionaries formatted for LLM provider APIs. The frontend submits these payloads directly to the LLM provider via the Smarter prompt passthrough API, and the API response is rendered back in the template.

The view resolves the correct API and provider-listing URLs at request time and injects them—along with CSRF and session cookie configuration—into the React component context.

Classes:
PromptPassthroughView: Renders the prompt passthrough React page for

authenticated users.

Example

Wire up the view in your URL configuration:

from smarter.apps.dashboard.views.passthrough.view import PromptPassthroughView

urlpatterns = [
    path("passthrough/", PromptPassthroughView.as_view(), name="prompt_passthrough"),
]
class smarter.apps.dashboard.views.passthrough.view.PromptPassthroughView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Renders a passthrough template for the prompt app that accepts a raw JSON dict for an LLM provider, passes this directly to the LLM provider API, and renders the API response in the template.

Parameters:
  • request (ASGIRequest) – Django HTTP request object.

  • args (tuple) – Additional positional arguments.

  • kwargs (dict) – Keyword arguments, must include ‘name’ (chatbot name) and ‘kind’ (chatbot type).

Returns:

Rendered HTML page with chatbot manifest details, or a 404 error page if the chatbot is not found or parameters are invalid.

Return type:

HttpResponse

Example usage:

GET /dashboard/passthrough/
get(request, *args, **kwargs)[source]

Render the prompt passthrough page for the authenticated user.

Resolves the LLM provider passthrough API URL and the provider-listing API URL at request time, builds a context dictionary for the React frontend, and renders react/prompt-passthrough.html.

The passthrough API URL is derived by stripping the provider-name placeholder segment from the fully-qualified URL so that the React component can append any provider name dynamically.

Parameters:
  • request (HttpRequest) – The incoming HTTP GET request from the client.

  • args – Additional positional arguments forwarded by the URL dispatcher.

  • kwargs – Additional keyword arguments forwarded by the URL dispatcher.

Returns:

An HTTP 200 response rendering react/prompt-passthrough.html with the passthrough context dictionary.

Return type:

HttpResponse

template_path: str = 'prompt/passthrough.html'