Skip to content

Commit

Permalink
Merge pull request #285 from tegnike/develop
Browse files Browse the repository at this point in the history
本番リリース
  • Loading branch information
tegnike authored Jan 5, 2025
2 parents efde898 + f43df3a commit ffc1199
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 36 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ NEXT_PUBLIC_SELECTED_VRM_PATH=""
# Whether to include timestamp in user message (true or false)
NEXT_PUBLIC_INCLUDE_TIMESTAMP_IN_USER_MESSAGE=""

# Message Receiver (true or false)
NEXT_PUBLIC_MESSAGE_RECEIVER_ENABLED=""

# Use Search Grounding (true or false)
NEXT_PUBLIC_USE_SEARCH_GROUNDING=""

# Model Type (vrm or live2d)
NEXT_PUBLIC_MODEL_TYPE=""

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<a href="https://github.com/sponsors/tegnike"><img alt="GitHub Sponsor" src="https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat&logo=github"/></a>
</p>

<div align="center">
<h3>
🌟 <a href="https://aituberkit.com">デモサイトへ</a> 🌟
</h3>
</div>

<h3 align="center">
<a href="./docs/README_en.md">English</a>|
<a href="./docs/README_zh.md">中文</a>|
Expand Down
6 changes: 6 additions & 0 deletions docs/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<a href="https://github.com/sponsors/tegnike"><img alt="GitHub Sponsor" src="https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat&logo=github"/></a>
</p>

<div align="center">
<h3>
🌟 <a href="https://aituberkit.com">Demo Site</a> 🌟
</h3>
</div>

<h3 align="center">
<a href="../README.md">【Japanese】</a>|
<a href="./README_zh.md">【Chinese】</a>|
Expand Down
6 changes: 6 additions & 0 deletions docs/README_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<a href="https://github.com/sponsors/tegnike"><img alt="GitHub Sponsor" src="https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat&logo=github"/></a>
</p>

<div align="center">
<h3>
🌟 <a href="https://aituberkit.com">Demo Site</a> 🌟
</h3>
</div>

<h3 align="center">
<a href="../README.md">【일본어】</a>|
<a href="./README_en.md">【영어】</a>|
Expand Down
6 changes: 6 additions & 0 deletions docs/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<a href="https://github.com/sponsors/tegnike"><img alt="GitHub Sponsor" src="https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat&logo=github"/></a>
</p>

<div align="center">
<h3>
🌟 <a href="https://aituberkit.com">Demo Site</a> 🌟
</h3>
</div>

<h3 align="center">
<a href="../README.md">【日本語】</a>|
<a href="./README_en.md">【英語】</a>|
Expand Down
1 change: 1 addition & 0 deletions locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"AudioMode": "Audio Mode (Beta)",
"InputText": "Text",
"InputAudio": "Audio",
"SearchGrounding": "Use Search Grounding",
"UpdateRealtimeAPISettings": "Update Realtime API Settings",
"UpdateRealtimeAPISettingsInfo": "When updating the API key, Azure Endpoint, voice type, model, or system prompt, please press the update button to start a new WebSocket session.",
"AzureEndpoint": "Azure Endpoint",
Expand Down
1 change: 1 addition & 0 deletions locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"AudioMode": "オーディオモード(ベータ版)",
"InputText": "テキスト",
"InputAudio": "音声",
"SearchGrounding": "検索機能を利用する",
"UpdateRealtimeAPISettings": "リアルタイムAPI設定を更新",
"UpdateRealtimeAPISettingsInfo": "APIキー、Azure Endpoint、ボイスタイプ、モデル、システムプロンプトを更新した際は更新ボタンを押して、新しいWebSocketセッションを開始してください。",
"AzureEndpoint": "Azure Endpoint",
Expand Down
1 change: 1 addition & 0 deletions locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"AudioMode": "오디오 모드 (베타 버전)",
"InputText": "텍스트",
"InputAudio": "음성",
"SearchGrounding": "검색 기능을 사용하기",
"UpdateRealtimeAPISettings": "리얼타임 API 설정 업데이트",
"UpdateRealtimeAPISettingsInfo": "API 키, Azure Endpoint, 보이스 타입, 모델, 시스템 프롬프트를 업데이트한 경우 업데이트 버튼을 눌러 새로운 WebSocket 세션을 시작하십시오.",
"AzureEndpoint": "Azure Endpoint",
Expand Down
1 change: 1 addition & 0 deletions locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"AudioMode": "音訊模式(測試版)",
"InputText": "文字",
"InputAudio": "音訊",
"SearchGrounding": "使用搜索功能",
"UpdateRealtimeAPISettings": "更新實時API設定",
"UpdateRealtimeAPISettingsInfo": "當更新 API 金鑰、Azure Endpoint、語音型別、模型或系統提示時,請按更新按鈕以開始新的 WebSocket 會話。",
"AzureEndpoint": "Azure Endpoint",
Expand Down
52 changes: 26 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/live2DViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function Live2DViewer() {

console.log('Rendering Live2DViewer')
return (
<div className="fixed bottom-0 right-0 w-screen h-screen">
<div className="fixed bottom-0 right-0 w-screen h-screen z-5">
<Script
key={`cubismcore-${scriptLoadRetries.cubismcore}`}
src="/scripts/live2dcubismcore.min.js"
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const Main = () => {
const Footer = () => {
return (
<footer className="absolute py-4 bg-[#413D43] text-center text-white font-Montserrat bottom-0 w-full">
powered by ChatVRM from Pixiv / ver. 2.21.0
powered by ChatVRM from Pixiv / ver. 2.22.0
</footer>
)
}
17 changes: 17 additions & 0 deletions src/components/settings/modelProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const ModelProvider = () => {
const perplexityKey = settingsStore((s) => s.perplexityKey)
const fireworksKey = settingsStore((s) => s.fireworksKey)
const difyKey = settingsStore((s) => s.difyKey)
const useSearchGrounding = settingsStore((s) => s.useSearchGrounding)

const selectAIService = settingsStore((s) => s.selectAIService)
const selectAIModel = settingsStore((s) => s.selectAIModel)
Expand Down Expand Up @@ -480,6 +481,22 @@ const ModelProvider = () => {
</option>
</select>
</div>
<div className="my-24">
<div className="my-16 typography-20 font-bold">
{t('SearchGrounding')}
</div>
<div className="my-8">
<TextButton
onClick={() => {
settingsStore.setState({
useSearchGrounding: !useSearchGrounding,
})
}}
>
{useSearchGrounding ? t('StatusOn') : t('StatusOff')}
</TextButton>
</div>
</div>
</>
)
} else if (selectAIService === 'azure') {
Expand Down
21 changes: 17 additions & 4 deletions src/features/chat/vercelAIChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const getAIConfig = () => {
selectAIService: aiService,
selectAIModel: ss.selectAIModel,
azureEndpoint: ss.azureEndpoint,
useSearchGrounding: ss.useSearchGrounding,
}
}

Expand All @@ -28,8 +29,13 @@ function handleApiError(errorCode: string): string {
}

export async function getVercelAIChatResponse(messages: Message[]) {
const { aiApiKey, selectAIService, selectAIModel, azureEndpoint } =
getAIConfig()
const {
aiApiKey,
selectAIService,
selectAIModel,
azureEndpoint,
useSearchGrounding,
} = getAIConfig()

try {
const response = await fetch('/api/aiChat', {
Expand All @@ -44,6 +50,7 @@ export async function getVercelAIChatResponse(messages: Message[]) {
model: selectAIModel,
azureEndpoint: azureEndpoint,
stream: false,
useSearchGrounding: useSearchGrounding,
}),
})

Expand All @@ -67,8 +74,13 @@ export async function getVercelAIChatResponse(messages: Message[]) {
export async function getVercelAIChatResponseStream(
messages: Message[]
): Promise<ReadableStream<string>> {
const { aiApiKey, selectAIService, selectAIModel, azureEndpoint } =
getAIConfig()
const {
aiApiKey,
selectAIService,
selectAIModel,
azureEndpoint,
useSearchGrounding,
} = getAIConfig()

const response = await fetch('/api/aiChat', {
method: 'POST',
Expand All @@ -82,6 +94,7 @@ export async function getVercelAIChatResponseStream(
model: selectAIModel,
azureEndpoint: azureEndpoint,
stream: true,
useSearchGrounding: useSearchGrounding,
}),
})

Expand Down
6 changes: 5 additions & 1 deletion src/features/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ interface General {
slideMode: boolean
messageReceiverEnabled: boolean
clientId: string
useSearchGrounding: boolean
}

interface ModelType {
Expand Down Expand Up @@ -286,8 +287,11 @@ const settingsStore = create<SettingsState>()(
(process.env.NEXT_PUBLIC_AUDIO_MODE_VOICE as OpenAITTSVoice) ||
'shimmer',
slideMode: process.env.NEXT_PUBLIC_SLIDE_MODE === 'true',
messageReceiverEnabled: false,
messageReceiverEnabled:
process.env.NEXT_PUBLIC_MESSAGE_RECEIVER_ENABLED === 'true',
clientId: '',
useSearchGrounding:
process.env.NEXT_PUBLIC_USE_SEARCH_GROUNDING === 'true',

// NijiVoice settings
nijivoiceApiKey: '',
Expand Down
17 changes: 14 additions & 3 deletions src/pages/api/aiChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ export default async function handler(req: NextRequest) {
)
}

const { messages, apiKey, aiService, model, azureEndpoint, stream } =
await req.json()
const {
messages,
apiKey,
aiService,
model,
azureEndpoint,
stream,
useSearchGrounding,
} = await req.json()

let aiApiKey = apiKey
if (!aiApiKey) {
Expand Down Expand Up @@ -128,10 +135,14 @@ export default async function handler(req: NextRequest) {
const instance = aiServiceInstance()
const modifiedMessages: Message[] = modifyMessages(aiService, messages)

const isUseSearchGrounding = aiService === 'google' && useSearchGrounding
const options = isUseSearchGrounding ? { useSearchGrounding: true } : {}
console.log('options', options)

try {
if (stream) {
const result = await streamText({
model: instance(modifiedModel),
model: instance(modifiedModel, options),
messages: modifiedMessages as CoreMessage[],
})

Expand Down

0 comments on commit ffc1199

Please sign in to comment.