Skip to content

Commit add8f58

Browse files
authored
Fix mancer (#1086)
* - rapidapi attempt - fix mancer * fix append image gen
1 parent 5cd2ae0 commit add8f58

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

srv/adapter/mancer.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type MancerModel = {
2828
const modelOptions = Object.entries(mancerOptions).map(([label, value]) => ({ label, value }))
2929

3030
export const handleMancer: ModelAdapter = async function* (opts) {
31+
const { gen } = opts
3132
const url = 'https://neuro.mancer.tech/oai/v1/completions'
3233

3334
const userModel: string = opts.gen.registered?.mancer?.url || opts.user.adapterConfig?.mancer?.url
@@ -36,28 +37,36 @@ export const handleMancer: ModelAdapter = async function* (opts) {
3637
const body: any = {
3738
prompt: opts.prompt,
3839
model,
39-
add_bos_token: opts.gen.addBosToken ?? false,
40-
ban_eos_token: opts.gen.banEosToken ?? false,
41-
do_sample: true,
40+
ignore_eos: !opts.gen.banEosToken,
4241
max_new_tokens: opts.gen.maxTokens,
4342
temperature: opts.gen.temp!,
4443
top_a: opts.gen.topA,
4544
top_k: opts.gen.topK,
4645
top_p: opts.gen.topP,
46+
min_p: gen.minP,
4747
length_penalty: 1,
48-
truncation_length: opts.gen.maxContextLength,
48+
max_tokens: opts.gen.maxContextLength,
4949
typical_p: opts.gen.typicalP,
50-
encoder_repetition_penalty: opts.gen.encoderRepitionPenalty,
5150
repetition_penalty: opts.gen.repetitionPenalty,
52-
repetition_penalty_range: opts.gen.repetitionPenaltyRange,
53-
skip_special_tokens: true,
51+
presence_penalty: opts.gen.presencePenalty,
52+
frequency_penalty: opts.gen.frequencyPenalty,
5453
tfs: opts.gen.tailFreeSampling,
55-
penalty_alpha: opts.gen.penaltyAlpha,
56-
num_beams: 1,
5754
seed: -1,
5855
stop: getStoppingStrings(opts),
56+
smoothing_factor: gen.smoothingFactor,
57+
smoothing_curve: gen.smoothingCurve,
5958
stream: opts.gen.streamResponse,
6059
}
60+
if (gen.dynatemp_range) {
61+
if (gen.dynatemp_range >= gen.temp!) {
62+
gen.dynatemp_range = gen.temp! - 0.1
63+
}
64+
65+
body.dynatemp_min = (gen.temp ?? 1) - (gen.dynatemp_range ?? 0)
66+
body.dynatemp_max = (gen.temp ?? 1) + (gen.dynatemp_range ?? 0)
67+
body.dynatemp_exponent = gen.dynatemp_exponent
68+
body.dynatemp_mode = 1
69+
}
6170

6271
if (!model) {
6372
yield { error: 'Mancer request failed: Select a model and try again' }

srv/adapter/openai.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,24 @@ export const handleOAI: ModelAdapter = async function* (opts) {
7272
const useThirdPartyPassword =
7373
base.changed && isThirdParty && (gen.thirdPartyKey || user.thirdPartyPassword)
7474

75-
const apiKey = useThirdPartyPassword
75+
let apiKey = useThirdPartyPassword
7676
? gen.thirdPartyKey || user.thirdPartyPassword
7777
: !isThirdParty
7878
? user.oaiKey
7979
: null
80-
const bearer = !!guest ? `Bearer ${apiKey}` : apiKey ? `Bearer ${decryptText(apiKey)}` : null
80+
81+
if (!guest && apiKey) {
82+
apiKey = decryptText(apiKey)
83+
}
84+
const bearer = !!apiKey ? `Bearer ${apiKey}` : null
8185

8286
const headers: any = {
8387
'Content-Type': 'application/json',
8488
}
8589

86-
if (bearer) {
90+
if (apiKey) {
8791
headers.Authorization = bearer
92+
headers['X-RapidAPI-Key'] = apiKey
8893
}
8994

9095
log.debug(body, 'OpenAI payload')

web/store/message.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ export const msgStore = createStore<MsgState>(
711711
}
712712

713713
const prev = messageId ? msgs.find((msg) => msg._id === messageId) : undefined
714-
const parent = messageId ? graph.tree[messageId].msg.parent : msgs.slice(-1)[0]._id
714+
const parent = prev ? prev.parent : msgs.slice(-1)[0]._id
715715

716716
const res = await imageApi.generateImage({
717717
messageId,

0 commit comments

Comments
 (0)