Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Caojiahao-Coder committed Feb 24, 2024
2 parents ebac3bc + a5e74bc commit 59e18e2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
44 changes: 38 additions & 6 deletions src/components/GroqSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,44 @@ function onSaveOpenAIConfig() {
open.value = false
}
}
const copyApiKeySuccess = ref<boolean>(false)
const copyApiKeyFailed = ref<boolean>(false)
/**
* 复制OpenAI Api Key
*/
function copyOpenAiKey() {
if (copyApiKeySuccess.value === true || copyApiKeyFailed.value === true)
return
if (!groqApiKey.value) {
copyApiKeyFailed.value = true
setTimeout(() => copyApiKeyFailed.value = false, 1200)
return
}
navigator.clipboard.writeText(groqApiKey.value ?? '').then(() => {
copyApiKeySuccess.value = true
setTimeout(() => {
copyApiKeySuccess.value = false
}, 1200)
}).catch(() => {
copyApiKeyFailed.value = true
setTimeout(() => copyApiKeyFailed.value = false, 1200)
})
}
</script>

<template>
<div class="border-base" b="0 b-1 solid">
<div class="text-18px font-700 h-36px" p="t-16px l-16px r-16px">
<div class="text-18px font-700 " p="t-16px l-16px r-16px">
<div class="flex flex-row gap-2">
<div class="h-24px flex-1 line-height-24px text-18px">
Groq
</div>

<div data-cursor="block" class="icon-button i-carbon-edit" @click="() => open = true" />
</div>
<div class="color-red-3 text-3 m-t-1">
{{ t('use_groq_api.cors') }}
</div>
</div>

<div class="p-16px">
Expand All @@ -67,8 +90,17 @@ function onSaveOpenAIConfig() {
{{ t('api_key') }}
</div>

<div class="text-4 m-t-2" :class="groqApiKey.length <= 0 ? 'color-fade' : 'color-base'">
{{ groqApiKey ? `${groqApiKey.substring(0, 6)}****${groqApiKey.substring(groqApiKey.length - 6, groqApiKey.length)}` : 'undefined' }}
<div class="flex flex-row gap-2 m-t-2">
<div class="text-4" :class="groqApiKey ? 'color-base' : 'color-fade'">
{{
groqApiKey ? `${groqApiKey.substring(0, 6)}****${groqApiKey.substring(groqApiKey.length - 6, groqApiKey.length)}` : 'undefined'
}}
</div>
<div
data-cursor="block" class="icon-button text-4 h-20px line-height-20px" :class="[
copyApiKeySuccess ? 'i-carbon-checkmark color-green' : copyApiKeyFailed ? 'i-carbon-close color-red' : 'i-carbon-copy',
]" @click="copyOpenAiKey"
/>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/groq/logic/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class GroqServices {
body: JSON.stringify({
top_p: topP.value,
temperature: temperature.value,
max_tokens: 32768,
stream: true,
model: groqModel.value,
messages: message,
Expand Down

0 comments on commit 59e18e2

Please sign in to comment.