@@ -399,30 +399,42 @@ answer.
399399
400400However, right now it's hardly better than Google itself, since you have to
401401basically start over every time you want to refine the query. To enable more
402- organic multi-turn interaction we need to add chat history, and in order to
403- enable gradual query refinement, we need to infer the query from the context of
404- the entire conversation.
402+ organic multi-turn interaction we need to add chat history and infer the query
403+ from the context of the entire conversation.
405404
406- Let 's do both using Gel.
405+ Now 's a good time to introduce Gel.
407406
408- To get started with Gel, first we need to initialize the project using the
409- command line interface.
407+ In case you need installation instructions, take a look at :ref: `Quickstart UI
408+ <_ref_quickstart>`. Once Gel CLI is present in your system, initialize the
409+ project like this:
410410
411411.. code-block :: bash
412412 $ gel project init --non-interactive
413413
414- Defining the schema
415- -------------------
414+ This command is going to put some project scaffolding inside our app, spin up a
415+ local instace of Gel, and then link the two together. From now on, all
416+ Gel-related things that happen inside our project folder are going to be
417+ automatically run on the correct databaser instance, no need to worry about
418+ connection incantations.
416419
417- .. note ::
418- add links to documentation
419420
420- The database schema in Gel is defined declaratively. The init command actually
421- created a stub for it in `dbchema/default.esdl `, that we're going to extend now
422- with our types.
421+ Defining the schema
422+ -------------------
423423
424- We obviously want to keep track of messages, so that should be there. By
425- convention established in the LLM space, each message is going to have a role.
424+ The database :ref: `schema <_ref_datamodel_index >` in Gel is defined
425+ declaratively. The :ref: `gel project init <_ref_cli_edgedb_project_init >`
426+ command has created a file called `dbchema/default.esdl `, which we're going to
427+ use to define our types.
428+
429+ We obviously want to keep track of messages, so we need to represent those in
430+ the schema. By convention established in the LLM space, each message is going to
431+ have a role in addition to the message content itself. We can also get Gel to
432+ automatically keep track of message's creation time by adding a property callled
433+ `timestamp ` and setting its :ref: `default value <_ref_datamodel_props >` to the
434+ output of the :ref: `datetime_current() <_ref_std_datetime >` function. Finally,
435+ LLM messages in our searchbot have souce URLs associated with them. Let's keep
436+ track of those too, by adding a :ref: `multi-link property
437+ <_ref_datamodel_links>`.
426438
427439.. code-block :: sdl
428440 type Message {
@@ -434,14 +446,19 @@ convention established in the LLM space, each message is going to have a role.
434446 multi sources: str;
435447 }
436448
437- Messages are grouped together into a chat, so let's add that, too.
449+ Messages are grouped together into a chat, so let's add that entity to our
450+ schema too.
438451
439452.. code-block :: sdl
440453 type Chat {
441454 multi messages: Message;
442455 }
443456
444- And chats all belong to a certain user, making up their chat history:
457+ And chats all belong to a certain user, making up their chat history. One other
458+ thing we'd like to keep track of about our users is their username, and it would
459+ make sense for us to make sure that it's unique by using an `excusive `
460+ :ref: `constraint <_ref_datamodel_constraints >`.
461+
445462
446463.. code-block :: sdl
447464 type User {
@@ -451,11 +468,11 @@ And chats all belong to a certain user, making up their chat history:
451468 multi chats: Chat;
452469 }
453470
454- We're going to keep our schema super simple for now. Some time down the road,
455- you might wanna leverage Gel's powerful capabilities in order to add auth or AI
456- features. But we're gonna come back to that.
471+ We're going to keep our schema super simple. One cool thing about Gel is that it
472+ will enable us to easily implement advanced features such as authentification or
473+ AI down the road, but we're gonna come back to that later .
457474
458- This is the entire schema we came up with:
475+ For now, this is the entire schema we came up with:
459476
460477.. code-block :: sdl
461478 module default {
@@ -480,10 +497,9 @@ This is the entire schema we came up with:
480497 }
481498 }
482499
483- For now, let's migrate to our new schema and proceed to writing some queries.
484-
485- .. note ::
486- add links to documentation
500+ Let's use the :ref: `gel migration create <_ref_cli_edgedb_migration_create >` CLI
501+ command, followed by :ref: `gel migrate <_ref_cli_edgedb_migrate >` in order to
502+ migrate to our new schema and proceed to writing some queries.
487503
488504.. code-block :: sdl
489505 $ gel migration create
@@ -492,7 +508,9 @@ For now, let's migrate to our new schema and proceed to writing some queries.
492508 $ gel migrate
493509
494510 Now that our schema is applied, let's quickly populate the database with some
495- fake data in order to be able to test the queries.
511+ fake data in order to be able to test the queries. We're going to explore
512+ writing queries in a bit, but for now you can just run the following command in
513+ the shell:
496514
497515.. code-block :: bash
498516 $ mkdir app/sample_data && cat << 'EOF ' > app/sample_data/inserts.edgeql
@@ -573,8 +591,8 @@ fake data in order to be able to test the queries.
573591 };
574592 EOF
575593
576- Make sure that the `app/sample_data/inserts.edgeql` popped up in your file
577- system, then run :
594+ This created an `app/sample_data/inserts.edgeql` file, which we can now execute
595+ using the CLI like this :
578596
579597.. code-block:: bash
580598 $ gel query -f app/sample_data/inserts.edgeql
@@ -584,7 +602,9 @@ system, then run:
584602 {"id": "862de904-de39-11ef-9713-4fab09220c4a"}
585603 {"id": "862e400c-de39-11ef-9713-2f81f2b67013"}
586604
587- That's it! Now there's stuff in the database. Let's verify it by running:
605+ The :ref:`gel query <_ref_cli_edgedb_query>` command is one of many ways we can
606+ execute a query in Gel. Now that we've done it, there's stuff in the database.
607+ Let's verify it by running:
588608
589609.. code-block:: bash
590610 $ gel query "select User { name };"
0 commit comments