Skip to content

Commit

Permalink
Updates and Improvements (#1069)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
sceuick authored Nov 10, 2024
1 parent fc530b1 commit 5e8466c
Show file tree
Hide file tree
Showing 60 changed files with 1,688 additions and 1,117 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"plugins": [],
"presets": ["solid"],
"env": {
"development": {
"presets": ["babel-preset-solid"]
// "plugins": ["module:solid-refresh/babel"]
}
}
}
5 changes: 4 additions & 1 deletion .github/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const tags = ['<meta inject="">', '<meta inject>', '<meta inject="" />']
const indexFile = path.resolve(__dirname, '../dist/index.html')
const outFile = path.resolve(__dirname, '../dist/index.html')

let content = fs.readFileSync(indexFile).toString().replace('{{unknown}}', process.env.GITHUB_SHA)
let content = fs
.readFileSync(indexFile)
.toString()
.replace('{{unknown}}",', process.env.GITHUB_SHA + '";')

if (inject) {
for (const tag of tags) {
Expand Down
2 changes: 2 additions & 0 deletions common/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ export const samplerDisableValues: { [key in keyof PresetAISettings]?: number }
frequencyPenalty: 0,
presencePenalty: 0,
tailFreeSampling: 1,
xtcThreshold: 0,
dryMultiplier: 0,
}

export function adaptersToOptions(adapters: AIAdapter[]) {
Expand Down
19 changes: 14 additions & 5 deletions common/image-prompt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AppSchema } from './types/schema'
import { tokenize } from './tokenize'
import { BOT_REPLACE, SELF_REPLACE } from './prompt'

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

const prefix = ''
const max = getMaxImageContext(user)
let size = await tokenize(prefix)
let size = prefix.length

const { persona } = avatar

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

for (const visual of value) {
size += await tokenize(visual)
size += visual.length
if (size > max) break
visuals.push(visual)
}
Expand Down Expand Up @@ -71,7 +70,7 @@ export async function createImagePrompt(opts: ImagePromptOpts) {

for (const index of indexes.reverse()) {
const line = msg.slice(index)
const size = await tokenize(line)
const size = line.length
tokens += size

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

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

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

return matches
}

export function fixImagePrompt(prompt: string) {
return prompt
.replace(/ +/g, ' ')
.replace(/,+/g, ',')
.split(',')
.filter((t) => !!t.trim())
.map((t) => t.trim())
.join(', ')
}
21 changes: 11 additions & 10 deletions common/types/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
OpenRouterModel,
RegisteredAdapter,
} from '../adapters'
import { JsonField } from '../prompt'
import { SubscriptionModelOption, SubscriptionTier } from './presets'
import { ThemeColor } from './ui'

Expand Down Expand Up @@ -48,7 +47,16 @@ export type ImageModel = {
desc: string
override: string
level: number
init: { clipSkip?: number; steps: number; cfg: number; height: number; width: number }
init: {
clipSkip?: number
steps: number
cfg: number
height: number
width: number
suffix: string
prefix: string
negative: string
}
limit: { clipSkip?: number; steps: number; cfg: number; height: number; width: number }
}

Expand Down Expand Up @@ -87,6 +95,7 @@ export interface Configuration {
maintenance: boolean

supportEmail: string
stripeCustomerPortal: string

/** Markdown */
maintenanceMessage: string
Expand Down Expand Up @@ -124,14 +133,6 @@ export interface Configuration {
maxGuidanceTokens: number
maxGuidanceVariables: number

modPresetId: string
modPrompt: string
modFieldPrompt: string
modSchema: JsonField[]

charlibPublish: 'off' | 'users' | 'subscribers' | 'moderators' | 'admins'
charlibGuidelines: string

actionCalls: ActionCall[]
}

Expand Down
12 changes: 12 additions & 0 deletions common/types/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,22 @@ export interface GenSettings {

temp: number
tempLast?: boolean

dynatemp_range?: number
dynatemp_exponent?: number

xtcProbability?: number
xtcThreshold?: number

dryMultiplier?: number
dryBase?: number
dryAllowedLength?: number
dryRange?: number
drySequenceBreakers?: string[]

smoothingFactor?: number
smoothingCurve?: number

maxTokens: number
maxContextLength?: number
useMaxContext?: boolean
Expand Down
2 changes: 2 additions & 0 deletions common/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export namespace AppSchema {
texttospeech?: TTSSettings

images?: ImageSettings
useRecommendedImages?: string // 'all' | 'except-(size|affix|negative)' | 'none'

adapterConfig?: { [key in AIAdapter]?: Record<string, any> }

ui?: UISettings
Expand Down
5 changes: 5 additions & 0 deletions common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export function findOne<T extends { _id: string }>(id: string, list: T[]): T | v
}
}

export function round(value: number, places = 2) {
const pow = Math.pow(10, places)
return Math.round(value * pow) / pow
}

export function toArray<T>(values?: T | T[]): T[] {
if (values === undefined) return []
if (Array.isArray(values)) return values
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"agnaistic": "./srv/bin.js",
"agnai": "./srv/bin.js"
},
"browserslist": "> 0.1%, not ie 11",
"homepage": "https://github.com/agnaistic/agnai/issues",
"files": [
"poetry.lock",
Expand Down Expand Up @@ -153,6 +154,7 @@
"assert": "^2.0.0",
"babel-preset-solid": "^1.6.9",
"browserify-zlib": "^0.2.0",
"browserslist": "^4.24.2",
"buffer": "^5.5.0",
"chai": "^4.3.7",
"concurrently": "^7.6.0",
Expand All @@ -162,6 +164,7 @@
"exifreader": "^4.13.0",
"https-browserify": "^1.0.0",
"js-cookie": "^3.0.1",
"jwt-decode": "^4.0.0",
"libsodium-wrappers-sumo": "^0.7.11",
"localforage": "^1.10.0",
"lucide-solid": "0.356.0",
Expand Down
Loading

0 comments on commit 5e8466c

Please sign in to comment.