diff --git a/enterprise_catalog/apps/ai_curation/openai_client.py b/enterprise_catalog/apps/ai_curation/openai_client.py index b3df53b34..b8cbfa18a 100644 --- a/enterprise_catalog/apps/ai_curation/openai_client.py +++ b/enterprise_catalog/apps/ai_curation/openai_client.py @@ -85,7 +85,7 @@ def chat_completions( response_content = response.json().get('content') if response_format == 'json': return json.loads(response_content) - return json.loads(response_content)[0] + return response_content except json.decoder.JSONDecodeError as ex: LOGGER.error( '[AI_CURATION] Invalid JSON response received: Prompt: [%s], Response: [%s]', diff --git a/enterprise_catalog/apps/api_client/discovery.py b/enterprise_catalog/apps/api_client/discovery.py index 38732c0a3..3e4d5d644 100644 --- a/enterprise_catalog/apps/api_client/discovery.py +++ b/enterprise_catalog/apps/api_client/discovery.py @@ -232,7 +232,7 @@ def get_video_skills(self, video_usage_key): """ page = 1 results = [] - request_params = {'page': page, 'usage_key': video_usage_key, 'verified': 'true'} + request_params = {'page': page, 'usage_key': video_usage_key, 'verified': 'false'} try: response = self._retrieve_video_skills(request_params) results += response.get('results', []) diff --git a/enterprise_catalog/apps/video_catalog/management/commands/generate_video_transcript_summary.py b/enterprise_catalog/apps/video_catalog/management/commands/generate_video_transcript_summary.py index 32b103548..0284c747d 100644 --- a/enterprise_catalog/apps/video_catalog/management/commands/generate_video_transcript_summary.py +++ b/enterprise_catalog/apps/video_catalog/management/commands/generate_video_transcript_summary.py @@ -36,6 +36,14 @@ def handle(self, *args, **options): processed_videos = VideoTranscriptSummary.objects.all().values_list('video_id', flat=True) videos = Video.objects.exclude(edx_video_id__in=processed_videos) for video in videos: - summary = generate_transcript_summary(video) - if summary: - VideoTranscriptSummary.objects.create(video=video, summary=summary) + try: + summary = generate_transcript_summary(video) + if summary: + VideoTranscriptSummary.objects.create(video=video, summary=summary) + except Exception as ex: # pylint: disable=broad-exception-caught + logger.error( + '[FETCH_VIDEO_TRANSCRIPT_SUMMARY] Failure in generating transcript \ + summary for Video id: "%s". Ex: "%s".', + video.edx_video_id, + str(ex) + ) diff --git a/enterprise_catalog/apps/video_catalog/utils.py b/enterprise_catalog/apps/video_catalog/utils.py index b53729a28..3a78fe8f4 100644 --- a/enterprise_catalog/apps/video_catalog/utils.py +++ b/enterprise_catalog/apps/video_catalog/utils.py @@ -110,7 +110,7 @@ def get_transcript_summary(transcript: str, max_length: int = 260) -> str: 'content': settings.SUMMARIZE_VIDEO_TRANSCRIPT_PROMPT.format(count=max_length, transcript=transcript) } ] - return chat_completions(messages=messages, response_format='text', response_type=str) + return chat_completions(messages=messages, response_format='text') def fetch_transcript(transcript_url: str, include_time_markings: bool = True) -> str: