github-actions[bot]
Update from GitHub Actions
b68afdb
import{d as o,u as t,g as e,a as r,b as n}from"../../nitro/nitro.mjs";import{g as i,c as s}from"../../_/storage.mjs";import{l as a}from"../../_/index.mjs";import"node:http";import"node:https";import"node:events";import"node:buffer";import"node:fs";import"node:path";import"node:crypto";import"node:url";import"uuid";import"eventsource-parser/stream";import"eventsource-parser";import"http2";import"form-data";import"ws";import"jose";import"child_process";import"protobufjs";import"@grpc/grpc-js";let p;const d=o((async o=>{if("OPTIONS"===o.method)return new Response(null,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"*","Access-Control-Allow-Headers":"*","Access-Control-Allow-Credentials":"true"}});const d=t().models,l=e(o).pathname,c=r(o),m=n(o);if(void 0===p||"true"===m.reload_config){console.log("load config...");const o=i();p=await o.getItem("backup")}for(const t of d){const e=t.route,r=t.provider;if(l.startsWith(e)&&(l.length==e.length||"/"==l[e.length])){if(!a.hasOwnProperty(r))continue;o.context.model=t;const e=n(o);let i=e.model,d=e.conversation;const l={};if(c.authorization&&c.authorization.startsWith("Bearer ")&&c.authorization.includes("oa_")){decrypt(c.authorization.replace(/^Bearer /,"").replace("oa_","")).split("&").forEach((o=>{const[t,e]=o.split("=");l[t]=e})),i=l.model,d=l.conversation}const m=p.model.models.find((o=>o.id===i)),u=s.conversation.list.find((o=>o.id===d)).models.find((o=>o.modelId===i));console.log(l,m,u),o.context.meta={query:l,apiKey:m.apiKey,apiModel:m.apiModel,apiAgentId:u.apiAgentId,apiConversationId:u.apiConversationId};return await a[r](o)}}return new Response("No Route Handler",{status:404})}));function decrypt(o){const t=o.split("").map((o=>{const t=o.charCodeAt(0);return String.fromCharCode(t-1)})).join("");return Buffer.from(t,"base64").toString()}export{d as default};