Skip to content

Commit

Permalink
add support for mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
hbsgithub committed Apr 12, 2023
1 parent 92e5537 commit f13a885
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { serve } from "https://deno.land/std@0.181.0/http/server.ts";

// The name of your Azure OpenAI Resource.
const resourceName:string = "your-resource-name";

// The deployment name you chose when you deployed the model.
// const deployName:string = "deployment-name";

// The version of OpenAI API.
const apiVersion:string = "2023-03-15-preview";
// 自定义 mapper 来映射 model 字段
// The mapping of model name.
const mapper:any = {
'gpt-3.5-turbo': 'gpt35'
// 其他映射规则可以在这里添加
'gpt-3.5-turbo': 'gpt35',
'gpt-4': 'gpt4'
// Other mapping rules can be added here.
};

async function handleRequest(request:Request):Promise<Response> {
Expand All @@ -31,7 +29,7 @@ async function handleRequest(request:Request):Promise<Response> {
}


// 获取 model 字段的值,并进行映射
// Get the value of the model field and perform mapping.
let deployName:string = '';
let body:any;
if (request.method === 'POST') {
Expand Down

0 comments on commit f13a885

Please sign in to comment.