Fix openai proxy (#244)
* add create messages in batch * add use conversation * update conversation shortcut * add speech handler * tts in renderer * fix speech create
This commit is contained in:
@@ -4,16 +4,18 @@ import { Button, ScrollArea, toast } from "@renderer/components/ui";
|
||||
import { LoaderSpin } from "@renderer/components";
|
||||
import { MessageCircleIcon, LoaderIcon } from "lucide-react";
|
||||
import { t } from "i18next";
|
||||
import { useConversation } from "@renderer/hooks";
|
||||
|
||||
export const ConversationsShortcut = (props: {
|
||||
prompt: string;
|
||||
onReply?: (reply: MessageType[]) => void;
|
||||
onReply?: (reply: Partial<MessageType>[]) => void;
|
||||
}) => {
|
||||
const { EnjoyApp } = useContext(AppSettingsProviderContext);
|
||||
const { prompt, onReply } = props;
|
||||
const [conversations, setConversations] = useState<ConversationType[]>([]);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [offset, setOffset] = useState<number>(0);
|
||||
const { chat } = useConversation();
|
||||
|
||||
const fetchConversations = () => {
|
||||
if (offset === -1) return;
|
||||
@@ -51,10 +53,8 @@ export const ConversationsShortcut = (props: {
|
||||
|
||||
const ask = (conversation: ConversationType) => {
|
||||
setLoading(true);
|
||||
EnjoyApp.conversations
|
||||
.ask(conversation.id, {
|
||||
content: prompt,
|
||||
})
|
||||
|
||||
chat({ content: prompt }, { conversation })
|
||||
.then((replies) => {
|
||||
onReply(replies);
|
||||
})
|
||||
|
||||
@@ -31,6 +31,7 @@ import { useCopyToClipboard } from "@uidotdev/usehooks";
|
||||
import { t } from "i18next";
|
||||
import { AppSettingsProviderContext } from "@renderer/context";
|
||||
import Markdown from "react-markdown";
|
||||
import { useConversation } from "@renderer/hooks";
|
||||
|
||||
export const AssistantMessageComponent = (props: {
|
||||
message: MessageType;
|
||||
@@ -46,6 +47,7 @@ export const AssistantMessageComponent = (props: {
|
||||
const [resourcing, setResourcing] = useState<boolean>(false);
|
||||
const [shadowing, setShadowing] = useState<boolean>(false);
|
||||
const { EnjoyApp } = useContext(AppSettingsProviderContext);
|
||||
const { tts } = useConversation();
|
||||
|
||||
useEffect(() => {
|
||||
if (speech) return;
|
||||
@@ -59,13 +61,12 @@ export const AssistantMessageComponent = (props: {
|
||||
|
||||
setSpeeching(true);
|
||||
|
||||
EnjoyApp.messages
|
||||
.createSpeech(message.id, {
|
||||
engine: configuration?.tts?.engine,
|
||||
model: configuration?.tts?.model,
|
||||
voice: configuration?.tts?.voice,
|
||||
baseUrl: configuration?.tts?.baseUrl,
|
||||
})
|
||||
tts({
|
||||
sourceType: "Message",
|
||||
sourceId: message.id,
|
||||
text: message.content,
|
||||
configuration: configuration.tts,
|
||||
})
|
||||
.then((speech) => {
|
||||
setSpeech(speech);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user