Получение ошибки System.Xml.XmlException при выполнении метода сематического ядра sk.InvokeAsync при наличии некоторых сC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Получение ошибки System.Xml.XmlException при выполнении метода сематического ядра sk.InvokeAsync при наличии некоторых с

Сообщение Anonymous »

У меня есть этот шаблон Hadlebar с семантическим ядром .yaml, и я хочу вставить в него текст расшифровки ниже во время выполнения, чтобы получить структурированный ответ в формате JSON с помощью метода GetSpeakerNames (ядро C#.net)
Я получаю синтаксический анализ ошибка в методе TryParse класса XmlPromptParser Microsoft.SemanticKernel при попытке загрузить шаблон вместе с текстом транскрипции.
xmlDocument.LoadXml($"{prompt}");
System.Xml .XmlException: «Имя не может начинаться с символа «1», шестнадцатеричного значения 0x31. Строка 7, позиция 26.
Я пробовал экранировать содержимое... во время выполнения, а также вставлял экранированные символы в шаблон руля. Ничего не помогает.
Transcription.SpeakerId.yaml


< pre class="snippet-code-html lang-html Prettyprint-override">

Код: Выделить всё

name: TranscriptionSpeakers
description: Takes a conversation dialog transcripts and identifies the speakers
template: |
 Your  input is a speaker based transcription of a conversation between two or more people. In the transcription, the speakers will only be known as SPEAKER 1, SPEAKER 2, etc.
Your goal it to identify the names of the speakers if possible.

Return your results in a JSON format

{
"SPEAKER 1" : "",
"SPEAKER 2" : "",
"SPEAKER 3" : ""
}

If you can not positively identify a speaker from the transcription, leave the value as the current speaker placeholder, e.g. "SPEAKER 1" instead of adding somethng else such as "UNKNOWN". In this scenario, the output would be:

{
"SPEAKER 1" : "",
"SPEAKER 2" : "SPEAKER 2",
"SPEAKER 3" : "SPEAKER 3"
}

IMPORTANT: Do not include any other text in your response other than the JSON object. If you do, your response will be rejected.


{{transcription}}
JSON formatted response
template_format: handlebars
input_variables:
- name: transcription
description: Text of the transcribed conversation
is_required: true
execution_settings:
default:
max_tokens: 4096
temperature: 0.0


текст расшифровки:

Код: Выделить всё

SPEAKER 1: Hi, my name is David Johnson. My laptop keeps disconnecting from Wi-Fi. It's very frustrating.
SPEAKER 2: It is Alex Matrix here. I'm sorry to hear that. Let's see if we can get this resolved. Have you tried connecting to different networks to see if the issue persists?
SPEAKER 1: I hope it gets resolved soon. This issue is really affecting my work.
SPEAKER 2: We understand how important it is to have a reliable Wi-Fi connection. We'll do our best to resolve this quickly. Is there anything else I can help you with today?
SPEAKER 1: No, that's all. Thanks.
SPEAKER 3: You're welcome. Have a nice day.


Код:

Код: Выделить всё

internal async Task GetSpeakerNames(string sourceFileName, string transcription)
{
Dictionary speakerDict = null;
try

var result = await sk.InvokeAsync(yamlPrompts["Transcription_SpeakerId"], new() { { "transcription", transcription } });
try
{
speakerDict = JsonSerializer.Deserialize(result.GetValue());
return speakerDict;
}
catch (Exception exe)
{
log.LogError($"Error getting speaker names: {exe.Message}");
return speakerDict;
}
}
}



Подробнее здесь: https://stackoverflow.com/questions/787 ... -invokeasy
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»