Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
5dff4744
Commit
5dff4744
authored
Nov 11, 2023
by
Timothy J. Baek
Browse files
feat: improved chat history openai support
parent
b6f41a17
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
src/routes/+page.svelte
src/routes/+page.svelte
+17
-3
No files found.
src/routes/+page.svelte
View file @
5dff4744
...
...
@@ -479,6 +479,7 @@
history
.
messages
[
userMessageId
]
=
userMessage
;
history
.
currentId
=
userMessageId
;
await
tick
();
await
sendPrompt
(
userPrompt
,
userMessageId
);
};
...
...
@@ -809,15 +810,28 @@
}
};
const
sendPromptOpenAI
=
async
(
userPrompt
)
=>
{
const
sendPromptOpenAI
=
async
(
userPrompt
,
parentId
)
=>
{
if
(
settings
.
OPENAI_API_KEY
)
{
if
(
models
)
{
let
responseMessageId
=
uuidv4
();
let
responseMessage
=
{
parentId
:
parentId
,
id
:
responseMessageId
,
childrenIds
:
[],
role
:
'
assistant
'
,
content
:
''
};
messages
=
[...
messages
,
responseMessage
];
history
.
messages
[
responseMessageId
]
=
responseMessage
;
history
.
currentId
=
responseMessageId
;
if
(
parentId
!==
null
)
{
history
.
messages
[
parentId
].
childrenIds
=
[
...
history
.
messages
[
parentId
].
childrenIds
,
responseMessageId
];
}
window
.
scrollTo
({
top
:
document
.
body
.
scrollHeight
});
const
res
=
await
fetch
(
`https://api.openai.com/v1/chat/completions`
,
{
...
...
@@ -839,7 +853,7 @@
...
messages
]
.
filter
((
message
)
=>
message
)
.
map
((
message
)
=>
({
...
message
,
d
on
e
:
undefined
})),
.
map
((
message
)
=>
({
role
:
message
.
role
,
c
on
tent
:
message
.
content
})),
temperature
:
settings
.
temperature
??
undefined
,
top_p
:
settings
.
top_p
??
undefined
,
frequency_penalty
:
settings
.
repeat_penalty
??
undefined
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment