mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	Merge pull request #3314 from H0llyW00dzZ/text-moderation-azure
Feat ChatGPT LLM Api [Console Log] [Text Moderation] [Azure]
This commit is contained in:
		@@ -228,19 +228,21 @@ export class ChatGPTApi implements LLMApi {
 | 
			
		||||
            }
 | 
			
		||||
            const text = msg.data;
 | 
			
		||||
            try {
 | 
			
		||||
              const json = JSON.parse(text) as {
 | 
			
		||||
                choices: Array<{
 | 
			
		||||
                  delta: {
 | 
			
		||||
                    content: string;
 | 
			
		||||
                  };
 | 
			
		||||
                }>;
 | 
			
		||||
              };
 | 
			
		||||
              const delta = json.choices[0]?.delta?.content;
 | 
			
		||||
              const json = JSON.parse(text);
 | 
			
		||||
              const choices = json.choices as Array<{ delta: { content: string } }>;
 | 
			
		||||
              const delta = choices[0]?.delta?.content;
 | 
			
		||||
              const textmoderation = json?.prompt_filter_results;
 | 
			
		||||
 | 
			
		||||
              if (delta) {
 | 
			
		||||
                remainText += delta;
 | 
			
		||||
              }
 | 
			
		||||
 | 
			
		||||
              if (textmoderation && textmoderation.length > 0 && ServiceProvider.Azure) {
 | 
			
		||||
                const contentFilterResults = textmoderation[0]?.content_filter_results;
 | 
			
		||||
                console.log(`[${ServiceProvider.Azure}] [Text Moderation] flagged categories result:`, contentFilterResults);
 | 
			
		||||
              }
 | 
			
		||||
            } catch (e) {
 | 
			
		||||
              console.error("[Request] parse error", text);
 | 
			
		||||
              console.error("[Request] parse error", text, msg);
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          onclose() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user