From 6aee749ade4d13ffdccdd2e7e191ff09fd407785 Mon Sep 17 00:00:00 2001 From: Phil Date: Tue, 28 May 2024 09:27:13 +0200 Subject: [PATCH] feat: add OpenRouter service template (#581) --- .../CustomServiceChatCompletionTemplate.kt | 16 ++++++++++++++++ .../custom/template/CustomServiceTemplate.kt | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceChatCompletionTemplate.kt b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceChatCompletionTemplate.kt index 8e873571..43db6d54 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceChatCompletionTemplate.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceChatCompletionTemplate.kt @@ -99,6 +99,22 @@ enum class CustomServiceChatCompletionTemplate( "max_tokens" to 1024 ) ) + ), + OPEN_ROUTER( + "https://openrouter.ai/api/v1/chat/completions", + getDefaultHeaders( + mapOf( + "Authorization" to "Bearer \$CUSTOM_SERVICE_API_KEY", + "HTTP-Referer" to "https://plugins.jetbrains.com/plugin/21056-codegpt", + "X-Title" to "CodeGPT" + ) + ), + getDefaultBodyParams( + mapOf( + "model" to "meta-llama/llama-3-8b-instruct:free", + "max_tokens" to 1024 + ) + ) ); } diff --git a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceTemplate.kt b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceTemplate.kt index e80c8121..d1dc0b86 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceTemplate.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/template/CustomServiceTemplate.kt @@ -66,6 +66,11 @@ enum class CustomServiceTemplate( "Mistral AI", "https://docs.mistral.ai/getting-started/quickstart", CustomServiceChatCompletionTemplate.MISTRAL_AI + ), + OPEN_ROUTER( + "OpenRouter", + "https://openrouter.ai/docs#quick-start", + CustomServiceChatCompletionTemplate.OPEN_ROUTER ); override fun toString(): String {