Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

環境変数周りの修正 #159

Merged
merged 8 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# AI Service
NEXT_PUBLIC_SELECT_AI_SERVICE="" # openai, dify, groq, etc.
NEXT_PUBLIC_SELECT_AI_MODEL="" # gpt-4o, claude-3-5-sonnet-20240620, etc.

# Local LLM
NEXT_PUBLIC_LOCAL_LLM_URL=""
NEXT_PUBLIC_LOCAL_LLM_MODEL=""

# Voice
NEXT_PUBLIC_SELECT_VOICE="" # voicevox, elevenlabs, etc.

# VoiceVox
NEXT_PUBLIC_VOICEVOX_SPEAKER="" # 46, 47, etc.
NEXT_PUBLIC_VOICEVOX_SPEED="" # 1.0, 1.2, etc.
NEXT_PUBLIC_VOICEVOX_PITCH="" # 0.0, 0.2, etc.
NEXT_PUBLIC_VOICEVOX_INTONATION="" # 1.0, 1.2, etc.

# KoeiroMap
NEXT_PUBLIC_KOEIROMAP_KEY=""

# Google TTS
NEXT_PUBLIC_GOOGLE_TTS_TYPE=""

# StyleBertVits2
NEXT_PUBLIC_STYLEBERTVITS2_MODEL_ID=""
NEXT_PUBLIC_STYLEBERTVITS2_STYLE=""
NEXT_PUBLIC_STYLEBERTVITS2_SDP_RATIO=""
NEXT_PUBLIC_STYLEBERTVITS2_LENGTH=""

STYLEBERTVITS2_SERVER_URL=""
STYLEBERTVITS2_API_KEY=""

# ElevenLabs
ELEVENLABS_API_KEY=""

# GSVI TTS
NEXT_PUBLIC_GSVI_TTS_URL=""
NEXT_PUBLIC_GSVI_TTS_MODEL_ID=""
NEXT_PUBLIC_GSVI_TTS_BATCH_SIZE=""
NEXT_PUBLIC_GSVI_TTS_SPEECH_RATE=""

# Youtube
NEXT_PUBLIC_YOUTUBE_API_KEY=""
NEXT_PUBLIC_YOUTUBE_MODE=""
NEXT_PUBLIC_YOUTUBE_LIVE_ID=""

# Language
NEXT_PUBLIC_SELECT_LANGUAGE="" # en, ja, etc.
NEXT_PUBLIC_SELECT_VOICE_LANGUAGE="" # en-US, ja-JP, etc.

# Other
NEXT_PUBLIC_BACKGROUND_IMAGE_PATH="/bg-c.png"
NEXT_PUBLIC_SHOW_INTRODUCTION=false
NEXT_PUBLIC_CHARACTER_NAME=""
NEXT_PUBLIC_SHOW_ASSISTANT_TEXT=""
NEXT_PUBLIC_SHOW_CHARACTER_NAME=""
NEXT_PUBLIC_CHANGE_ENGLISH_TO_JAPANESE=""
NEXT_PUBLIC_SHOW_CONTROL_PANEL=""
NEXT_PUBLIC_WEBSOCKET_MODE=""
NEXT_PUBLIC_SLIDE_MODE=""

# AI API Keys
OPENAI_KEY=""
ANTHROPIC_KEY=""
GOOGLE_KEY=""
AZURE_KEY=""
GROQ_KEY=""
COHERE_KEY=""
MISTRALAI_KEY=""
PERPLEXITY_KEY=""
FIREWORKS_KEY=""

# Dify
DIFY_KEY=""
DIFY_URL=""
79 changes: 72 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,75 @@
GOOGLE_APPLICATION_CREDENTIALS="./credentials.json"
NEXT_PUBLIC_OPEN_AI_KEY=""
NEXT_PUBLIC_ANTHROPIC_KEY=""
NEXT_PUBLIC_GOOGLE_KEY=""
NEXT_PUBLIC_GROQ_KEY=""
# AI Service
NEXT_PUBLIC_SELECT_AI_SERVICE="" # openai, dify, groq, etc.
NEXT_PUBLIC_SELECT_AI_MODEL="" # gpt-4o, claude-3-5-sonnet-20240620, etc.

