Nagesh Muralidhar commited on
Commit
70c3b32
·
1 Parent(s): b4dc0bf

midterm-submission

Browse files
podcraft/src/pages/Home.tsx CHANGED
@@ -52,12 +52,6 @@ const Home: React.FC = () => {
52
 
53
  const sendMessageToServer = async (message: string): Promise<ChatResponse> => {
54
  try {
55
- setMessages(prev => [...prev, {
56
- id: prev.length + 1,
57
- text: `Processing your request...`,
58
- agent: "system"
59
- }]);
60
-
61
  const response = await fetch(`${API_URL}/api/chat`, {
62
  method: 'POST',
63
  headers: {
@@ -76,7 +70,8 @@ const Home: React.FC = () => {
76
 
77
  if (!response.ok) {
78
  const errorData = await response.text();
79
- throw new Error(`Server error: ${response.status} - ${errorData}`);
 
80
  }
81
 
82
  const data: ChatResponse = await response.json();
 
52
 
53
  const sendMessageToServer = async (message: string): Promise<ChatResponse> => {
54
  try {
 
 
 
 
 
 
55
  const response = await fetch(`${API_URL}/api/chat`, {
56
  method: 'POST',
57
  headers: {
 
70
 
71
  if (!response.ok) {
72
  const errorData = await response.text();
73
+ console.error('Server error:', response.status, errorData);
74
+ throw new Error(`Server error (${response.status}): ${errorData}`);
75
  }
76
 
77
  const data: ChatResponse = await response.json();
podcraft/src/pages/PodcastForm.tsx CHANGED
@@ -42,7 +42,7 @@ const PodcastForm: React.FC = () => {
42
  if (!id) return;
43
 
44
  // Fetch podcast details
45
- const response = await fetch(`${API_URL}/audio-list`);
46
  if (!response.ok) {
47
  throw new Error('Failed to fetch podcasts');
48
  }
@@ -52,7 +52,7 @@ const PodcastForm: React.FC = () => {
52
  id: index + 1,
53
  title: file.filename.split('-')[0].replace(/_/g, ' '),
54
  description: "An AI-generated debate podcast exploring different perspectives",
55
- audio_file: `${API_URL}/audio/${file.filename}`
56
  }));
57
 
58
  const selectedPodcast = podcastList.find(p => p.id === parseInt(id));
@@ -60,7 +60,7 @@ const PodcastForm: React.FC = () => {
60
  setPodcast(selectedPodcast);
61
 
62
  // Fetch podcast context
63
- const contextResponse = await fetch(`${API_URL}/podcast/${id}/context`);
64
  if (contextResponse.ok) {
65
  const contextData: PodcastContext = await contextResponse.json();
66
  setPodcastContext(contextData);
 
42
  if (!id) return;
43
 
44
  // Fetch podcast details
45
+ const response = await fetch(`${API_URL}/api/audio-list`);
46
  if (!response.ok) {
47
  throw new Error('Failed to fetch podcasts');
48
  }
 
52
  id: index + 1,
53
  title: file.filename.split('-')[0].replace(/_/g, ' '),
54
  description: "An AI-generated debate podcast exploring different perspectives",
55
+ audio_file: `${API_URL}${file.path}`
56
  }));
57
 
58
  const selectedPodcast = podcastList.find(p => p.id === parseInt(id));
 
60
  setPodcast(selectedPodcast);
61
 
62
  // Fetch podcast context
63
+ const contextResponse = await fetch(`${API_URL}/api/podcast/${id}/context`);
64
  if (contextResponse.ok) {
65
  const contextData: PodcastContext = await contextResponse.json();
66
  setPodcastContext(contextData);