Skip to content

Commit 5e8466c

Browse files
authored
Updates and Improvements (#1069)
- Token probabilities - Fix LTM toggle - Image settings: config ui, user ui, add and auto-use recommended settings - Chat graphs: msg previews and labels - Fix json schema field updates - XTC and DRY samplers - Fix prompt template display
1 parent fc530b1 commit 5e8466c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1688
-1117
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2+
"plugins": [],
23
"presets": ["solid"],
34
"env": {
45
"development": {
56
"presets": ["babel-preset-solid"]
6-
// "plugins": ["module:solid-refresh/babel"]
77
}
88
}
99
}

.github/inject.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const tags = ['<meta inject="">', '<meta inject>', '<meta inject="" />']
88
const indexFile = path.resolve(__dirname, '../dist/index.html')
99
const outFile = path.resolve(__dirname, '../dist/index.html')
1010

11-
let content = fs.readFileSync(indexFile).toString().replace('{{unknown}}', process.env.GITHUB_SHA)
11+
let content = fs
12+
.readFileSync(indexFile)
13+
.toString()
14+
.replace('{{unknown}}",', process.env.GITHUB_SHA + '";')
1215

1316
if (inject) {
1417
for (const tag of tags) {

common/adapters.ts

+2
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ export const samplerDisableValues: { [key in keyof PresetAISettings]?: number }
438438
frequencyPenalty: 0,
439439
presencePenalty: 0,
440440
tailFreeSampling: 1,
441+
xtcThreshold: 0,
442+
dryMultiplier: 0,
441443
}
442444

443445
export function adaptersToOptions(adapters: AIAdapter[]) {

common/image-prompt.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AppSchema } from './types/schema'
2-
import { tokenize } from './tokenize'
32
import { BOT_REPLACE, SELF_REPLACE } from './prompt'
43

54
export type ImagePromptOpts = {
@@ -21,7 +20,7 @@ export async function createAppearancePrompt(
2120

2221
const prefix = ''
2322
const max = getMaxImageContext(user)
24-
let size = await tokenize(prefix)
23+
let size = prefix.length
2524

2625
const { persona } = avatar
2726

@@ -37,7 +36,7 @@ export async function createAppearancePrompt(
3736
if (!value) continue
3837

3938
for (const visual of value) {
40-
size += await tokenize(visual)
39+
size += visual.length
4140
if (size > max) break
4241
visuals.push(visual)
4342
}
@@ -71,7 +70,7 @@ export async function createImagePrompt(opts: ImagePromptOpts) {
7170

7271
for (const index of indexes.reverse()) {
7372
const line = msg.slice(index)
74-
const size = await tokenize(line)
73+
const size = line.length
7574
tokens += size
7675

7776
if (tokens > maxTokens) {
@@ -85,7 +84,7 @@ export async function createImagePrompt(opts: ImagePromptOpts) {
8584
if (tokens > maxTokens) break
8685

8786
const handle = userId ? opts.members.find((pr) => pr.userId === userId)?.handle : opts.char.name
88-
tokens += await tokenize(handle + ':')
87+
tokens += (handle || '').length
8988

9089
if (tokens > maxTokens) {
9190
lines.push(last.trim())
@@ -135,3 +134,13 @@ function tokenizeMessage(line: string) {
135134

136135
return matches
137136
}
137+
138+
export function fixImagePrompt(prompt: string) {
139+
return prompt
140+
.replace(/ +/g, ' ')
141+
.replace(/,+/g, ',')
142+
.split(',')
143+
.filter((t) => !!t.trim())
144+
.map((t) => t.trim())
145+
.join(', ')
146+
}

common/types/admin.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
OpenRouterModel,
66
RegisteredAdapter,
77
} from '../adapters'
8-
import { JsonField } from '../prompt'
98
import { SubscriptionModelOption, SubscriptionTier } from './presets'
109
import { ThemeColor } from './ui'
1110

@@ -48,7 +47,16 @@ export type ImageModel = {
4847
desc: string
4948
override: string
5049
level: number
51-
init: { clipSkip?: number; steps: number; cfg: number; height: number; width: number }
50+
init: {
51+
clipSkip?: number
52+
steps: number
53+
cfg: number
54+
height: number
55+
width: number
56+
suffix: string
57+
prefix: string
58+
negative: string
59+
}
5260
limit: { clipSkip?: number; steps: number; cfg: number; height: number; width: number }
5361
}
5462

@@ -87,6 +95,7 @@ export interface Configuration {
8795
maintenance: boolean
8896

8997
supportEmail: string
98+
stripeCustomerPortal: string
9099

91100
/** Markdown */
92101
maintenanceMessage: string
@@ -124,14 +133,6 @@ export interface Configuration {
124133
maxGuidanceTokens: number
125134
maxGuidanceVariables: number
126135

127-
modPresetId: string
128-
modPrompt: string
129-
modFieldPrompt: string
130-
modSchema: JsonField[]
131-
132-
charlibPublish: 'off' | 'users' | 'subscribers' | 'moderators' | 'admins'
133-
charlibGuidelines: string
134-
135136
actionCalls: ActionCall[]
136137
}
137138

common/types/presets.ts

+12
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,22 @@ export interface GenSettings {
8282

8383
temp: number
8484
tempLast?: boolean
85+
8586
dynatemp_range?: number
8687
dynatemp_exponent?: number
88+
89+
xtcProbability?: number
90+
xtcThreshold?: number
91+
92+
dryMultiplier?: number
93+
dryBase?: number
94+
dryAllowedLength?: number
95+
dryRange?: number
96+
drySequenceBreakers?: string[]
97+
8798
smoothingFactor?: number
8899
smoothingCurve?: number
100+
89101
maxTokens: number
90102
maxContextLength?: number
91103
useMaxContext?: boolean

common/types/schema.ts

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ export namespace AppSchema {
146146
texttospeech?: TTSSettings
147147

148148
images?: ImageSettings
149+
useRecommendedImages?: string // 'all' | 'except-(size|affix|negative)' | 'none'
150+
149151
adapterConfig?: { [key in AIAdapter]?: Record<string, any> }
150152

151153
ui?: UISettings

common/util.ts

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export function findOne<T extends { _id: string }>(id: string, list: T[]): T | v
1818
}
1919
}
2020

21+
export function round(value: number, places = 2) {
22+
const pow = Math.pow(10, places)
23+
return Math.round(value * pow) / pow
24+
}
25+
2126
export function toArray<T>(values?: T | T[]): T[] {
2227
if (values === undefined) return []
2328
if (Array.isArray(values)) return values

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"agnaistic": "./srv/bin.js",
99
"agnai": "./srv/bin.js"
1010
},
11+
"browserslist": "> 0.1%, not ie 11",
1112
"homepage": "https://github.com/agnaistic/agnai/issues",
1213
"files": [
1314
"poetry.lock",
@@ -153,6 +154,7 @@
153154
"assert": "^2.0.0",
154155
"babel-preset-solid": "^1.6.9",
155156
"browserify-zlib": "^0.2.0",
157+
"browserslist": "^4.24.2",
156158
"buffer": "^5.5.0",
157159
"chai": "^4.3.7",
158160
"concurrently": "^7.6.0",
@@ -162,6 +164,7 @@
162164
"exifreader": "^4.13.0",
163165
"https-browserify": "^1.0.0",
164166
"js-cookie": "^3.0.1",
167+
"jwt-decode": "^4.0.0",
165168
"libsodium-wrappers-sumo": "^0.7.11",
166169
"localforage": "^1.10.0",
167170
"lucide-solid": "0.356.0",

0 commit comments

Comments
 (0)