# Local LLM
NEXT_PUBLIC_LOCAL_LLM_URL=""
NEXT_PUBLIC_LOCAL_LLM_MODEL=""
NEXT_PUBLIC_DIFY_KEY=""
NEXT_PUBLIC_DIFY_URL=""

# Voice
NEXT_PUBLIC_SELECT_VOICE="" # voicevox, elevenlabs, etc.

# VoiceVox
NEXT_PUBLIC_VOICEVOX_SPEAKER="" # 46, 47, etc.
NEXT_PUBLIC_VOICEVOX_SPEED="" # 1.0, 1.2, etc.
NEXT_PUBLIC_VOICEVOX_PITCH="" # 0.0, 0.2, etc.
NEXT_PUBLIC_VOICEVOX_INTONATION="" # 1.0, 1.2, etc.

# KoeiroMap
NEXT_PUBLIC_KOEIROMAP_KEY=""

# Google TTS
NEXT_PUBLIC_GOOGLE_TTS_TYPE=""

# StyleBertVits2
NEXT_PUBLIC_STYLEBERTVITS2_MODEL_ID=""
NEXT_PUBLIC_STYLEBERTVITS2_STYLE=""
NEXT_PUBLIC_STYLEBERTVITS2_SDP_RATIO=""
NEXT_PUBLIC_STYLEBERTVITS2_LENGTH=""

STYLEBERTVITS2_SERVER_URL=""
STYLEBERTVITS2_API_KEY=""

# ElevenLabs
ELEVENLABS_API_KEY=""

# GSVI TTS
NEXT_PUBLIC_GSVI_TTS_URL=""
NEXT_PUBLIC_GSVI_TTS_MODEL_ID=""
NEXT_PUBLIC_GSVI_TTS_BATCH_SIZE=""
NEXT_PUBLIC_GSVI_TTS_SPEECH_RATE=""

# Youtube
NEXT_PUBLIC_YOUTUBE_API_KEY=""
NEXT_PUBLIC_YOUTUBE_MODE=""
NEXT_PUBLIC_YOUTUBE_LIVE_ID=""

# Language
NEXT_PUBLIC_SELECT_LANGUAGE="" # en, ja, etc.
NEXT_PUBLIC_SELECT_VOICE_LANGUAGE="" # en-US, ja-JP, etc.

# Other
NEXT_PUBLIC_BACKGROUND_IMAGE_PATH="/bg-c.png"
NEXT_PUBLIC_SHOW_INTRODUCTION=false
NEXT_PUBLIC_CHARACTER_NAME=""
NEXT_PUBLIC_SHOW_ASSISTANT_TEXT=""
NEXT_PUBLIC_SHOW_CHARACTER_NAME=""
NEXT_PUBLIC_CHANGE_ENGLISH_TO_JAPANESE=""
NEXT_PUBLIC_SHOW_CONTROL_PANEL=""
NEXT_PUBLIC_WEBSOCKET_MODE=""
NEXT_PUBLIC_SLIDE_MODE=""

# AI API Keys
OPENAI_KEY=""
ANTHROPIC_KEY=""
GOOGLE_KEY=""
AZURE_KEY=""
GROQ_KEY=""
COHERE_KEY=""
MISTRALAI_KEY=""
PERPLEXITY_KEY=""
FIREWORKS_KEY=""

# Dify
DIFY_KEY=""
DIFY_URL=""
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ credentials.json
.tool-versions

certificates
.env

/public/slides/*
!/public/slides/demo/
1 change: 0 additions & 1 deletion docs/README_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
- Node.js: ^20.0.0
- npm: 10.8.1


## 공통 사전 준비

1. 리포지토리를 로컬에 클론합니다.
Expand Down
1 change: 0 additions & 1 deletion docs/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
- Node.js: ^20.0.0
- npm: 10.8.1


## 共同準備

1. 將存儲庫克隆到本地。
Expand Down
11 changes: 10 additions & 1 deletion locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,14 @@
"PdfConvertLoading": "Converting...",
"PdfConvertSuccess": "Conversion completed",
"PdfConvertError": "Conversion failed",
"PdfConvertSubmitError": "Please make sure the PDF file, folder name, and API key are set."
"PdfConvertSubmitError": "Please make sure the PDF file, folder name, and API key are set.",
"LocalStorageReset": "Reset settings (page will be reloaded)",
"Errors": {
"EmptyAPIKey": "API key is not set",
"AIInvalidProperty": "AI service settings are incorrect",
"AIAPIError": "An error occurred while executing the AI API",
"InvalidAIService": "The selected AI service is not valid",
"MethodNotAllowed": "The request is not appropriate",
"UnexpectedError": "An unexpected error occurred"
}
}
11 changes: 10 additions & 1 deletion locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,14 @@
"PdfConvertLoading": "変換中...",
"PdfConvertSuccess": "変換が完了しました",
"PdfConvertError": "変換に失敗しました",
"PdfConvertSubmitError": "PDFファイル、フォルダ名、APIキーが設定されているか確認をしてください"
"PdfConvertSubmitError": "PDFファイル、フォルダ名、APIキーが設定されているか確認をしてください",
"LocalStorageReset": "設定をリセットする(ページが再読み込みされます)",
"Errors": {
"EmptyAPIKey": "APIキーが設定されていません",
"AIInvalidProperty": "AIサービスの設定値が正しくありません",
"AIAPIError": "AI API実行時にエラーが発生しました",
"InvalidAIService": "選択しているAIサービスが正しくありません",
"MethodNotAllowed": "リクエストが適切でありません",
"UnexpectedError": "予期せぬエラーが発生しました"
}
}
11 changes: 10 additions & 1 deletion locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,14 @@
"PdfConvertLoading": "변환 중...",
"PdfConvertSuccess": "변환 완료",
"PdfConvertError": "변환 실패",
"PdfConvertSubmitError": "PDF 파일, 폴더 이름, API 키가 설정되어 있는지 확인하세요."
"PdfConvertSubmitError": "PDF 파일, 폴더 이름, API 키가 설정되어 있는지 확인하세요.",
"LocalStorageReset": "설정을 재설정합니다 (페이지가 다시 로드됩니다)",
"Errors": {
"EmptyAPIKey": "API 키가 설정되지 않았습니다",
"AIInvalidProperty": "AI 서비스 설정값이 올바르지 않습니다",
"AIAPIError": "AI API 실행 중 오류가 발생했습니다",
"InvalidAIService": "선택한 AI 서비스가 올바르지 않습니다",
"MethodNotAllowed": "요청이 적절하지 않습니다",
"UnexpectedError": "예기치 않은 오류가 발생했습니다"
}
}
11 changes: 10 additions & 1 deletion locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,14 @@
"PdfConvertLoading": "转换中...",
"PdfConvertSuccess": "转换完成",
"PdfConvertError": "转换失败",
"PdfConvertSubmitError": "请确保已设置PDF文件、文件夹名称和API密钥。"
"PdfConvertSubmitError": "请确保已设置PDF文件、文件夹名称和API密钥。",
"LocalStorageReset": "重設設定(頁面會重新載入)",
"Errors": {
"EmptyAPIKey": "API 密钥未设置",
"AIInvalidProperty": "AI 服务设置值不正确",
"AIAPIError": "AI API 执行时发生错误",
"InvalidAIService": "选择的 AI 服务不正确",
"MethodNotAllowed": "请求不适当",
"UnexpectedError": "意外的错误发生"
}
}
17 changes: 7 additions & 10 deletions src/components/introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ import {
} from '@/features/constants/settings'

export const Introduction = () => {
const dontShowIntroduction = homeStore((s) => s.dontShowIntroduction)
const showIntroduction = homeStore((s) => s.showIntroduction)
const selectLanguage = settingsStore((s) => s.selectLanguage)

const [showIntroduction, setShowIntroduction] = useState(false)
const [displayIntroduction, setDisplayIntroduction] = useState(false)
const [opened, setOpened] = useState(true)

const { t } = useTranslation()

useEffect(() => {
// wait for local storage to be fully initialized
// to prevent a flash of <Introduction />
setShowIntroduction(!homeStore.getState().dontShowIntroduction)
}, [dontShowIntroduction])
setDisplayIntroduction(homeStore.getState().showIntroduction)
}, [showIntroduction])

const updateLanguage = () => {
console.log('i18n.language', i18n.language)
Expand Down Expand Up @@ -54,7 +52,7 @@ export const Introduction = () => {
})
}

return showIntroduction && opened ? (
return displayIntroduction && opened ? (
<div className="absolute z-40 w-full h-full px-24 py-40 bg-black/30 font-M_PLUS_2">
<div className="relative mx-auto my-auto max-w-3xl max-h-full p-24 overflow-auto bg-white rounded-16">
<IconButton
Expand Down Expand Up @@ -128,15 +126,14 @@ export const Introduction = () => {
</div>
</div>

{/* dontShowIntroductionのチェックボックスを表示 */}
<div className="my-24">
<label className="flex items-center">
<input
type="checkbox"
checked={dontShowIntroduction}
checked={showIntroduction}
onChange={(e) => {
homeStore.setState({
dontShowIntroduction: e.target.checked,
showIntroduction: e.target.checked,
})
updateLanguage()
}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const Menu = () => {
const chatLog = homeStore((s) => s.chatLog)
const assistantMessage = homeStore((s) => s.assistantMessage)
const showWebcam = menuStore((s) => s.showWebcam)
const showControlPanel = settingsStore((s) => s.showControlPanel)
const showCapture = menuStore((s) => s.showCapture)
const showControlPanel = menuStore((s) => s.showControlPanel)
const slidePlaying = slideStore((s) => s.isPlaying)
const showAssistantText = settingsStore((s) => s.showAssistantText)

Expand Down
14 changes: 12 additions & 2 deletions src/components/settings/advancedSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ const AdvancedSettings = () => {
const changeEnglishToJapanese = settingsStore(
(s) => s.changeEnglishToJapanese
)
const showControlPanel = menuStore((s) => s.showControlPanel)
const showControlPanel = settingsStore((s) => s.showControlPanel)
const showAssistantText = settingsStore((s) => s.showAssistantText)
const showCharacterName = settingsStore((s) => s.showCharacterName)

const { t } = useTranslation()

return (
<div className="my-40">
<div className="my-40 grid-cols-2">
<TextButton
onClick={() => {
settingsStore.persist.clearStorage()
window.location.reload()
}}
>
{t('LocalStorageReset')}
</TextButton>
</div>
<Disclosure>
{({ open }) => (
<>
Expand Down Expand Up @@ -97,7 +107,7 @@ const AdvancedSettings = () => {
<div className="my-8">
<TextButton
onClick={() =>
menuStore.setState({
settingsStore.setState({
showControlPanel: !showControlPanel,
})
}
Expand Down
12 changes: 5 additions & 7 deletions src/features/chat/aiChatFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@ export async function getAIChatResponseStream(
case 'fireworks':
return getVercelAIChatResponseStream(
messages,
ss[`${service}Key`] ||
process.env[`NEXT_PUBLIC_${service.toUpperCase()}_KEY`] ||
'',
ss[`${service}Key`] || '',
service,
ss.selectAIModel
)
case 'localLlm':
return getLocalLLMChatResponseStream(
messages,
ss.localLlmUrl || process.env.NEXT_PUBLIC_LOCAL_LLM_URL || '',
ss.selectAIModel || process.env.NEXT_PUBLIC_LOCAL_LLM_MODEL || ''
ss.localLlmUrl,
ss.selectAIModel
)
case 'dify':
return getDifyChatResponseStream(
messages,
ss.difyKey || process.env.NEXT_PUBLIC_DIFY_KEY || '',
ss.difyUrl || process.env.NEXT_PUBLIC_DIFY_URL || '',
ss.difyKey || '',
ss.difyUrl || '',
ss.difyConversationId
)
default:
Expand Down
Loading
Loading