Ich erstelle Lappen mit Azure -Technologien. Dazu muss ich Inhalte so streamen, um Frontend zum Schnell Ergebnis zu stream. Andernfalls dauert es lange Zeit bis zur Antwort. [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>
Hier ist Angular Service Code, den ich geschrieben habe < /p>
requestFromBLCopilotAIV3(request: BLCopilotRequestV2) {
return this.http
.post(environment.getEndpoint() + 'Common/getCopilotResponseV3', request,{
responseType: 'text',observe: 'events'
});
}
< /code>
Hier ist Frontend Componenet Code < /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>
Wenn ich nun die Konsole im nächsten als nächstes testet{
"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>
Es ist ok, Inhalt nicht gefunden zu respektieren. Es ist kein Problem, aber dies ist nicht meine erwartete Ausgabe. Meine erwartete Ausgabe ist < /p>
the
requested
information
is
not
found
< /code>
Wie eins nach einer Antwort. Rendite Rendite scheint in Ordnung zu sein. Wie kann ich diese Art von Ausgabe haben, stattdessen eine ganze Reaktion.
Streaming -Reaktion von .NET Core API auf Angular Frontend ⇐ C#
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Streaming -Antwort von der ASP.NET -Kern -Web -API bis hin zu Angular Frontend
by Anonymous » » in C# - 0 Replies
- 6 Views
-
Last post by Anonymous
-