mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 09:46:25 +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 { useContext } from "react";
|
||||
import { useActionState, useContext } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { chatInterfaceContext } from "../ChatInterface";
|
||||
import { generatePodCastAction, getChatPodcastPromise } from "./actions";
|
||||
|
|
@ -11,6 +11,15 @@ export interface PodCastInterface {
|
|||
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() {
|
||||
const context = useContext(chatInterfaceContext);
|
||||
|
||||
|
|
@ -19,6 +28,13 @@ export function ChatPanelContainer() {
|
|||
}
|
||||
|
||||
const { isChatPannelOpen, setIsChatPannelOpen, chat_id: chatId } = context;
|
||||
|
||||
const [state, generatePodcastAction, isGeneratingPodcast] =
|
||||
useActionState<PodcastGenerationState>(generatePodCastAction, {
|
||||
chat_id: chatId,
|
||||
prompt: "Test",
|
||||
});
|
||||
|
||||
return chatId && chatId !== "" ? (
|
||||
<div
|
||||
className={cn(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
"use server";
|
||||
|
||||
import type { PodCastInterface } from "./ChatPanelContainer";
|
||||
import type { PodCastInterface, PodcastGenerationState } from "./ChatPanelContainer";
|
||||
|
||||
export const generatePodCastAction = async (formData: { prompt: string; chatId: string }) => {
|
||||
console.log("Generating podcast");
|
||||
export const generatePodCastAction = async (
|
||||
formData: PodcastGenerationState
|
||||
): Promise<PodCastInterface> => {
|
||||
return Promise.resolve({
|
||||
title: "Test",
|
||||
podcast_transcript: "Test",
|
||||
search_space_id: "Test",
|
||||
});
|
||||
};
|
||||
|
||||
export const getChatPodcastPromise = async (chatId: string): Promise<PodCastInterface> => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue