Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORM docs added to guides. #8351

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
3bb1448
Add `edb::env-switcher`, `edb::split-section` and `edb::split-point` …
jaclarke Feb 4, 2025
fe6e198
Add index directives for keywords, symbols, sql equivalents, etc. in …
jaclarke Jan 30, 2025
79d9549
Add docs preview deploys (#8289)
jaclarke Feb 4, 2025
d9f0631
Fix deploy failed message
jaclarke Feb 4, 2025
40a0f09
Fix indentation in string docs
jaclarke Feb 4, 2025
b8acef2
Allow any type of content on right side of split pages
jaclarke Feb 5, 2025
0619bd9
Move JS/Python/Go docs into the core
1st1 Feb 7, 2025
df9985b
Update docs site deployment branch
jaclarke Feb 8, 2025
381feec
Return errors from script if deployment fails
jaclarke Feb 8, 2025
7ec9113
docs: Move guides/cloud -> cloud
1st1 Feb 13, 2025
57da0af
Implement basic Sphinx subsitution |Gel| -> node to custom render
1st1 Feb 14, 2025
90b0bb3
Replace EdgeDB->Gel in all :edb-alt-title:
1st1 Feb 14, 2025
d779fa9
Fix docs/tests to go green
1st1 Feb 14, 2025
83efcee
Get rid of trailing whitespace for good
1st1 Feb 14, 2025
aa6a6a7
Get rid of weird unicode ' symbols
1st1 Feb 14, 2025
cd8076d
Massive (yet careful) rename EdgeDB -> Gel
1st1 Feb 14, 2025
87a1c31
Rename ``.esdl`` -> |.gel|
1st1 Feb 14, 2025
ec61dad
Rename ``edgedb.toml`` to |gel.toml|
1st1 Feb 14, 2025
8b5b2b3
``edgedb`` -> |gelcmd|
1st1 Feb 14, 2025
a681be6
Kill links to (temporarily) Easy EdgeDB and Live Tutorial
1st1 Feb 14, 2025
10968b9
Make doc test stricter; fix bug
1st1 Feb 14, 2025
696acdd
Add a custom role for inline '$ gel ..' commands
1st1 Feb 14, 2025
446e876
Start using :gelcmd:
1st1 Feb 14, 2025
2b2f88d
Fix what's new 6
1st1 Feb 14, 2025
f6738c6
Use :gelcmd: in more places
1st1 Feb 14, 2025
98be319
Replacing some ``edgedb ...`` with :gelcmd:...
1st1 Feb 14, 2025
8e14100
Update some guides
1st1 Feb 14, 2025
63deaaf
Another batch of updates
1st1 Feb 14, 2025
554d601
Another round of EdgeDB -> |Gel|
1st1 Feb 14, 2025
9f0c952
Enable |Gel's| substitution
1st1 Feb 14, 2025
87ea9bd
Gel's -> |Gel's|
1st1 Feb 14, 2025
4679a9b
More renames
1st1 Feb 15, 2025
13f1c72
'gel watch'
1st1 Feb 15, 2025
6a60a84
More edgedb commands -> gel
1st1 Feb 15, 2025
1667f1d
More changes
1st1 Feb 15, 2025
00ddfda
edgedb> -> gel>
1st1 Feb 15, 2025
2671879
edgedb error: -> gel error:
1st1 Feb 15, 2025
7ca895a
Drop Phoenix tutorial (per nik's suggestion)
1st1 Feb 15, 2025
bde0104
Start renaming references
1st1 Feb 15, 2025
98641e0
More refs
1st1 Feb 15, 2025
d8d3f0a
an |Gel| -> a |Gel|
1st1 Feb 15, 2025
d915e54
"$ edgedb" -> "$ gel"
1st1 Feb 15, 2025
46755a1
More renames
1st1 Feb 15, 2025
6000fb5
@edgedb -> @gel
1st1 Feb 15, 2025
d124194
Fix another ref name
1st1 Feb 15, 2025
d4501bf
edgedb-auth-token, edgedb-pkce-verifier -> gel
1st1 Feb 15, 2025
c4d6f06
More renames
1st1 Feb 15, 2025
b4999d1
"$ edgedb" -> "$ gel"
1st1 Feb 15, 2025
1e09d11
Handle .esdl transition
1st1 Feb 15, 2025
e07e9f7
More changes
1st1 Feb 15, 2025
3299349
github link renames
1st1 Feb 15, 2025
725020e
Another batch of renames
1st1 Feb 15, 2025
8981b7c
More renames
1st1 Feb 15, 2025
399f6b2
More renames
1st1 Feb 15, 2025
6912bf1
More renames
1st1 Feb 15, 2025
72733d0
More renames -- almost there
1st1 Feb 15, 2025
a8e0949
More renames
1st1 Feb 15, 2025
db9d8ee
Kill Java
1st1 Feb 15, 2025
b58e9ca
Rename X-Gel-User back to X-EdgeDB-User
1st1 Feb 15, 2025
a2357b5
Bulk-rename ``EDGEDB_NAME`` to :gelenv:`NAME`
1st1 Feb 15, 2025
9f77ed7
More inline ENV vars renames
1st1 Feb 15, 2025
cd62bc2
More environment variables renamed
1st1 Feb 15, 2025
393a049
More env var renames
1st1 Feb 15, 2025
e7bf1a8
Remaining env vars renamed
1st1 Feb 15, 2025
7b5398f
Rename CLI rest filed from edgedb_* to gel_*
1st1 Feb 15, 2025
5e87c4e
Add redirects file
1st1 Feb 15, 2025
3119021
Rename edgedb_toml.rst to gel_toml.rst
1st1 Feb 15, 2025
f07de4d
Update CLI curl URL to new scheme
1st1 Feb 15, 2025
6c6e50a
Commit forgotten new gel_toml.rst
1st1 Feb 15, 2025
b1121dc
Kill versionchanged:_default versioning
1st1 Feb 15, 2025
6f6629b
Kill debug
1st1 Feb 15, 2025
ffc182e
Drop all :version-lt: snippets
1st1 Feb 15, 2025
05d05e0
Some branches<>databases footwork
1st1 Feb 15, 2025
5187a6b
Cleanup version_added < 5
1st1 Feb 15, 2025
5631250
Kill :versionreplace:
1st1 Feb 19, 2025
511454a
Refactor Indexes
1st1 Feb 15, 2025
b62a9dc
Refactor functions
1st1 Feb 15, 2025
5c60f4d
Refactor modules
1st1 Feb 15, 2025
6d7f493
Unify triggers
1st1 Feb 15, 2025
0389a3e
Merge constraints
1st1 Feb 16, 2025
e44afc2
Merge annotations
1st1 Feb 16, 2025
1920531
Merge links
1st1 Feb 16, 2025
e0574ee
Add a clarification about DDL commands
1st1 Feb 16, 2025
517d0c7
Merge extensions
1st1 Feb 16, 2025
08d6670
Merge access policies
1st1 Feb 16, 2025
3597114
Fix up links. OK, I'm not trusting LLMs anymore.
1st1 Feb 17, 2025
5653abc
Fix up constraints
1st1 Feb 17, 2025
967fa4d
Refactor aliases
1st1 Feb 17, 2025
dc15c45
Merge mutation rewrites
1st1 Feb 19, 2025
d3800a3
Upgrade and merge the "Future behavior" section
1st1 Feb 19, 2025
2fec4b4
Kill 3.0 syntax from SDL/index (it's covered in what's new)
1st1 Feb 19, 2025
af6f9d8
Merge globals
1st1 Feb 19, 2025
f23a9d6
Merge primitives/scalars
1st1 Feb 19, 2025
121ebf6
Merge objects
1st1 Feb 19, 2025
c086931
Quickstart tutorial with Next.js (#8269)
scotttrinh Feb 19, 2025
6946204
ORM docs added to guides.
vpetrovykh Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
191 changes: 191 additions & 0 deletions .github/scripts/docs/preview-deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
const DOCS_SITE_REPO = {
org: "edgedb",
repo: "edgedb.com",
ref: "new-new-docs",
};

module.exports = async ({ github, context }) => {
const { VERCEL_TOKEN, VERCEL_TEAM_ID } = process.env;

if (!VERCEL_TOKEN || !VERCEL_TEAM_ID) {
throw new Error(
`cannot run docs preview deploy workflow, ` +
`VERCEL_TOKEN or VERCEL_TEAM_ID secrets are missing`
);
}

const prBranch = context.payload.pull_request.head.ref;
const commitSHA = context.payload.pull_request.head.sha;
const shortCommitSHA = commitSHA.slice(0, 8);

const existingComments = (
await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
).data;

const commentHeader = `### Docs preview deploy\n`;
let commentMessage = commentHeader;

let updateComment = existingComments.find(
(c) =>
c.performed_via_github_app?.slug === "github-actions" &&
c.body?.startsWith(commentHeader)
);

let deploymentError = null;
let deployment;
try {
deployment = await vercelFetch("https://api.vercel.com/v13/deployments", {
name: "edgedb-docs",
gitSource: {
type: "github",
...DOCS_SITE_REPO,
},
projectSettings: {
buildCommand: `EDGEDB_REPO_BRANCH=${prBranch} EDGEDB_REPO_SHA=${commitSHA} yarn vercel-build`,
},
});

commentMessage += `\n🔄 Deploying docs preview for commit ${shortCommitSHA}:\n\n<https://${deployment.url}>`;
} catch (e) {
deploymentError = e;
commentMessage += `\n❌ Failed to deploy docs preview for commit ${shortCommitSHA}:\n\n\`\`\`\n${e.message}\n\`\`\``;
}

commentMessage += `\n\n(Last updated: ${formatDatetime(new Date())})`;

if (updateComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: updateComment.id,
body: commentMessage,
});
} else {
updateComment = (
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentMessage,
})
).data;
}

if (deploymentError) {
throw new Error(`Docs preview deployment failed: ${e.message}`);
}

let i = 0;
while (i < 40) {
await sleep(15_000);
i++;

const status = (
await vercelFetch(
`https://api.vercel.com/v13/deployments/${deployment.id}`
)
).status;

const latestComment = await github.rest.issues.getComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: updateComment.id,
});

if (!latestComment.data.body.includes(shortCommitSHA)) {
console.log("Skipping further updates, new deployment has started");
return;
}

if (status === "READY" || status === "ERROR" || status === "CANCELED") {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: updateComment.id,
body: `${commentHeader}${
status === "READY"
? `\n✅ Successfully deployed docs preview for commit ${shortCommitSHA}:`
: `\n❌ Docs preview deployment ${
status === "CANCELED" ? "was canceled" : "failed"
} for commit ${shortCommitSHA}:`
}\n\n<https://${deployment.url}>\n\n(Last updated: ${formatDatetime(
new Date()
)})`,
});
if (status !== "READY") {
throw new Error(
`Docs preview deployment failed with status ${status}: https://${deployment.url}`
);
}
return;
}
}

await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: updateComment.id,
body: `${commentHeader}
❌ Timed out waiting for deployment status to succeed or fail for commit ${shortCommitSHA}:\n\n<https://${
deployment.url
}>\n\n(Last updated: ${formatDatetime(new Date())})`,
});
throw new Error("Timed out waiting for deployment status to succeed or fail");
};

async function vercelFetch(url, body) {
const { VERCEL_TOKEN, VERCEL_TEAM_ID } = process.env;
const _url = new URL(url);
url = `${_url.origin}${_url.pathname}?${new URLSearchParams({
teamId: VERCEL_TEAM_ID,
})}`;

let res;
try {
res = await fetch(url, {
body: body ? JSON.stringify(body) : undefined,
headers: {
Authorization: `Bearer ${VERCEL_TOKEN}`,
"Content-Type": body ? "application/json" : undefined,
},
method: body ? "post" : "get",
});
} catch (e) {
throw new Error(`vercel api request failed: ${e}`);
}

if (res.ok) {
return await res.json();
} else {
let body;
try {
body = await res.text();
} catch (e) {
// ignore
}
throw new Error(
`vercel api request failed: ${res.status} ${res.statusText}, ${body}`
);
}
}

function formatDatetime(date) {
return date.toLocaleString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
hourCycle: "h24",
timeZoneName: "short",
});
}

function sleep(milliseconds) {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}
21 changes: 21 additions & 0 deletions .github/workflows/docs-preview-deploy.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 23 additions & 23 deletions docs/ai/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ AI
python
reference

:edb-alt-title: Using EdgeDB AI
:edb-alt-title: Using Gel AI

EdgeDB AI allows you to ship AI-enabled apps with practically no effort. It
|Gel| AI allows you to ship AI-enabled apps with practically no effort. It
automatically generates embeddings for your data. Works with OpenAI, Mistral
AI, Anthropic, and any other provider with a compatible API.


Enable extension in your schema
===============================

AI is an EdgeDB extension. To enable it, you will need to add the extension
to your apps schema:
AI is a |Gel| extension. To enable it, you will need to add the extension
to your app's schema:

.. code-block:: sdl

Expand All @@ -34,12 +34,12 @@ Extension configuration
=======================

The AI extension may be configured via our UI or via EdgeQL. To use the
built-in UI, access it by running ``edgedb ui``. If you have the extension
built-in UI, access it by running :gelcmd:`ui`. If you have the extension
enabled in your schema as shown above and have migrated that schema change, you
will see the "AI Admin" icon in the left-hand toolbar.

.. image:: images/ui-ai.png
:alt: The EdgeDB local development server UI highlighting the AI admin
:alt: The Gel local development server UI highlighting the AI admin
icon in the left-hand toolbar. The icon is two stars, one larger and
one smaller, the smaller being a light pink color and the larger
being a light blue when selected.
Expand Down Expand Up @@ -69,7 +69,7 @@ Provider" button, selecting the appropriate API, and pasting your key in the
"Secret" field.

.. image:: images/ui-ai-add-provider.png
:alt: The "Add Provider" form of the EdgeDB local development server UI.
:alt: The "Add Provider" form of the Gel local development server UI.
On the left, the sidebar navigation for the view showing Playground,
Prompts, and Providers options, with Provider selected (indicated
with a purple border on the left). The main content area shows a
Expand All @@ -85,7 +85,7 @@ You may alternatively configure a provider via EdgeQL:

.. code-block:: edgeql

configure current database
configure current branch
insert ext::ai::OpenAIProviderConfig {
secret := 'sk-....',
};
Expand All @@ -104,13 +104,13 @@ We have provider config types for each of the three supported APIs:
Usage
=====

Using EdgeDB AI requires some changes to your schema.
Using |Gel| AI requires some changes to your schema.


Add an index
------------

To start using EdgeDB AI on a type, create an index:
To start using |Gel| AI on a type, create an index:

.. code-block:: sdl-diff

Expand All @@ -124,8 +124,8 @@ To start using EdgeDB AI on a type, create an index:

In this example, we have added an AI index on the ``Astronomy`` type's
``content`` property using the ``text-embedding-3-small`` model. Once you have
the index in your schema, :ref:`create <ref_cli_edgedb_migration_create>` and
:ref:`apply <ref_cli_edgedb_migration_apply>` your migration, and you're ready
the index in your schema, :ref:`create <ref_cli_gel_migration_create>` and
:ref:`apply <ref_cli_gel_migration_apply>` your migration, and you're ready
to start running queries!

.. note::
Expand Down Expand Up @@ -154,13 +154,13 @@ can define an AI index on an expression:
.. note:: When AI indexes aren't working…

If you find your queries are not returning the expected results, try
inspecting your instance logs. On an EdgeDB Cloud instance, use the "Logs"
inspecting your instance logs. On a |Gel| Cloud instance, use the "Logs"
tab in your instance dashboard. On local or :ref:`CLI-linked remote
instances <ref_cli_edgedb_instance_link>`, use ``edgedb instance logs -I
<instance-name>``. You may find the problem there.
instances <ref_cli_gel_instance_link>`, use :gelcmd:`instance logs -I
<instance-name>`. You may find the problem there.

Providers impose rate limits on their APIs which can often be the source of
AI index problems. If index creation hits a rate limit, EdgeDB will wait
AI index problems. If index creation hits a rate limit, |Gel| will wait
the ``indexer_naptime`` (see the docs on :ref:`ext::ai configuration
<ref_ai_reference_config>`) and resume index creation.

Expand Down Expand Up @@ -209,13 +209,13 @@ Use RAG via HTTP
----------------

By making an HTTP request to
``https://<edgedb-host>:<port>/branch/<branch-name>/ai/rag``, you can generate
``https://<gel-host>:<port>/branch/<branch-name>/ai/rag``, you can generate
text via the generative AI API of your choice within the context of a type with
a deferred embedding index.

.. note::

Making HTTP requests to EdgeDB requires :ref:`authentication
Making HTTP requests to |Gel| requires :ref:`authentication
<ref_http_auth>`.

.. code-block:: bash
Expand All @@ -224,7 +224,7 @@ a deferred embedding index.
"query": "What color is the sky on Mars?",
"model": "gpt-4-turbo-preview",
"context": {"query":"select Astronomy"}
}' https://<edgedb-host>:<port>/branch/<branch-name>/ai/rag
}' https://<gel-host>:<port>/branch/<branch-name>/ai/rag
{"response": "The sky on Mars is red."}

Since LLMs are often slow, it may be useful to stream the response. To do this,
Expand All @@ -243,14 +243,14 @@ add ``"stream": true`` to your request JSON.
Use RAG via JavaScript
----------------------

``@edgedb/ai`` offers a convenient wrapper around ``ext::ai``. Install it with
``npm install @edgedb/ai`` (or via your package manager of choice) and
``@gel/ai`` offers a convenient wrapper around ``ext::ai``. Install it with
``npm install @gel/ai`` (or via your package manager of choice) and
implement it like this example:

.. code-block:: typescript

import { createClient } from "edgedb";
import { createAI } from "@edgedb/ai";
import { createClient } from "gel";
import { createAI } from "@gel/ai";

const client = createClient();

Expand Down
Loading
Loading