import openai import os class CriticalAnalysisExpert: def __init__(self): self.openai_api_key = os.environ.get("OPENAI_API_KEY") # Load OpenAI API key - **CAE هم اکنون از OpenAI API استفاده می‌کند** openai.api_key = self.openai_api_key self.model_name = "gpt-4o" # Specify GPT-4o model - **CAE هم اکنون از GPT-4o استفاده می‌کند** def analyze_outputs(self, chatbot_prompt, knowledge_base, faq_section): prompt_critique_suggestions = self._analyze_chatbot_prompt(chatbot_prompt) knowledge_base_critique_suggestions = self._analyze_knowledge_base(knowledge_base) faq_section_critique_suggestions = self._analyze_faq_section(faq_section) return prompt_critique_suggestions, knowledge_base_critique_suggestions, faq_section_critique_suggestions def _analyze_chatbot_prompt(self, chatbot_prompt): # **[محل پیاده‌سازی منطق تحلیل انتقادی پرامپت با استفاده از API ChatGPT و GPT-4o و پرامپت CAE نهایی - برای GPT-4o]** # جایگزین placeholder با کد واقعی تحلیل انتقادی پرامپت (برای GPT-4o) critique_prompt = f""" Critique the following chatbot prompt: {chatbot_prompt} Provide detailed critique and suggestions for improvement in Persian. """ response = openai.ChatCompletion.create( # استفاده از openai.ChatCompletion.create به جای Gemini API model=self.model_name, messages=[ {"role": "user", "content": critique_prompt} ] ) return response.choices[0].message.content # Return critique and suggestions as text def _analyze_knowledge_base(self, knowledge_base): # **[محل پیاده‌سازی منطق تحلیل انتقادی پایگاه دانش با استفاده از API ChatGPT و GPT-4o و پرامپت CAE نهایی - برای GPT-4o]** # جایگزین placeholder با کد واقعی تحلیل انتقادی پایگاه دانش (برای GPT-4o) critique_prompt = f""" Critique the following knowledge base: {knowledge_base} Provide detailed critique and suggestions for improvement in Persian. """ response = openai.ChatCompletion.create( # استفاده از openai.ChatCompletion.create به جای Gemini API model=self.model_name, messages=[ {"role": "user", "content": critique_prompt} ] ) return response.choices[0].message.content # Return critique and suggestions as text def _analyze_faq_section(self, faq_section): # **[محل پیاده‌سازی منطق تحلیل انتقادی بخش FAQ با استفاده از API ChatGPT و GPT-4o و پرامپت CAE نهایی - برای GPT-4o]** # جایگزین placeholder با کد واقعی تحلیل انتقادی بخش FAQ (برای GPT-4o) critique_prompt = f""" Critique the following FAQ section: {faq_section} Provide detailed critique and suggestions for improvement in Persian. """ response = openai.ChatCompletion.create( # استفاده از openai.ChatCompletion.create به جای Gemini API model=self.model_name, messages=[ {"role": "user", "content": critique_prompt} ] ) return response.choices[0].message.content # Return critique and suggestions as text