Agent Setup and Tool Definition

planningChallenge

Prompt Content

Initialize your OpenAI Agent using `OpenAI Agents SDK`. Define a tool named `policy_retriever` that can query the Supabase vector database for relevant policy documents based on a search query. Also, define a tool named `mem0_saver` to persist critical audit findings or contextual information to Mem0 for long-term memory. Your agent should be configured to use `GPT-4o` as its underlying model.

```python
from openai import OpenAI
import os

# Assume Supabase client and Mem0 client are initialized elsewhere
# from supabase_client import get_policy_documents
# from mem0_client import save_to_mem0

client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))

def policy_retriever(query: str):
    # This function would interact with your Supabase Vector DB
    print(f"Searching Supabase for policies related to: {query}")
    # Example: return get_policy_documents(query)
    return ["Policy A: Data retention policies.", "Policy B: Consent guidelines."]

def mem0_saver(key: str, value: str):
    # This function would save information to Mem0
    print(f"Saving to Mem0: {key} = {value}")
    # Example: save_to_mem0(key, value)
    return {"status": "success"}

# Tool definitions for OpenAI Agents SDK
tools = [
    {
        "type": "function",
        "function": {
            "name": "policy_retriever",
            "description": "Retrieves relevant policy documents from a vector database based on a search query.",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {"type": "string", "description": "The search query for policy documents."}
                },
                "required": ["query"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "mem0_saver",
            "description": "Persists key-value information into long-term memory via Mem0.",
            "parameters": {
                "type": "object",
                "properties": {
                    "key": {"type": "string", "description": "The key for the information to save."}, 
                    "value": {"type": "string", "description": "The value (content) to save."
                    }
                },
                "required": ["key", "value"]
            }
        }
    }
]

# Initialize the Assistant
assistant = client.beta.assistants.create(
    name="AI Policy Auditor",
    instructions="You are an expert AI policy auditor. Your task is to analyze documents for compliance with ethical guidelines and regulations. Use the provided tools to retrieve relevant policies and save your findings.",
    model="gpt-4o", # Or a specific model like 'gpt-4o'
    tools=tools
)

print(f"Assistant created with ID: {assistant.id}")
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations