def run()

in pipeline/activities/callAoai.py [0:0]


def run(textResult: str):
    """
    Calls the Azure OpenAI service with the provided text result.
    
    Args:
        text_result (str): The text result to be processed by the Azure OpenAI service.
    
    Returns:
        str: The response from the Azure OpenAI service.
    """
    try:
      # Load the prompt
      prompt_json = load_prompts()
      
      # Call the Azure OpenAI service
      response_content = run_prompt(textResult, prompt_json['system_prompt'])
      if response_content.startswith('```json') and response_content.endswith('```'):
        response_content = response_content.strip('`')
        response_content = response_content.replace('json', '', 1).strip()
      
      json_str = response_content
      # Return the response
      return json_str
  
    except Exception as e:
        logging.error(f"Error processing {textResult}: {e}")
        return None