Я создаю тряпку, используя Azure Technologies. Для этого мне нужно транслировать контент для Frontend, чтобы быстро результат. В противном случае для ответа требуется много времени.[HttpPost("getCopilotResponseV3")]
public IEnumerable GetCopilotResponsev3(BLCopilotRequestV2 req)
{
CollectionResult response;
try
{
response = _bLOpenAIService.GetOpenAIResponseStream(req);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting OpenAI response stream.");
yield break;
}
var enumerator = response.GetEnumerator();
using (enumerator)
{
while (enumerator.MoveNext())
{
foreach (var cnt in enumerator.Current.ContentUpdate)
{
yield return cnt.Text;
}
}
}
}
< /code>
Вот угловой код службы, который я написал: < /p>
requestFromBLCopilotAIV3(request: BLCopilotRequestV2) {
return this.http
.post(environment.getEndpoint() + 'Common/getCopilotResponseV3', request,{
responseType: 'text',observe: 'events'
});
}
< /code>
Это код компонента Frontend: < /p>
this.copilotService.requestFromBLCopilotAIV3({ messageList: cpMessageList, indexName: this.copilotComponent.defaultValue, semanticConfigName:this.copilotComponent.mapName } as BLCopilotRequestV2)
.pipe(takeUntil(this.stopSignal))
.subscribe({
next: (event : any) => {
console.log(event)
},
complete: () => {
//this.changeDetector.detectChanges();
},
error: (err) => {
console.error(err);
this.isLoading = false;
this.responseStarted = false;
this.changeDetector.detectChanges();
}
});
< /code>
Когда я тестирую консоли, код печатает что -то вроде этого: < /p>
{
"headers": {
"normalizedNames": {},
"lazyUpdate": null
},
"status": 200,
"statusText": "OK",
"url": "https://localhost:7036/api/Common/getBL ... ResponseV3",
"ok": true,
"type": 4,
"body": "[\"The\",\" requested\",\" information\",\" is\",\" not\",\" available\",\" in\",\" the\",\" retrieved\",\" data\",\".\",\" Please\",\" try\",\" another\",\" query\",\" or\",\" topic\",\".\"]"
}
< /code>
Это нормальное содержание, не найденный ответ. Ответ не является проблемой, но это не мой ожидаемый вывод. < /p>
Мой ожидаемый вывод будет: < /p>
the
requested
information
is
not
found
< /code>
как один за другим ответом. Возврат доходности кажется в порядке.>
Подробнее здесь: https://stackoverflow.com/questions/794 ... r-frontend
Потоковая реакция от ASP.net Core Web API на Angular Frontend ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение