scale cookie method

This commit is contained in:
based
2023-08-20 20:55:37 +10:00
parent 7528a3828a
commit 7ecc0295dc
5 changed files with 170 additions and 16 deletions

View File

@ -3231,6 +3231,75 @@ async function sendScaleRequest(request, response) {
}
}
app.post("/generate_altscale", jsonParser, function (request, response_generate_scale) {
if(!request.body) return response_generate_scale.sendStatus(400);
fetch('https://dashboard.scale.com/spellbook/api/trpc/v2.variant.run', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'cookie': `_jwt=${readSecret(SECRET_KEYS.SCALE_COOKIE)}`,
},
body: JSON.stringify({
json: {
variant: {
name: 'New Variant',
appId: '',
taxonomy: null
},
prompt: {
id: '',
template: '{{input}}\n',
exampleVariables: {},
variablesSourceDataId: null,
systemMessage: request.body.sysprompt
},
modelParameters: {
id: '',
modelId: 'GPT4',
modelType: 'OpenAi',
maxTokens: request.body.max_tokens,
temperature: request.body.temp,
stop: null,
suffix: null,
topP: null,
logprobs: null,
logitBias: null
},
inputs: [
{
index: '-1',
valueByName: {
input: request.body.prompt
}
}
]
},
meta: {
values: {
'variant.taxonomy': ['undefined'],
'prompt.variablesSourceDataId': ['undefined'],
'modelParameters.stop': ['undefined'],
'modelParameters.suffix': ['undefined'],
'modelParameters.topP': ['undefined'],
'modelParameters.logprobs': ['undefined'],
'modelParameters.logitBias': ['undefined']
}
}
})
})
.then(response => response.json())
.then(data => {
console.log(data.result.data.json.outputs[0])
return response_generate_scale.send({output: data.result.data.json.outputs[0]});
})
.catch((error) => {
console.error('Error:', error)
return response_generate_scale.send({error: true})
});
});
async function sendClaudeRequest(request, response) {
const fetch = require('node-fetch').default;
@ -3917,7 +3986,8 @@ const SECRET_KEYS = {
DEEPL: 'deepl',
OPENROUTER: 'api_key_openrouter',
SCALE: 'api_key_scale',
AI21: 'api_key_ai21'
AI21: 'api_key_ai21',
SCALE_COOKIE: 'scale_cookie',
}
function migrateSecrets() {