mirror of
https://github.com/coaidev/coai.git
synced 2025-05-30 02:10:25 +09:00
feat: provide username
param in buy link (#132) and fix anthropic message format error
This commit is contained in:
parent
642fc46afd
commit
f0b46294bf
@ -54,7 +54,29 @@ func (c *ChatInstance) GetTokens(props *adaptercommon.ChatProps) int {
|
||||
}
|
||||
|
||||
func (c *ChatInstance) GetMessages(props *adaptercommon.ChatProps) []Message {
|
||||
start := false
|
||||
|
||||
return utils.Each(props.Message, func(message globals.Message) Message {
|
||||
// anthropic api: top message must be user message, system message is not allowed
|
||||
if !start {
|
||||
start = true
|
||||
// set first message to user message
|
||||
if message.Role != globals.User {
|
||||
return Message{
|
||||
Role: globals.User,
|
||||
Content: message.Content,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if message.Role == globals.System {
|
||||
// set system message to user message
|
||||
return Message{
|
||||
Role: message.Role,
|
||||
Content: message.Content,
|
||||
}
|
||||
}
|
||||
|
||||
if !globals.IsVisionModel(props.Model) || message.Role != globals.User {
|
||||
return Message{
|
||||
Role: message.Role,
|
||||
|
@ -37,7 +37,7 @@ import { AlertDialogTitle } from "@radix-ui/react-alert-dialog";
|
||||
import { buyQuota } from "@/api/addition.ts";
|
||||
import { useToast } from "@/components/ui/use-toast.ts";
|
||||
import { useEffectAsync } from "@/utils/hook.ts";
|
||||
import { selectAuthenticated } from "@/store/auth.ts";
|
||||
import { selectAuthenticated, selectUsername } from "@/store/auth.ts";
|
||||
import { ToastAction } from "@/components/ui/toast.tsx";
|
||||
import {
|
||||
buyLink,
|
||||
@ -88,6 +88,7 @@ function QuotaDialog() {
|
||||
const [amount, setAmount] = useState(10);
|
||||
const open = useSelector(dialogSelector);
|
||||
const auth = useSelector(selectAuthenticated);
|
||||
const username = useSelector(selectUsername);
|
||||
|
||||
const sub = useSelector(subDialogSelector);
|
||||
const subscriptionData = useSelector(subscriptionDataSelector);
|
||||
@ -241,8 +242,13 @@ function QuotaDialog() {
|
||||
<AlertDialogAction
|
||||
onClick={async () => {
|
||||
if (!useDeeptrain) {
|
||||
if (buyLink.trim().length === 0)
|
||||
return toast({
|
||||
title: t("buy.not-config-link"),
|
||||
});
|
||||
|
||||
openWindow(
|
||||
`${buyLink}?quota=${amount}`,
|
||||
`${buyLink}?quota=${amount}&username=${username}`,
|
||||
"_blank",
|
||||
);
|
||||
return;
|
||||
|
@ -176,6 +176,7 @@
|
||||
},
|
||||
"quota-description": "消息的点数支出",
|
||||
"buy": {
|
||||
"not-config-link": "后台未配置购买链接",
|
||||
"choose": "选择一个金额",
|
||||
"other": "其他",
|
||||
"other-desc": "多少点数?",
|
||||
|
@ -146,7 +146,8 @@
|
||||
"exchange-failed": "Failed",
|
||||
"exchange-failed-prompt": "Redemption failed for {{reason}}",
|
||||
"buy-link": "Go to the deal",
|
||||
"deeptrain-tip": "Tip: Once Deeptrain has reloaded to your wallet, come back here and click to buy the appropriate credits"
|
||||
"deeptrain-tip": "Tip: Once Deeptrain has reloaded to your wallet, come back here and click to buy the appropriate credits",
|
||||
"not-config-link": "Purchase link is not configured in the background"
|
||||
},
|
||||
"pkg": {
|
||||
"title": "Packages",
|
||||
|
@ -146,7 +146,8 @@
|
||||
"exchange-failed": "引き換えに失敗しました",
|
||||
"exchange-failed-prompt": "{{reason}}のため、引き換えに失敗しました",
|
||||
"buy-link": "購入しに行く",
|
||||
"deeptrain-tip": "ヒント: Deeptrainがウォレットにリロードされたら、ここに戻ってクリックして適切なクレジットを購入してください"
|
||||
"deeptrain-tip": "ヒント: Deeptrainがウォレットにリロードされたら、ここに戻ってクリックして適切なクレジットを購入してください",
|
||||
"not-config-link": "購入リンクがバックグラウンドで設定されていません"
|
||||
},
|
||||
"pkg": {
|
||||
"title": "パック",
|
||||
|
@ -146,7 +146,8 @@
|
||||
"exchange-failed": "Сбой обмена",
|
||||
"exchange-failed-prompt": "Не удалось погасить по {{reason}}",
|
||||
"buy-link": "Перейти к покупке",
|
||||
"deeptrain-tip": "Совет: как только Deeptrain перезагрузится на ваш кошелек, вернитесь сюда и нажмите, чтобы купить соответствующие кредиты"
|
||||
"deeptrain-tip": "Совет: как только Deeptrain перезагрузится на ваш кошелек, вернитесь сюда и нажмите, чтобы купить соответствующие кредиты",
|
||||
"not-config-link": "Ссылка на покупку не настроена в фоновом режиме"
|
||||
},
|
||||
"pkg": {
|
||||
"title": "Пакеты",
|
||||
|
Loading…
Reference in New Issue
Block a user