Feat: use default ai config (#167)
* fix locale * use openai config if any
This commit is contained in:
@@ -35,6 +35,7 @@ export const ipaCommand = async (
|
||||
const fixParser = OutputFixingParser.fromLLM(
|
||||
new ChatOpenAI({
|
||||
openAIApiKey: key,
|
||||
modelName,
|
||||
temperature: 0,
|
||||
configuration: {
|
||||
baseURL: baseUrl,
|
||||
|
||||
@@ -51,6 +51,7 @@ export const lookupCommand = async (
|
||||
const fixParser = OutputFixingParser.fromLLM(
|
||||
new ChatOpenAI({
|
||||
openAIApiKey: key,
|
||||
modelName,
|
||||
temperature: 0,
|
||||
configuration: {
|
||||
baseURL: baseUrl,
|
||||
|
||||
@@ -30,7 +30,10 @@ import {
|
||||
Textarea,
|
||||
} from "@renderer/components/ui";
|
||||
import { useState, useEffect, useContext } from "react";
|
||||
import { AppSettingsProviderContext } from "@renderer/context";
|
||||
import {
|
||||
AppSettingsProviderContext,
|
||||
AISettingsProviderContext,
|
||||
} from "@renderer/context";
|
||||
import { LoaderIcon } from "lucide-react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
@@ -68,6 +71,7 @@ export const ConversationForm = (props: {
|
||||
const [submitting, setSubmitting] = useState<boolean>(false);
|
||||
const [providers, setProviders] = useState<any>(LLM_PROVIDERS);
|
||||
const { EnjoyApp } = useContext(AppSettingsProviderContext);
|
||||
const { openai } = useContext(AISettingsProviderContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const refreshProviders = async () => {
|
||||
@@ -94,6 +98,15 @@ export const ConversationForm = (props: {
|
||||
refreshProviders();
|
||||
}, []);
|
||||
|
||||
const defaultConfig = conversationDefaultConfiguration;
|
||||
if (defaultConfig.engine === "openai" && openai) {
|
||||
defaultConfig.configuration.model = openai.model;
|
||||
defaultConfig.configuration.baseUrl = openai.baseUrl;
|
||||
}
|
||||
if (defaultConfig.configuration.tts.engine === "openai" && openai) {
|
||||
defaultConfig.configuration.tts.baseUrl = openai.baseUrl;
|
||||
}
|
||||
|
||||
const form = useForm<z.infer<typeof conversationFormSchema>>({
|
||||
resolver: zodResolver(conversationFormSchema),
|
||||
// @ts-ignore
|
||||
@@ -109,10 +122,10 @@ export const ConversationForm = (props: {
|
||||
},
|
||||
}
|
||||
: {
|
||||
name: conversationDefaultConfiguration.name,
|
||||
engine: conversationDefaultConfiguration.engine,
|
||||
name: defaultConfig.name,
|
||||
engine: defaultConfig.engine,
|
||||
configuration: {
|
||||
...conversationDefaultConfiguration.configuration,
|
||||
...defaultConfig.configuration,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -697,6 +710,7 @@ const conversationDefaultConfiguration = {
|
||||
engine: "openai",
|
||||
configuration: {
|
||||
model: "gpt-4-1106-preview",
|
||||
baseUrl: "",
|
||||
roleDefinition: `你是我的英语教练。
|
||||
请将我的话改写成英文。
|
||||
不需要逐字翻译。
|
||||
|
||||
@@ -27,7 +27,11 @@ export const FfmpegCheck = () => {
|
||||
EnjoyApp.ffmpeg.discover().then((config) => {
|
||||
setScanResult(config);
|
||||
if (config.ffmpegPath && config.ffprobePath) {
|
||||
toast.success(t("ffmpegFound"));
|
||||
toast.success(
|
||||
t("ffmpegFoundAt", {
|
||||
path: [config.ffmpegPath, config.ffprobePath].join(", "),
|
||||
})
|
||||
);
|
||||
refreshFfmpegConfig();
|
||||
} else {
|
||||
toast.error(t("ffmpegNotFound"));
|
||||
|
||||
@@ -55,6 +55,7 @@ export const LookupResult = (props: {
|
||||
},
|
||||
{
|
||||
key: openai.key,
|
||||
modelName: openai.model,
|
||||
}
|
||||
)
|
||||
.then((res) => {
|
||||
|
||||
@@ -90,6 +90,7 @@ export const MediaCaption = (props: {
|
||||
|
||||
ipaCommand(transcription.text, {
|
||||
key: openai.key,
|
||||
modelName: openai.model,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result?.words?.length > 0) {
|
||||
@@ -128,6 +129,7 @@ export const MediaCaption = (props: {
|
||||
|
||||
translateCommand(transcription.text, {
|
||||
key: openai.key,
|
||||
modelName: openai.model,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
|
||||
@@ -82,6 +82,7 @@ export default () => {
|
||||
try {
|
||||
const res = await extractStoryCommand(story.content, {
|
||||
key: openai.key,
|
||||
modelName: openai.model,
|
||||
});
|
||||
|
||||
words = res.words || [];
|
||||
|
||||
Reference in New Issue
Block a user