Skip to content

Commit

Permalink
Add Claude 2.0 models. Update Claude streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Cohee1207 committed Jul 11, 2023
1 parent 0fc10e8 commit 12908ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1576,12 +1576,14 @@ <h4>Claude API Key</h4>
<h4 data-i18n="Claude Model">Claude Model</h4>
<select id="model_claude_select">
<optgroup label="Latest">
<option value="claude-2">claude-2</option>
<option value="claude-v1">claude-v1</option>
<option value="claude-v1-100k">claude-v1-100k</option>
<option value="claude-instant-v1">claude-instant-v1</option>
<option value="claude-instant-v1-100k">claude-instant-v1-100k</option>
</optgroup>
<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-100k">claude-v1.3-100k</option>
<option value="claude-v1.2">claude-v1.2</option>
Expand Down
9 changes: 8 additions & 1 deletion public/scripts/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,13 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) {
}

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"))
continue;
if (event == "data: [DONE]") {
Expand Down Expand Up @@ -838,7 +845,7 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) {

function getStreamingReply(getMessage, data) {
if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) {
getMessage = data.completion || "";
getMessage += data?.completion || "";
} else {
getMessage += data.choices[0]?.delta?.content || data.choices[0]?.message?.content || data.choices[0]?.text || "";
}
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3174,6 +3174,7 @@ async function sendClaudeRequest(request, response) {
}),
headers: {
"Content-Type": "application/json",
"anthropic-version": '2023-06-01',
"x-api-key": api_key_claude,
},
timeout: 0,
Expand Down

0 comments on commit 12908ba

Please sign in to comment.