Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ai-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
PROJECT_ID: ${{ secrets.SEARCH_SUPABASE_PROJECT_ID }}
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SEARCH_SUPABASE_URL }}
Expand Down
2 changes: 2 additions & 0 deletions apps/database-new/supabase/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ enabled = true
port = 54323
# External URL of the API server that frontend connects to.
api_url = "http://localhost"
# OpenAI API Key to use for Supabase AI in the Supabase Studio.
openai_api_key = "env(OPENAI_API_KEY)"

# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they
# are monitored, and you can view the emails that would have been sent from the web interface.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
NEXT_PUBLIC_SUPABASE_ANON_KEY=

# PRIVATE
OPENAI_KEY=
OPENAI_API_KEY=
SUPABASE_SERVICE_ROLE_KEY=
SEARCH_GITHUB_APP_ID=
SEARCH_GITHUB_APP_INSTALLATION_ID=
Expand Down
6 changes: 6 additions & 0 deletions apps/docs/components/MDX/social_provider_setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ The next step requires a callback URL, which looks like this: `https://<project-
- Click on the `Authentication` icon in the left sidebar
- Click on [`Providers`](https://supabase.com/dashboard/project/_/auth/providers) under the Configuration section
- Click on **{props.provider}** from the accordion list to expand and you'll find your **Callback URL**, you can click `Copy` to copy it to the clipboard

<Admonition type="note">

For testing OAuth locally with the Supabase CLI please see the [local development docs](/docs/guides/cli/local-development#use-auth-locally).

</Admonition>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Now we can use the [Headless Vector Search](https://github.com/supabase/headless
1. Clone the repo to your local machine: `git clone git@github.com:supabase/headless-vector-search.git`
2. Link the repo to your remote project: `supabase link --project-ref XXX`
3. Apply the database migrations: `supabase db push`
4. Set your OpenAI key as a secret: `supabase secrets set OPENAI_KEY=sk-xxx`
4. Set your OpenAI key as a secret: `supabase secrets set OPENAI_API_KEY=sk-xxx`
5. Deploy the Edge Functions: `supabase functions deploy --no-verify-jwt`
6. Expose `docs` schema via API in Supabase Dashboard [settings](https://supabase.com/dashboard/project/_/settings/api) > `API Settings` > `Exposed schemas`

Expand All @@ -66,11 +66,11 @@ jobs:
with:
supabase-url: 'https://your-project-ref.supabase.co' # Update this to your project URL.
supabase-service-role-key: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
openai-key: ${{ secrets.OPENAI_KEY }}
openai-key: ${{ secrets.OPENAI_API_KEY }}
docs-root-path: 'docs' # the path to the root of your md(x) files
```

Make sure to choose the latest version, and set your `SUPABASE_SERVICE_ROLE_KEY` and `OPENAI_KEY` as repository secrets in your repo settings (settings > secrets > actions).
Make sure to choose the latest version, and set your `SUPABASE_SERVICE_ROLE_KEY` and `OPENAI_API_KEY` as repository secrets in your repo settings (settings > secrets > actions).

### Add a search interface

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ With our database set up, we need to process and store all `.mdx` files in the `
SUPABASE_SERVICE_ROLE_KEY=

# Get your key at https://platform.openai.com/account/api-keys
OPENAI_KEY=
OPENAI_API_KEY=
```

</StepHikeCompact.Code>
Expand Down
3 changes: 1 addition & 2 deletions apps/docs/content/guides/database/tables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ You must define the "data type" when you create a column.

### Data types

Every column is a predefined type. PostgreSQL provides many [default types](https://www.postgresql.org/docs/current/datatype.html), and you can even design your own (or use extensions)
if the default types don't fit your needs. You can use any data type that Postgres supports via the SQL editor. We only support a subset of these in the Table Editor in an effort to keep the experience simple for people with less experience with databases.
Every column is a predefined type. PostgreSQL provides many [default types](https://www.postgresql.org/docs/current/datatype.html), and you can even design your own (or use extensions) if the default types don't fit your needs. You can use any data type that Postgres supports via the SQL editor. We only support a subset of these in the Table Editor in an effort to keep the experience simple for people with less experience with databases.

<details>
<summary>Show/Hide default data types</summary>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/guides/functions/ai-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Inference via larger models is supported via [Ollama](https://ollama.com/). In t

### Running locally

1. Install Ollama and pull the Mistral model
1. [Install Ollama](https://github.com/ollama/ollama?tab=readme-ov-file#ollama) and pull the Mistral model

```
ollama pull mistral
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/api/ai/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import OpenAI from 'openai'

export const runtime = 'edge'

const openAiKey = process.env.OPENAI_KEY
const openAiKey = process.env.OPENAI_API_KEY
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL as string
const supabaseServiceKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string

export default async function handler(req: NextRequest) {
if (!openAiKey) {
return new Response(
JSON.stringify({
error: 'No OPENAI_KEY set. Create this environment variable to use AI features.',
error: 'No OPENAI_API_KEY set. Create this environment variable to use AI features.',
}),
{
status: 500,
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/scripts/search/generate-embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function generateEmbeddings() {
const requiredEnvVars = [
'NEXT_PUBLIC_SUPABASE_URL',
'SUPABASE_SERVICE_ROLE_KEY',
'OPENAI_KEY',
'OPENAI_API_KEY',
'NEXT_PUBLIC_MISC_USE_URL',
'NEXT_PUBLIC_MISC_USE_ANON_KEY',
'SEARCH_GITHUB_APP_ID',
Expand Down Expand Up @@ -162,10 +162,11 @@ async function generateEmbeddings() {
console.log(`[${path}] Adding ${sections.length} page sections (with embeddings)`)
for (const { slug, heading, content } of sections) {
// OpenAI recommends replacing newlines with spaces for best results (specific to embeddings)
// force a redeploy
const input = content.replace(/\n/g, ' ')

try {
const openai = new OpenAI({ apiKey: process.env.OPENAI_KEY })
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })

const embeddingResponse = await openai.embeddings.create({
model: 'text-embedding-ada-002',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,24 @@ const PROVIDER_EMAIL = {
type: 'boolean',
},
MAILER_OTP_EXP: {
title: 'Mailer OTP Expiration',
title: 'Email OTP Expiration',
type: 'number',
description: 'Duration before an email otp / link expires.',
units: 'seconds',
},
PASSWORD_MIN_LENGTH: {
title: 'Min password length',
description: 'Users will not be able to use a password shorter than this.',
MAILER_OTP_LENGTH: {
title: 'Email OTP Length',
type: 'number',
description: 'Number of digits in the email OTP',
units: 'number',
},
},
validationSchema: object().shape({
PASSWORD_MIN_LENGTH: number()
.required('A password is required.')
.min(6, 'Password length must be at least 6 characters long'),
MAILER_OTP_EXP: number()
.min(0, 'Must be more than 0')
.max(86400, 'Must be no more than 86400')
.required('This is required'),
MAILER_OTP_LENGTH: number().min(6, 'Must be at least 6').max(10, 'Must be no more than 10'),
}),
misc: {
iconKey: 'email-icon2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ export const CreateFunctionHeader = ({
setAssistantVisible: (v: boolean) => void
}) => {
return (
<SheetHeader
className={cn(
selectedFunction !== undefined ? 'pt-3 pb-0' : 'py-3',
'flex flex-row justify-between items-center border-b-0'
)}
>
<SheetHeader className="py-3 flex flex-row justify-between items-center border-b-0">
<div className="flex flex-row gap-3 items-center max-w-[75%]">
<SheetClose
className={cn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ import { isEmpty } from 'lodash'
export function convertArgumentTypes(value: string) {
const items = value?.split(',')
if (isEmpty(value) || !items || items?.length == 0) return { value: [] }
const temp = items.map((x) => {
const str = x.trim()
const space = str.indexOf(' ')
const name = str.slice(0, space !== 1 ? space : 0)
const type = str.slice(space + 1)
return { name, type }
})
const temp = items
.map((x) => {
const str = x.trim()
const splitted = str.split(' ')
if (splitted.length === 2) {
return { name: splitted[0], type: splitted[1] }
}
if (splitted.length === 1) {
return { name: splitted[0], type: splitted[0] }
}
console.error('Error while trying to parse function arguments', value)
})
.filter(Boolean) as { name: string; type: string }[]
return { value: temp }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ const TableList = ({
<p>{x.name}</p>
)}
</Table.td>
<Table.td className="hidden max-w-sm truncate lg:table-cell break-all whitespace-normal">
<Table.td className="hidden lg:table-cell ">
{x.comment !== null ? (
<p title={x.comment}>{x.comment}</p>
<span className="lg:max-w-48 truncate inline-block" title={x.comment}>
{x.comment}
</span>
) : (
<p className="text-border-stronger">No description</p>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,35 @@ const Results = ({ id, rows }: { id: string; rows: readonly any[] }) => {
return <div className="flex h-full items-center justify-center font-mono text-xs">{name}</div>
}

const columns: CalculatedColumn<any>[] = Object.keys(rows?.[0] ?? []).map((key, idx) => ({
idx,
key,
name: key,
resizable: true,
parent: undefined,
level: 0,
width: 120,
minWidth: 120,
maxWidth: undefined,
draggable: false,
frozen: false,
sortable: false,
isLastFrozenColumn: false,
renderCell: ({ row }: any) => formatter(key, row),
renderHeaderCell: () => columnRender(key),
}))
const EST_CHAR_WIDTH = 8.25
const MIN_COLUMN_WIDTH = 100
const MAX_COLUMN_WIDTH = 500

const columns: CalculatedColumn<any>[] = Object.keys(rows?.[0] ?? []).map((key, idx) => {
const maxColumnValueLength = Math.max(...rows.map((row) => String(row[key]).length))
const columnWidth = Math.max(
Math.min(maxColumnValueLength * EST_CHAR_WIDTH, MAX_COLUMN_WIDTH),
MIN_COLUMN_WIDTH
)

return {
idx,
key,
name: key,
resizable: true,
parent: undefined,
level: 0,
width: columnWidth,
minWidth: MIN_COLUMN_WIDTH,
maxWidth: undefined,
draggable: false,
frozen: false,
sortable: false,
isLastFrozenColumn: false,
renderCell: ({ row }: any) => formatter(key, row),
renderHeaderCell: () => columnRender(key),
}
})

function onSelectedCellChange(position: any) {
setCellPosition(position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useQueryClient } from '@tanstack/react-query'
import { useParams } from 'common'
import toast from 'react-hot-toast'

import { useContentQuery } from 'data/content/content-query'
import { useContentUpsertMutation } from 'data/content/content-upsert-mutation'
import { contentKeys } from 'data/content/keys'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
Expand Down Expand Up @@ -38,7 +37,6 @@ const UtilityPanel = ({
}: UtilityPanelProps) => {
const snap = useSqlEditorStateSnapshot()
const { ref } = useParams()
const { data } = useContentQuery(ref)
const snippet = snap.snippets[id]?.snippet

const queryKeys = contentKeys.list(ref)
Expand Down
Loading