mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
add generate podcast action
This commit is contained in:
parent
ce658b91ea
commit
05a8bd1be3
2 changed files with 26 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { PanelRight } from "lucide-react";
|
import { PanelRight } from "lucide-react";
|
||||||
import { useContext } from "react";
|
import { useActionState, useContext } from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { chatInterfaceContext } from "../ChatInterface";
|
import { chatInterfaceContext } from "../ChatInterface";
|
||||||
import { generatePodCastAction, getChatPodcastPromise } from "./actions";
|
import { generatePodCastAction, getChatPodcastPromise } from "./actions";
|
||||||
|
|
@ -11,6 +11,15 @@ export interface PodCastInterface {
|
||||||
search_space_id: string;
|
search_space_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PodcastGenerationState = Partial<{
|
||||||
|
title: string;
|
||||||
|
podcast_transcript: string;
|
||||||
|
search_space_id: string;
|
||||||
|
chat_id: string;
|
||||||
|
prompt: string;
|
||||||
|
error: unknown;
|
||||||
|
}>;
|
||||||
|
|
||||||
export function ChatPanelContainer() {
|
export function ChatPanelContainer() {
|
||||||
const context = useContext(chatInterfaceContext);
|
const context = useContext(chatInterfaceContext);
|
||||||
|
|
||||||
|
|
@ -19,6 +28,13 @@ export function ChatPanelContainer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { isChatPannelOpen, setIsChatPannelOpen, chat_id: chatId } = context;
|
const { isChatPannelOpen, setIsChatPannelOpen, chat_id: chatId } = context;
|
||||||
|
|
||||||
|
const [state, generatePodcastAction, isGeneratingPodcast] =
|
||||||
|
useActionState<PodcastGenerationState>(generatePodCastAction, {
|
||||||
|
chat_id: chatId,
|
||||||
|
prompt: "Test",
|
||||||
|
});
|
||||||
|
|
||||||
return chatId && chatId !== "" ? (
|
return chatId && chatId !== "" ? (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import type { PodCastInterface } from "./ChatPanelContainer";
|
import type { PodCastInterface, PodcastGenerationState } from "./ChatPanelContainer";
|
||||||
|
|
||||||
export const generatePodCastAction = async (formData: { prompt: string; chatId: string }) => {
|
export const generatePodCastAction = async (
|
||||||
console.log("Generating podcast");
|
formData: PodcastGenerationState
|
||||||
|
): Promise<PodCastInterface> => {
|
||||||
|
return Promise.resolve({
|
||||||
|
title: "Test",
|
||||||
|
podcast_transcript: "Test",
|
||||||
|
search_space_id: "Test",
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getChatPodcastPromise = async (chatId: string): Promise<PodCastInterface> => {
|
export const getChatPodcastPromise = async (chatId: string): Promise<PodCastInterface> => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue