diff --git a/src/lib/UI/ModelList.svelte b/src/lib/UI/ModelList.svelte
index 56a5bc8c..f763b94a 100644
--- a/src/lib/UI/ModelList.svelte
+++ b/src/lib/UI/ModelList.svelte
@@ -115,6 +115,10 @@
+
+
+
+
diff --git a/src/ts/model/names.ts b/src/ts/model/names.ts
index b0b46a84..b7504e8b 100644
--- a/src/ts/model/names.ts
+++ b/src/ts/model/names.ts
@@ -103,6 +103,10 @@ export function getModelName(name:string){
return 'Gemini 1.5 Flash'
case 'ollama-hosted':
return 'Ollama'
+ case 'cohere-command-r':
+ return 'Cohere Command-R'
+ case 'cohere-command-r-plus':
+ return 'Cohere Command-R Plus'
default:
if(name.startsWith("horde:::")){
const split = name.split(":::")
@@ -124,6 +128,9 @@ export function getModelShortName(model:string){
if(model.startsWith("gpt35")){
return "GPT-3.5"
}
+ if(model.startsWith("cohere-")){
+ return model.replace("cohere-", "")
+ }
if(model.startsWith("gpt4")){
return "GPT-4"
}
diff --git a/src/ts/process/request.ts b/src/ts/process/request.ts
index 8140f117..d7d158f8 100644
--- a/src/ts/process/request.ts
+++ b/src/ts/process/request.ts
@@ -1527,6 +1527,89 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
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:{
if(raiModel.startsWith('claude-3')){
let replacerURL = (aiModel === 'reverse_proxy') ? (db.forceReplaceUrl) : ('https://api.anthropic.com/v1/messages')
diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts
index 10eb1631..8109ad3f 100644
--- a/src/ts/storage/database.ts
+++ b/src/ts/storage/database.ts
@@ -667,6 +667,7 @@ export interface Database{
templateDefaultVariables:string
hypaAllocatedTokens:number
hypaChunkSize:number
+ cohereAPIKey:string
}
export interface customscript{