Repository: microsoft/semantic-kernel
File: python/samples/concepts/agents/openai_responses/responses_agent_binary_content_upload.py (Python)

Code before:
- Full-time employees with at least 6 months tenure
- Managers approval required
- Home office setup must meet security requirements

Work Schedule:
- Core hours: 10 AM - 3 PM local time
- Flexible start/end times outside core hours
- Maximum 3 remote days per week for hybrid roles

Communication Requirements:
- Daily check-ins with team lead
- Weekly video conference participation
- Response time: within 4 hours during business hours

Equipment and Security:
- Company-provided laptop and VPN access
- Secure Wi-Fi connection required
- No public Wi-Fi for work activities

For questions about remote work policies, contact HR at hr@company.com
"""


async def main():
    # 1. Create the client using OpenAI resources and configuration
    client, model = OpenAIResponsesAgent.setup_resources()

    # 2. Get path to existing PDF file and create sample text file
    pdf_file_path = os.path.join(
        os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))),
        "resources",
        "file_search",
        "employees.pdf",
    )

    # Create a sample text file for demonstration
    with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as text_file:
        text_content = create_sample_text_content()
        text_file.write(text_content)
        text_file_path = text_file.name

    try:
        # 3. Create BinaryContent objects from the files
        print("Creating BinaryContent from files...")

        # Create BinaryContent from PDF file
        pdf_binary_content = BinaryContent.from_file(file_path=pdf_file_path, mime_type="application/pdf")
        print(f"Created PDF BinaryContent: {pdf_binary_content.mime_type}, can_read: {pdf_binary_content.can_read}")

        # Create BinaryContent from text file
        text_binary_content = BinaryContent.from_file(file_path=text_file_path, mime_type="text/plain")

Review comment (suggestion):
Can we please update to the new pattern of using:

```python
client = OpenAIResponsesAgent.create_client()
```

Then the model is:

```python
from semantic_kernel.connectors.ai.open_ai import OpenAISettings

agent = OpenAIResponsesAgent(
    ai_model_id=OpenAISettings().responses_model_id,
    ...
)
```

Code after:
def create_sample_text_content() -> str:
    """Create sample text content for demonstration purposes.

    Returns:
        str: A sample company policy document in text format.
    """
    return """Company Policy Document - Remote Work Guidelines

This document outlines our company's remote work policies and procedures.

Remote Work Eligibility:
- Full-time employees with at least 6 months tenure
- Managers approval required
- Home office setup must meet security requirements

Work Schedule:
- Core hours: 10 AM - 3 PM local time
- Flexible start/end times outside core hours
- Maximum 3 remote days per week for hybrid roles

Communication Requirements:
- Daily check-ins with team lead
- Weekly video conference participation
- Response time: within 4 hours during business hours

Equipment and Security:
- Company-provided laptop and VPN access
- Secure Wi-Fi connection required
- No public Wi-Fi for work activities

For questions about remote work policies, contact HR at hr@company.com
"""


async def main():
    # 1. Initialize the OpenAI client
    client = OpenAIResponsesAgent.create_client()

    # 2. Prepare file paths and create sample content
    pdf_file_path = os.path.join(
        os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))),
        "resources",
        "file_search",
        "employees.pdf",
    )

    # Create a temporary text file for demonstration purposes
    with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as text_file:
        text_content = create_sample_text_content()
        text_file.write(text_content)
        text_file_path = text_file.name