Skip to content

Commit ea1b660

Browse files
committed
fix
1 parent b373801 commit ea1b660

File tree

9 files changed

+27
-19
lines changed

9 files changed

+27
-19
lines changed

services/net/auto-clipper/Config/AutoClipperOptions.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ public class AutoClipperOptions : ServiceOptions
122122
/// </summary>
123123
public int LlmPromptCharacterLimit { get; set; } = 0;
124124

125-
/// <summary>
126-
/// get/set - The LLM temperature.
127-
/// </summary>
128-
public double LlmTemperature { get; set; } = 0.1;
129-
130125
/// <summary>
131126
/// get/set - The LLM boundary score threshold.
132127
/// </summary>

services/net/auto-clipper/Config/StationProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class StationTextProfile
2727
public Dictionary<string, string> KeywordCategories { get; set; } = new();
2828
public bool LlmSegmentation { get; set; } = true;
2929
public string LlmModel { get; set; } = string.Empty;
30+
public float? LlmTemperature { get; set; }
3031
public string LlmPrompt { get; set; } = string.Empty;
3132
public string? SystemPrompt { get; set; }
3233
public bool? LlmDiarization { get; set; } = null;

services/net/auto-clipper/Config/Stations/CKNW.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ text:
1919
"(?i)coming up": Promo
2020
llm_segmentation: true
2121
llm_model: gpt-5.1-chat
22+
llm_temperature: 1
2223
system_prompt: |
2324
You are a Broadcast Structure Parser. Your ONLY job is to detect segment transitions.
2425
Output MUST be a single, raw JSON object.

services/net/auto-clipper/LLM/ClipSegmentationService.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text.RegularExpressions;
66
using Microsoft.Extensions.Logging;
77
using Microsoft.Extensions.Options;
8+
using TNO.Core.Exceptions;
89
using TNO.Core.Extensions;
910
using TNO.Services.AutoClipper.Azure;
1011
using TNO.Services.AutoClipper.Config;
@@ -71,7 +72,7 @@ public async Task<IReadOnlyList<ClipDefinition>> GenerateClipsAsync(IReadOnlyLis
7172
var payload = new
7273
{
7374
model = string.IsNullOrWhiteSpace(settings?.ModelOverride) ? _options.LlmDefaultModel : settings!.ModelOverride!,
74-
temperature = _options.LlmTemperature,
75+
temperature = settings!.TemperatureOverride,
7576
messages = new object[]
7677
{
7778
new { role = "system", content = systemPrompt },
@@ -87,16 +88,25 @@ public async Task<IReadOnlyList<ClipDefinition>> GenerateClipsAsync(IReadOnlyLis
8788

8889
using var response = await _httpClient.SendAsync(request, cancellationToken);
8990
var body = await response.Content.ReadAsStringAsync(cancellationToken);
90-
response.EnsureSuccessStatusCode();
9191

92-
var clipDefinitions = ParseResponse(body, transcript, settings, heuristicHits);
93-
if (clipDefinitions.Count == 0)
92+
if (response.IsSuccessStatusCode)
9493
{
95-
_logger.LogWarning("LLM segmentation did not return any clips.");
94+
95+
var clipDefinitions = ParseResponse(body, transcript, settings, heuristicHits);
96+
if (clipDefinitions.Count == 0)
97+
{
98+
_logger.LogWarning("LLM segmentation did not return any clips.");
99+
return [];
100+
}
101+
102+
return clipDefinitions;
103+
}
104+
else
105+
{
106+
var responseException = new HttpClientRequestException(response);
107+
_logger.LogError(responseException, "Failed to segment transcript with LLM. Error: {Details}", body);
96108
return [];
97109
}
98-
99-
return clipDefinitions;
100110
}
101111
catch (Exception ex)
102112
{

services/net/auto-clipper/LLM/ClipSegmentationSettings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System.Collections.Generic;
2-
31
namespace TNO.Services.AutoClipper.LLM;
42

53
public class ClipSegmentationSettings
64
{
75
public string? PromptOverride { get; set; }
86
public string? ModelOverride { get; set; }
7+
public float? TemperatureOverride { get; set; }
98
public string? SystemPrompt { get; set; }
109
public int? PromptCharacterLimit { get; set; }
1110
public int? MaxStories { get; set; }

services/net/auto-clipper/Pipeline/ClipProcessingPipeline.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private static ClipSegmentationSettings BuildSegmentationSettings(StationProfile
5858
{
5959
PromptOverride = string.IsNullOrWhiteSpace(profile.Text.LlmPrompt) ? null : profile.Text.LlmPrompt,
6060
ModelOverride = string.IsNullOrWhiteSpace(profile.Text.LlmModel) ? null : profile.Text.LlmModel,
61+
TemperatureOverride = profile.Text.LlmTemperature,
6162
SystemPrompt = string.IsNullOrWhiteSpace(profile.Text.SystemPrompt) ? null : profile.Text.SystemPrompt,
6263
PromptCharacterLimit = profile.Text.PromptCharacterLimit,
6364
MaxStories = profile.Text.MaxStories,

services/net/auto-clipper/appsettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"LlmApiVersion": "",
6161
"LlmPrompt": "",
6262
"LlmPromptCharacterLimit": 0,
63-
"LlmTemperature": 0.2,
6463
"StationConfigPath": "Config/Stations"
6564
},
6665
"CHES": {

tools/auto-clipper-harness/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ static ClipSegmentationSettings BuildSegmentationSettings(StationProfile profile
298298
{
299299
PromptOverride = string.IsNullOrWhiteSpace(profile.Text.LlmPrompt) ? null : profile.Text.LlmPrompt,
300300
ModelOverride = string.IsNullOrWhiteSpace(profile.Text.LlmModel) ? null : profile.Text.LlmModel,
301+
TemperatureOverride = profile.Text.LlmTemperature,
301302
SystemPrompt = string.IsNullOrWhiteSpace(profile.Text.SystemPrompt) ? null : profile.Text.SystemPrompt,
302303
PromptCharacterLimit = profile.Text.PromptCharacterLimit,
303304
MaxStories = profile.Text.MaxStories,

tools/scripts/gen-env-files.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,14 @@ Kafka__BootstrapServers=host.docker.internal:$portKafkaBrokerAdvertisedExternal
569569
Service__AzureSpeechKey={ENTER A VALID AZURE KEY}
570570
Service__AzureSpeechRegion=westus
571571
572+
Service__AzureSpeechStorageConnectionString={Connection String}
573+
Service__AzureSpeechStorageContainer=batch-transcripts
574+
572575
# Configure Azure OpenAI/Foundary LLM Service
573576
Service__LlmApiUrl=https://mmiopenai.cognitiveservices.azure.com
574577
Service__LlmApiKey={ENTER A VALID AZURE KEY}
575-
Service__LlmModel=
576-
Service__LlmDeployment=gpt-4o-mini
577-
Service__LlmPrompt=
578-
Service__LlmApiVersion=2025-01-01-preview" >> ./services/net/auto-clipper/.env
578+
Service__LlmDefaultModel=gpt-5.1-chat
579+
Service__LlmPrompt=" >> ./services/net/auto-clipper/.env
579580
echo "./services/net/auto-clipper/.env created"
580581
fi
581582

0 commit comments

Comments
 (0)