Implementation guides

Step-by-step instructions, copyable templates, and code snippets for each method.

Custom GPTs

No code required

Step-by-Step Setup

  1. Go to chat.openai.com → Explore GPTs → Create
  2. In the Configure tab, fill in Name, Description, and Instructions
  3. Optionally add Conversation Starters for guided UX
  4. Upload Knowledge files (PDFs, docs) for RAG-lite behavior
  5. Enable Actions to connect external APIs via OpenAPI schema
  6. Set visibility: Only me / Anyone with link / Public
  7. Click Save, then share the link with your team

Instructions Template

You are [BotName], a specialized assistant for [Company].

Your role:
- Help users with [specific tasks]
- Answer questions about [domain]
- DO NOT discuss [off-topic areas]

Tone: [professional/friendly/concise]

If the user asks something outside your scope, say:
"I'm specialized in [domain]. For other questions, please contact [[email protected]]."

Retrieval-Augmented Generation (RAG)

Low-code

How RAG Works

1. Ingest: Parse documents → split into chunks → embed each chunk → store in vector DB

2. Retrieve: Embed the user query → find nearest chunks by cosine similarity

3. Generate: Inject retrieved chunks into the system prompt → GPT answers from your content

Supabase SQL Schema (pgvector)

-- Enable required extensions
create extension if not exists vector;
create extension if not exists "uuid-ossp";
create extension if not exists pg_trgm;

-- Documents table
create table documents (
  id uuid primary key default gen_random_uuid(),
  user_id uuid not null references auth.users(id) on delete cascade,
  filename text not null,
  content text not null,
  embedding vector(1536),
  created_at timestamptz default now()
);

-- Hybrid search function (semantic + keyword)
create or replace function hybrid_search(
  query_text text,
  query_embedding vector(1536),
  match_count int,
  p_user_id uuid
) returns table(id uuid, content text, filename text, similarity float)
language sql stable as $$
  select id, content, filename,
    (0.7 * (1 - (embedding <=> query_embedding)) +
     0.3 * ts_rank(to_tsvector('english', content), plainto_tsquery('english', query_text))) as similarity
  from documents
  where user_id = p_user_id
  order by similarity desc
  limit match_count;
$$;

-- RLS: users only see their own documents
alter table documents enable row level security;
create policy "users see own docs" on documents
  for all to authenticated using (auth.uid() = user_id);

Key Decisions

Chunk size

400–600 tokens

Balance context richness vs. noise

Embedding model

text-embedding-3-small

Best cost/quality ratio

Top-k retrieval

3–8 chunks

Enough context, avoid distraction


Tool Calling / Actions

Code required

How Tool Calling Works

1. Define tools: Describe each function name, parameters, and what it does in JSON Schema

2. Model decides: GPT reads the conversation and decides which tool (if any) to call

3. You execute: Your server calls the actual API/DB and returns the result

4. Model responds: GPT uses the tool output to form its final answer

Example Tool Schema

{
  "name": "get_weather",
  "description": "Get the current weather for a city",
  "parameters": {
    "type": "object",
    "properties": {
      "city": {
        "type": "string",
        "description": "The city name"
      }
    },
    "required": ["city"]
  }
}

Fine-Tuning

Advanced

When to Fine-Tune

  • You need a very consistent tone or format across thousands of responses
  • Prompt engineering alone can't achieve the desired behavior
  • You have 50+ high-quality input/output examples
  • Reducing system prompt tokens matters for cost at scale

Training Data Format (JSONL)

{"messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"[Example question]"},{"role":"assistant","content":"[Ideal answer in your desired style]"}]}
{"messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"[Another question]"},{"role":"assistant","content":"[Another ideal answer]"}]}

Minimum: 10 examples. Recommended: 50–100 for meaningful results. Each line is one JSON object.

Fine-Tuning Checklist

  • 1Prepare 50+ JSONL examples with system, user, assistant messages
  • 2Validate JSONL: each line parseable, messages array present
  • 3Upload via OpenAI API: openai.files.create() with purpose='fine-tune'
  • 4Start job: openai.fineTuning.jobs.create({ model: 'gpt-4o-mini', training_file: id })
  • 5Monitor: openai.fineTuning.jobs.retrieve(jobId)
  • 6Use your model: model: 'ft:gpt-4o-mini:org:name:id'
  • 7Evaluate against base model on held-out test cases