mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add Claude 2.0 models. Update Claude streaming
This commit is contained in:
@@ -1576,12 +1576,14 @@
|
|||||||
<h4 data-i18n="Claude Model">Claude Model</h4>
|
<h4 data-i18n="Claude Model">Claude Model</h4>
|
||||||
<select id="model_claude_select">
|
<select id="model_claude_select">
|
||||||
<optgroup label="Latest">
|
<optgroup label="Latest">
|
||||||
|
<option value="claude-2">claude-2</option>
|
||||||
<option value="claude-v1">claude-v1</option>
|
<option value="claude-v1">claude-v1</option>
|
||||||
<option value="claude-v1-100k">claude-v1-100k</option>
|
<option value="claude-v1-100k">claude-v1-100k</option>
|
||||||
<option value="claude-instant-v1">claude-instant-v1</option>
|
<option value="claude-instant-v1">claude-instant-v1</option>
|
||||||
<option value="claude-instant-v1-100k">claude-instant-v1-100k</option>
|
<option value="claude-instant-v1-100k">claude-instant-v1-100k</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="Sub-versions">
|
<optgroup label="Sub-versions">
|
||||||
|
<option value="claude-2.0">claude-2.0</option>
|
||||||
<option value="claude-v1.3">claude-v1.3</option>
|
<option value="claude-v1.3">claude-v1.3</option>
|
||||||
<option value="claude-v1.3-100k">claude-v1.3-100k</option>
|
<option value="claude-v1.3-100k">claude-v1.3-100k</option>
|
||||||
<option value="claude-v1.2">claude-v1.2</option>
|
<option value="claude-v1.2">claude-v1.2</option>
|
||||||
|
@@ -805,6 +805,13 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let event of eventList) {
|
for (let event of eventList) {
|
||||||
|
if (event.startsWith('event: completion')) {
|
||||||
|
event = event.split("\n")[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof event !== 'string' || !event.length)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!event.startsWith("data"))
|
if (!event.startsWith("data"))
|
||||||
continue;
|
continue;
|
||||||
if (event == "data: [DONE]") {
|
if (event == "data: [DONE]") {
|
||||||
@@ -838,7 +845,7 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) {
|
|||||||
|
|
||||||
function getStreamingReply(getMessage, data) {
|
function getStreamingReply(getMessage, data) {
|
||||||
if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) {
|
if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) {
|
||||||
getMessage = data.completion || "";
|
getMessage += data?.completion || "";
|
||||||
} else {
|
} else {
|
||||||
getMessage += data.choices[0]?.delta?.content || data.choices[0]?.message?.content || data.choices[0]?.text || "";
|
getMessage += data.choices[0]?.delta?.content || data.choices[0]?.message?.content || data.choices[0]?.text || "";
|
||||||
}
|
}
|
||||||
|
@@ -3174,6 +3174,7 @@ async function sendClaudeRequest(request, response) {
|
|||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"anthropic-version": '2023-06-01',
|
||||||
"x-api-key": api_key_claude,
|
"x-api-key": api_key_claude,
|
||||||
},
|
},
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
Reference in New Issue
Block a user