Andrew commited on
Commit
00549b9
·
1 Parent(s): d0901fb

(refactor) Support custom headers for arch routing

Browse files
Files changed (1) hide show
  1. src/lib/server/router/arch.ts +4 -2
src/lib/server/router/arch.ts CHANGED
@@ -68,8 +68,10 @@ function parseRouteName(text: string): string | undefined {
68
 
69
  export async function archSelectRoute(
70
  messages: EndpointMessage[],
71
- traceId?: string
72
  ): Promise<{ routeName: string }> {
 
 
73
  const routes = await getRoutes();
74
  const prompt = toRouterPrompt(messages, routes);
75
 
@@ -82,7 +84,7 @@ export async function archSelectRoute(
82
  }
83
 
84
  const headers: HeadersInit = {
85
- Authorization: `Bearer ${config.OPENAI_API_KEY || config.HF_TOKEN}`,
86
  "Content-Type": "application/json",
87
  };
88
  const body = {
 
68
 
69
  export async function archSelectRoute(
70
  messages: EndpointMessage[],
71
+ options?: { traceId?: string; apiKey?: string }
72
  ): Promise<{ routeName: string }> {
73
+ const traceId = options?.traceId;
74
+ const apiKeyOverride = options?.apiKey;
75
  const routes = await getRoutes();
76
  const prompt = toRouterPrompt(messages, routes);
77
 
 
84
  }
85
 
86
  const headers: HeadersInit = {
87
+ Authorization: `Bearer ${apiKeyOverride ?? (config.OPENAI_API_KEY || config.HF_TOKEN || "")}`,
88
  "Content-Type": "application/json",
89
  };
90
  const body = {