Skip to content

Commit

Permalink
Fix openai streaming (#982)
Browse files Browse the repository at this point in the history
- Fix char form name width
- Fix openai streaming
  • Loading branch information
sceuick authored Jul 21, 2024
1 parent 5301614 commit 038fb9a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
19 changes: 10 additions & 9 deletions srv/adapter/chat-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,16 @@ function getCharLooks(char: AppSchema.Character) {

function tryParse<T = any>(value: string, prev?: string): T | undefined {
try {
if (!prev) {
const parsed = JSON.parse(value)
return parsed
}
const joined = JSON.parse(prev + value)
return joined
} catch (ex) {
return
}
const parsed = JSON.parse(value)
return parsed
} catch (ex) {}

try {
const parsed = JSON.parse(prev + value)
return parsed
} catch (ex) {}

return
}

export const requestFullCompletion: CompletionGenerator = async function* (
Expand Down
1 change: 0 additions & 1 deletion web/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const forms = {
const unsub = forms.sub(callback)

onCleanup(() => {
console.log('cleanedup')
unsub()
})

Expand Down
8 changes: 0 additions & 8 deletions web/pages/Character/CreateCharacterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,6 @@ export const CreateCharacterForm: Component<{
<HelpCircle size={16} /> AI Character Generation
</Button>
<Card>
{/* <TextInput
fieldName="name"
required
label="Character Name"
placeholder=""
value={editor.state.name}
tokenCount={(v) => setTokens((prev) => ({ ...prev, name: v }))}
/> */}
<ButtonInput
fieldName="name"
required
Expand Down
4 changes: 2 additions & 2 deletions web/shared/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Props = {

export const ButtonInput: Component<Props & { children: any }> = (props) => {
return (
<TextInput {...props} parentClass={`${props.parentClass || ''} input-buttons`}>
<TextInput {...props} parentClass={`${props.parentClass || ''} input-buttons w-full`}>
{props.children}
</TextInput>
)
Expand Down Expand Up @@ -254,7 +254,7 @@ const TextInput: Component<Props> = (props) => {
/>
</Match>
<Match when>
<div class="input-buttons">
<div class="input-buttons w-full">
<input
id={props.fieldName}
name={props.fieldName}
Expand Down

0 comments on commit 038fb9a

Please sign in to comment.