refactor: Add Cohere models to ModelList and names.ts
This commit is contained in:
@@ -115,6 +115,10 @@
|
|||||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('novellist')}}>SuperTrin</button>
|
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('novellist')}}>SuperTrin</button>
|
||||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('novellist_damsel')}}>Damsel</button>
|
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('novellist_damsel')}}>Damsel</button>
|
||||||
</Arcodion>
|
</Arcodion>
|
||||||
|
<Arcodion name="Cohere">
|
||||||
|
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('cohere-command-r')}}>Command R</button>
|
||||||
|
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('cohere-command-r-plus')}}>Command R Plus</button>
|
||||||
|
</Arcodion>
|
||||||
<Arcodion name="NovelAI">
|
<Arcodion name="NovelAI">
|
||||||
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('novelai')}}>NovelAI Clio</button>
|
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('novelai')}}>NovelAI Clio</button>
|
||||||
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('novelai_kayra')}}>NovelAI Kayra</button>
|
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('novelai_kayra')}}>NovelAI Kayra</button>
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ export function getModelName(name:string){
|
|||||||
return 'Gemini 1.5 Flash'
|
return 'Gemini 1.5 Flash'
|
||||||
case 'ollama-hosted':
|
case 'ollama-hosted':
|
||||||
return 'Ollama'
|
return 'Ollama'
|
||||||
|
case 'cohere-command-r':
|
||||||
|
return 'Cohere Command-R'
|
||||||
|
case 'cohere-command-r-plus':
|
||||||
|
return 'Cohere Command-R Plus'
|
||||||
default:
|
default:
|
||||||
if(name.startsWith("horde:::")){
|
if(name.startsWith("horde:::")){
|
||||||
const split = name.split(":::")
|
const split = name.split(":::")
|
||||||
@@ -124,6 +128,9 @@ export function getModelShortName(model:string){
|
|||||||
if(model.startsWith("gpt35")){
|
if(model.startsWith("gpt35")){
|
||||||
return "GPT-3.5"
|
return "GPT-3.5"
|
||||||
}
|
}
|
||||||
|
if(model.startsWith("cohere-")){
|
||||||
|
return model.replace("cohere-", "")
|
||||||
|
}
|
||||||
if(model.startsWith("gpt4")){
|
if(model.startsWith("gpt4")){
|
||||||
return "GPT-4"
|
return "GPT-4"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1527,6 +1527,89 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
result: readableStream
|
result: readableStream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 'cohere-command-r':
|
||||||
|
case 'cohere-command-r-plus':{
|
||||||
|
const modelName = aiModel.replace('cohere-', '')
|
||||||
|
let lastChatPrompt = ''
|
||||||
|
let preamble = ''
|
||||||
|
|
||||||
|
const lastChat = formated[formated.length-1]
|
||||||
|
if(lastChat.role === 'user'){
|
||||||
|
lastChatPrompt = lastChat.content
|
||||||
|
formated.pop()
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstChat = formated[0]
|
||||||
|
if(firstChat.role === 'system'){
|
||||||
|
preamble = firstChat.content
|
||||||
|
formated.shift()
|
||||||
|
}
|
||||||
|
|
||||||
|
let body = {
|
||||||
|
message: lastChatPrompt,
|
||||||
|
chat_history: formated.map((v) => {
|
||||||
|
if(v.role === 'assistant'){
|
||||||
|
return {
|
||||||
|
role: 'CHATBOT',
|
||||||
|
content: v.content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(v.role === 'system'){
|
||||||
|
return {
|
||||||
|
role: 'SYSTEM',
|
||||||
|
content: v.content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(v.role === 'user'){
|
||||||
|
return {
|
||||||
|
role: 'USER',
|
||||||
|
content: v.content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}).filter((v) => v !== null),
|
||||||
|
temperature: temperature,
|
||||||
|
k: db.top_k,
|
||||||
|
p: (db.top_p > 0.99) ? 0.99 : (db.top_p < 0.01) ? 0.01 : db.top_p,
|
||||||
|
presence_penalty: arg.PresensePenalty || (db.PresensePenalty / 100),
|
||||||
|
frequency_penalty: arg.frequencyPenalty || (db.frequencyPenalty / 100),
|
||||||
|
}
|
||||||
|
|
||||||
|
if(preamble){
|
||||||
|
// @ts-ignore
|
||||||
|
body.preamble = preamble
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await globalFetch('https://api.cohere.com/v1/chat', {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Authorization": "Bearer " + db.cohereAPIKey,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
|
||||||
|
if(!res.ok){
|
||||||
|
return {
|
||||||
|
type: 'fail',
|
||||||
|
result: JSON.stringify(res.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = res.data.text
|
||||||
|
if(!result){
|
||||||
|
return {
|
||||||
|
type: 'fail',
|
||||||
|
result: JSON.stringify(res.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: 'success',
|
||||||
|
result: result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:{
|
default:{
|
||||||
if(raiModel.startsWith('claude-3')){
|
if(raiModel.startsWith('claude-3')){
|
||||||
let replacerURL = (aiModel === 'reverse_proxy') ? (db.forceReplaceUrl) : ('https://api.anthropic.com/v1/messages')
|
let replacerURL = (aiModel === 'reverse_proxy') ? (db.forceReplaceUrl) : ('https://api.anthropic.com/v1/messages')
|
||||||
|
|||||||
@@ -667,6 +667,7 @@ export interface Database{
|
|||||||
templateDefaultVariables:string
|
templateDefaultVariables:string
|
||||||
hypaAllocatedTokens:number
|
hypaAllocatedTokens:number
|
||||||
hypaChunkSize:number
|
hypaChunkSize:number
|
||||||
|
cohereAPIKey:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface customscript{
|
export interface customscript{
|
||||||
|
|||||||
Reference in New Issue
Block a user