Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/schemas/bifrost.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ const (
BifrostContextKeyRequestHeaders BifrostContextKey = "bifrost-request-headers" // map[string]string (all request headers with lowercased keys)
BifrostContextKeySkipListModelsGovernanceFiltering BifrostContextKey = "bifrost-skip-list-models-governance-filtering" // bool (set by bifrost - DO NOT SET THIS MANUALLY))
BifrostContextKeySCIMClaims BifrostContextKey = "scim_claims"
BifrostContextKeyUserID BifrostContextKey = "bifrost-user-id" // string (to store the user ID (set by enterprise auth middleware - DO NOT SET THIS MANUALLY))
BifrostContextKeyUserName BifrostContextKey = "bifrost-user-name" // string (to store the user name (set by enterprise auth middleware - DO NOT SET THIS MANUALLY))
BifrostContextKeyUserID BifrostContextKey = "bifrost-user-id" // string (to store the user ID (set by enterprise auth middleware - DO NOT SET THIS MANUALLY))
BifrostContextKeyUserName BifrostContextKey = "bifrost-user-name" // string (to store the user name (set by enterprise auth middleware - DO NOT SET THIS MANUALLY))
BifrostContextKeyTargetUserID BifrostContextKey = "target_user_id"
BifrostContextKeyIsAzureUserAgent BifrostContextKey = "bifrost-is-azure-user-agent" // bool (set by bifrost - DO NOT SET THIS MANUALLY)) - whether the request is an Azure user agent (only used in gateway)
BifrostContextKeyVideoOutputRequested BifrostContextKey = "bifrost-video-output-requested"
Expand Down
1 change: 1 addition & 0 deletions docs/features/async-inference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Streaming is not supported on async endpoints.
| Image generations | `/v1/async/images/generations` | `/v1/async/images/generations/{job_id}` |
| Image edits | `/v1/async/images/edits` | `/v1/async/images/edits/{job_id}` |
| Image variations | `/v1/async/images/variations` | `/v1/async/images/variations/{job_id}` |
| OCR | `/v1/async/ocr` | `/v1/async/ocr/{job_id}` |
| Rerank | `/v1/async/rerank` | `/v1/async/rerank/{job_id}` |

## Submitting a Request
Expand Down
36 changes: 36 additions & 0 deletions framework/logstore/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ func triggerMigrations(ctx context.Context, db *gorm.DB) error {
if err := migrationAddUserNameColumn(ctx, db); err != nil {
return err
}
if err := migrationAddOCRInputColumn(ctx, db); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -2579,3 +2582,36 @@ func migrationAddSelectedPromptColumns(ctx context.Context, db *gorm.DB) error {
}
return nil
}

// migrationAddOCRInputColumn adds the ocr_input column to the logs table.
func migrationAddOCRInputColumn(ctx context.Context, db *gorm.DB) error {
opts := *migrator.DefaultOptions
opts.UseTransaction = true
m := migrator.New(db, &opts, []*migrator.Migration{{
ID: "logs_add_ocr_input_column",
Migrate: func(tx *gorm.DB) error {
tx = tx.WithContext(ctx)
mig := tx.Migrator()
if !mig.HasColumn(&Log{}, "ocr_input") {
if err := mig.AddColumn(&Log{}, "ocr_input"); err != nil {
return err
}
}
return nil
},
Rollback: func(tx *gorm.DB) error {
tx = tx.WithContext(ctx)
mig := tx.Migrator()
if mig.HasColumn(&Log{}, "ocr_input") {
if err := mig.DropColumn(&Log{}, "ocr_input"); err != nil {
return err
}
}
return nil
},
}})
if err := m.Migrate(); err != nil {
return fmt.Errorf("error while adding ocr_input column: %s", err.Error())
}
return nil
}
20 changes: 20 additions & 0 deletions framework/logstore/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var payloadFields = []string{
"responses_output",
"embedding_output",
"rerank_output",
"ocr_input",
"ocr_output",
"params",
"tools",
"tool_calls",
Expand Down Expand Up @@ -58,6 +60,8 @@ func ExtractPayload(l *Log) map[string]string {
m["responses_output"] = l.ResponsesOutput
m["embedding_output"] = l.EmbeddingOutput
m["rerank_output"] = l.RerankOutput
m["ocr_input"] = l.OCRInput
m["ocr_output"] = l.OCROutput
m["params"] = l.Params
m["tools"] = l.Tools
m["tool_calls"] = l.ToolCalls
Expand Down Expand Up @@ -100,6 +104,8 @@ func ClearPayload(l *Log) {
l.ResponsesOutput = ""
l.EmbeddingOutput = ""
l.RerankOutput = ""
l.OCRInput = ""
l.OCROutput = ""
l.Params = ""
l.Tools = ""
l.ToolCalls = ""
Expand Down Expand Up @@ -134,6 +140,8 @@ func ClearPayload(l *Log) {
l.ResponsesOutputParsed = nil
l.EmbeddingOutputParsed = nil
l.RerankOutputParsed = nil
l.OCRInputParsed = nil
l.OCROutputParsed = nil
l.ParamsParsed = nil
l.ToolsParsed = nil
l.ToolCallsParsed = nil
Expand Down Expand Up @@ -183,6 +191,12 @@ func MergePayloadFromJSON(l *Log, data []byte) error {
if v, ok := m["rerank_output"]; ok && v != "" {
l.RerankOutput = v
}
if v, ok := m["ocr_input"]; ok && v != "" {
l.OCRInput = v
}
if v, ok := m["ocr_output"]; ok && v != "" {
l.OCROutput = v
}
if v, ok := m["params"]; ok && v != "" {
l.Params = v
}
Expand Down Expand Up @@ -504,6 +518,12 @@ func clearPayloadField(l *Log, name string) {
case "rerank_output":
l.RerankOutput = ""
l.RerankOutputParsed = nil
case "ocr_input":
l.OCRInput = ""
l.OCRInputParsed = nil
case "ocr_output":
l.OCROutput = ""
l.OCROutputParsed = nil
case "params":
l.Params = ""
l.ParamsParsed = nil
Expand Down
16 changes: 16 additions & 0 deletions framework/logstore/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type Log struct {
ToolCalls string `gorm:"type:text" json:"-"` // JSON serialized []schemas.ToolCall (For backward compatibility, tool calls are now in the content)
SpeechInput string `gorm:"type:text" json:"-"` // JSON serialized *schemas.SpeechInput
TranscriptionInput string `gorm:"type:text" json:"-"` // JSON serialized *schemas.TranscriptionInput
OCRInput string `gorm:"type:text" json:"-"` // JSON serialized *schemas.OCRDocument
ImageGenerationInput string `gorm:"type:text" json:"-"` // JSON serialized *schemas.ImageGenerationInput
ImageEditInput string `gorm:"type:text" json:"-"` // JSON serialized *schemas.ImageEditInput
ImageVariationInput string `gorm:"type:text" json:"-"` // JSON serialized *schemas.ImageVariationInput
Expand Down Expand Up @@ -200,6 +201,7 @@ type Log struct {
ErrorDetailsParsed *schemas.BifrostError `gorm:"-" json:"error_details,omitempty"`
SpeechInputParsed *schemas.SpeechInput `gorm:"-" json:"speech_input,omitempty"`
TranscriptionInputParsed *schemas.TranscriptionInput `gorm:"-" json:"transcription_input,omitempty"`
OCRInputParsed *schemas.OCRDocument `gorm:"-" json:"ocr_input,omitempty"`
ImageGenerationInputParsed *schemas.ImageGenerationInput `gorm:"-" json:"image_generation_input,omitempty"`
ImageEditInputParsed *schemas.ImageEditInput `gorm:"-" json:"image_edit_input,omitempty"`
ImageVariationInputParsed *schemas.ImageVariationInput `gorm:"-" json:"image_variation_input,omitempty"`
Expand Down Expand Up @@ -337,6 +339,14 @@ func (l *Log) SerializeFields() error {
}
}

if l.OCRInputParsed != nil {
if data, err := sonic.Marshal(l.OCRInputParsed); err != nil {
return err
} else {
l.OCRInput = string(data)
}
}
Comment thread
Pratham-Mishra04 marked this conversation as resolved.

if l.ImageGenerationInputParsed != nil {
if data, err := sonic.Marshal(l.ImageGenerationInputParsed); err != nil {
return err
Expand Down Expand Up @@ -676,6 +686,12 @@ func (l *Log) DeserializeFields() error {
}
}

if l.OCRInput != "" {
if err := sonic.Unmarshal([]byte(l.OCRInput), &l.OCRInputParsed); err != nil {
l.OCRInputParsed = nil
}
}

if l.ImageGenerationInput != "" {
if err := sonic.Unmarshal([]byte(l.ImageGenerationInput), &l.ImageGenerationInputParsed); err != nil {
// Log error but don't fail the operation - initialize as nil
Expand Down
2 changes: 2 additions & 0 deletions plugins/logging/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ type InitialLogData struct {
Params any
SpeechInput *schemas.SpeechInput
TranscriptionInput *schemas.TranscriptionInput
OCRInput *schemas.OCRDocument
ImageGenerationInput *schemas.ImageGenerationInput
ImageEditInput *schemas.ImageEditInput
ImageVariationInput *schemas.ImageVariationInput
Expand Down Expand Up @@ -489,6 +490,7 @@ func (p *LoggerPlugin) PreLLMHook(ctx *schemas.BifrostContext, req *schemas.Bifr
initialData.Params = req.RerankRequest.Params
case schemas.OCRRequest:
initialData.Params = req.OCRRequest.Params
initialData.OCRInput = &req.OCRRequest.Document
Comment thread
Pratham-Mishra04 marked this conversation as resolved.
case schemas.SpeechRequest, schemas.SpeechStreamRequest:
Comment thread
Pratham-Mishra04 marked this conversation as resolved.
initialData.Params = req.SpeechRequest.Params
initialData.SpeechInput = req.SpeechRequest.Input
Expand Down
1 change: 1 addition & 0 deletions plugins/logging/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (p *LoggerPlugin) insertInitialLogEntry(
ToolsParsed: data.Tools,
SpeechInputParsed: data.SpeechInput,
TranscriptionInputParsed: data.TranscriptionInput,
OCRInputParsed: data.OCRInput,
ImageGenerationInputParsed: data.ImageGenerationInput,
ImageEditInputParsed: data.ImageEditInput,
ImageVariationInputParsed: data.ImageVariationInput,
Expand Down
23 changes: 0 additions & 23 deletions plugins/logging/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,29 +545,6 @@ func (p *LoggerPlugin) extractInputHistory(request *schemas.BifrostRequest) ([]s
},
}, []schemas.ResponsesMessage{}
}
if request.OCRRequest != nil {
var docRef string
if request.OCRRequest.Document.DocumentURL != nil {
docRef = *request.OCRRequest.Document.DocumentURL
} else if request.OCRRequest.Document.ImageURL != nil {
docRef = *request.OCRRequest.Document.ImageURL
}
// Strip query parameters to avoid logging sensitive tokens (e.g., pre-signed URLs)
if idx := strings.Index(docRef, "?"); idx != -1 {
docRef = docRef[:idx]
}
if docRef == "" {
return []schemas.ChatMessage{}, []schemas.ResponsesMessage{}
}
return []schemas.ChatMessage{
{
Role: schemas.ChatMessageRoleUser,
Content: &schemas.ChatMessageContent{
ContentStr: &docRef,
},
},
}, []schemas.ResponsesMessage{}
}
if request.CountTokensRequest != nil && len(request.CountTokensRequest.Input) > 0 {
return []schemas.ChatMessage{}, request.CountTokensRequest.Input
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/logging/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,11 @@ func buildCompleteLogEntryFromPending(pending *PendingLogData) *logstore.Log {
ToolsParsed: pending.InitialData.Tools,
SpeechInputParsed: pending.InitialData.SpeechInput,
TranscriptionInputParsed: pending.InitialData.TranscriptionInput,
OCRInputParsed: pending.InitialData.OCRInput,
ImageGenerationInputParsed: pending.InitialData.ImageGenerationInput,
ImageEditInputParsed: pending.InitialData.ImageEditInput,
ImageVariationInputParsed: pending.InitialData.ImageVariationInput,
VideoGenerationInputParsed: pending.InitialData.VideoGenerationInput,
PassthroughRequestBody: pending.InitialData.PassthroughRequestBody,
}
if pending.ParentRequestID != "" {
Expand Down
7 changes: 2 additions & 5 deletions transports/bifrost-http/handlers/mcpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ func injectMCPSessionIdentity(bifrostCtx *schemas.BifrostContext, session *table
if session.AccessToken != "" {
bifrostCtx.SetValue(schemas.BifrostContextKeyMCPUserSession, session.AccessToken)
}
if session.VirtualKeyID != nil && *session.VirtualKeyID != "" {
bifrostCtx.SetValue(schemas.BifrostContextKeyGovernanceVirtualKeyID, *session.VirtualKeyID)
if session.VirtualKey != nil && session.VirtualKey.Name != "" {
bifrostCtx.SetValue(schemas.BifrostContextKeyGovernanceVirtualKeyName, session.VirtualKey.Name)
}
if session.VirtualKeyID != nil && *session.VirtualKeyID != "" && session.VirtualKey != nil && session.VirtualKey.Value != "" {
bifrostCtx.SetValue(schemas.BifrostContextKeyVirtualKey, session.VirtualKey.Value)
}
if session.UserID != nil && *session.UserID != "" {
bifrostCtx.SetValue(schemas.BifrostContextKeyUserID, *session.UserID)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { ToolCase } from "lucide-react";
import ContactUsView from "../views/contactUsView";

export default function MCPToolGroups() {
return (
<>
<CardHeader className="mb-4 px-0">
<CardTitle>
<h1 className="text-foreground text-lg font-semibold">MCP tool groups</h1>
</CardTitle>
<CardDescription>Configure tool groups for MCP servers to organize and govern tools.</CardDescription>
</CardHeader>
<div className="flex items-center justify-between gap-4 mb-4">
<div>
<h2 className="text-lg font-semibold tracking-tight">MCP tool groups</h2>
<p className="text-muted-foreground text-sm">Configure tool groups for MCP servers to organize and govern tools.</p>
</div>
</div>
<div className="rounded-sm border">
<div className="flex w-full flex-col items-center justify-center py-16">
<ContactUsView
Expand Down
2 changes: 1 addition & 1 deletion ui/app/workspace/config/mcp-gateway/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import MCPGatewayView from "../views/mcpView";

export default function MCPGatewayPage() {
return (
<div className="mx-auto flex w-full max-w-7xl">
<div className="mx-auto w-full max-w-7xl">
<MCPGatewayView />
</div>
);
Expand Down
16 changes: 8 additions & 8 deletions ui/app/workspace/config/views/mcpView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default function MCPView() {

return (
<div
className="mx-auto w-full max-w-4xl space-y-4"
className="mx-auto w-full max-w-7xl space-y-4"
data-testid="mcp-settings-view"
>
<div>
Expand All @@ -158,7 +158,7 @@ export default function MCPView() {
</div>
<div className="space-y-4">
{/* Max Agent Depth */}
<div className="flex items-center justify-between space-x-2 rounded-lg border p-4">
<div className="flex items-center justify-between space-x-2 rounded-sm border p-4">
<div className="space-y-0.5">
<label htmlFor="mcp-agent-depth" className="text-sm font-medium">
Max Agent Depth
Expand All @@ -179,7 +179,7 @@ export default function MCPView() {
</div>

{/* Tool Execution Timeout */}
<div className="flex items-center justify-between space-x-2 rounded-lg border p-4">
<div className="flex items-center justify-between space-x-2 rounded-sm border p-4">
<div className="space-y-0.5">
<label
htmlFor="mcp-tool-execution-timeout"
Expand All @@ -203,7 +203,7 @@ export default function MCPView() {
</div>

{/* Tool Sync Interval */}
<div className="flex items-center justify-between space-x-2 rounded-lg border p-4">
<div className="flex items-center justify-between space-x-2 rounded-sm border p-4">
<div className="space-y-0.5">
<label
htmlFor="mcp-tool-sync-interval"
Expand All @@ -228,7 +228,7 @@ export default function MCPView() {
</div>

{/* Disable Auto Tool Injection */}
<div className="flex items-center justify-between space-x-2 rounded-lg border p-4">
<div className="flex items-center justify-between space-x-2 rounded-sm border p-4">
<div className="space-y-0.5">
<label
htmlFor="mcp-disable-auto-tool-inject"
Expand All @@ -254,7 +254,7 @@ export default function MCPView() {
</div>

{/* Code Mode Binding Level */}
<div className="space-y-4 rounded-lg border p-4">
<div className="space-y-4 rounded-sm border p-4">
<div className="space-y-0.5">
<label htmlFor="mcp-binding-level" className="text-sm font-medium">
Code Mode Binding Level
Expand Down Expand Up @@ -288,7 +288,7 @@ export default function MCPView() {
</p>

{localValues.mcp_code_mode_binding_level === "server" ? (
<div className="bg-muted border-border rounded-lg border p-4">
<div className="bg-muted border-border rounded-sm border p-4">
<div className="text-foreground space-y-1 font-mono text-xs">
<div>servers/</div>
<div className="pl-3">├─ calculator.py</div>
Expand All @@ -300,7 +300,7 @@ export default function MCPView() {
</p>
</div>
) : (
<div className="bg-muted border-border rounded-lg border p-4">
<div className="bg-muted border-border rounded-sm border p-4">
<div className="text-foreground space-y-1 font-mono text-xs">
<div>servers/</div>
<div className="pl-3">├─ calculator/</div>
Expand Down
Loading
Loading