{"id":"e7b6a6f3-0415-46cf-9330-2e4fc13ca582","name":"Implement RAG","tests":[{"id":"c8a9e839-f7aa-4600-b9c7-8f501aacd319","test_prompt":"This is an application for keeping track of Komi-san's friends. I would like you to add RAG functionality in it.","expected_outcome":null,"initial_state":[{"id":"ea7a73f7-be49-4eb4-8ab6-c9e9a591014e","url":"dbschema/default.gel","code":"module default {\n type Friend {\n required name: str {\n constraint exclusive;\n };\n\n summary: str; # A brief description of personality and role\n relationship_to_komi: str; # Relationship with Komi\n defining_trait: str; # Primary character trait or quirk\n }\n}","language":"gel"},{"id":"73285782-a90f-4c88-a078-1a617290f271","url":null,"code":"insert Friend {\n name := 'Tadano Hitohito',\n summary := 'An extremely average high school boy with a remarkable ability to read the atmosphere and understand others\\' feelings, especially Komi\\'s.',\n relationship_to_komi := 'First friend and love interest',\n defining_trait := 'Perceptiveness',\n};\n\ninsert Friend {\n name := 'Osana Najimi',\n summary := 'An extremely outgoing person who claims to have been everyone\\'s childhood friend. Gender: Najimi.',\n relationship_to_komi := 'Second friend and social catalyst',\n defining_trait := 'Universal childhood friend',\n};\n\ninsert Friend {\n name := 'Yamai Ren',\n summary := 'An intense and sometimes obsessive classmate who is completely infatuated with Komi.',\n relationship_to_komi := 'Self-proclaimed guardian and admirer',\n defining_trait := 'Obsessive devotion',\n};\n\ninsert Friend {\n name := 'Katai Makoto',\n summary := 'A intimidating-looking but shy student who shares many communication problems with Komi.',\n relationship_to_komi := 'Fellow communication-challenged friend',\n defining_trait := 'Scary appearance but gentle nature',\n};\n\ninsert Friend {\n name := 'Nakanaka Omoharu',\n summary := 'A self-proclaimed wielder of dark powers who acts like an anime character and is actually just a regular gaming enthusiast.',\n relationship_to_komi := 'Gaming buddy and chuunibyou friend',\n defining_trait := 'Chuunibyou tendencies',\n};","language":"edgeql"}]}],"examples":[{"id":"2413a27f-772c-42b7-b09e-614c9d6e4bda","name":"Enable AI extension","description":"Steps to enable and configure Gel's AI extension that automatically manages vector embeddings.","instructions":"1. Enable the extension in the schema and do a migration:\n```gel\n# outside of module definition\nusing extension ai;\n```\n2. Prompt the user to configure the API key:\n```edgeql\nconfigure current database\ninsert ext::ai::OpenAIProviderConfig {\n secret := 'sk-....',\n};\n```\n3. Add `ext::ai::index` to the type (see specific example for details)\n4. Use the `ext::ai::search` function in queries (also see specific example for details)","code":[]},{"id":"60cff72d-afa3-4eb5-b93e-c6359dc44071","name":"Schema template for RAG","description":"Example schema that uses Gel's AI extension to automatically generate vector embeddings.\n","instructions":null,"code":[{"id":"35fa00b6-bbd3-4329-97d7-7cda0f947c27","url":null,"code":"module default {\n type Type1 {\n str_property_1: str;\n str_property_2: str;\n\n deferred index ext::ai::index(embedding_model := 'text-embedding-3-small')\n on (\n .str_property_1 ++ ' ' ++ .str_property_2 # any EdgeQL expression that returns a string\n );\n }\n} ","language":"gel"}]},{"id":"61885259-a0f2-4858-9e73-dc04bb22186f","name":"Python vector search query","description":"Example Python code that uses Gel AI Python binding to perform vector similarity search for a text query.","instructions":null,"code":[{"id":"f02d6e2f-8b10-4137-a8ff-3322126028b0","url":null,"code":"import gel\nimport gel.ai\n\ngel_client = gel.create_client()\ngel_ai = gel.ai.create_rag_client(client, model=\"gpt-4o-mini\") # need to specify a language model even when now using it\n\ntext = \"test query\"\nvector = gel_ai.generate_embeddings(\n text,\n model=\"text-embedding-3-small\",\n)\n\ngel_client.query(\n \"select ext::ai::search(Type1, <array<float32>>$embedding_vector\",\n embedding_vector=vector,\n)","language":"python"}]}]}
{"id":"897d8d23-bc01-455a-8b68-1045e79fd408","name":"Database setup","tests":[{"id":"9ff3f46e-9e5d-405a-9899-75ebda75d9a0","test_prompt":"Please setup a database for me.","expected_outcome":"Gel project must be initialized.\nIf this is a Python project, the requirements.txt must be updated to include `gel` >= to the lastest version.\nThere should not be any unrequested schema changes.","initial_state":[]}],"examples":[{"id":"4d30cc7d-52af-4298-82cf-df0b42e2fd9e","name":"Setup a gel database","description":"This is how you setup a Gel project or a setup a new Gel database.","instructions":"Initialize the Gel project with `gel project init` command. This command normally requires user input.\n\nIf the project is already setup, the above command will produce an error message saying so.\n\nIf you want to initialize the project using default settings, use the `gel project init --non-interactive` command instead.\n\nIf this is a Python project, add `gel` >= to the latest version of package to the `requirements.txt`.\n\nFinally, ask the user what kind of schema should be created and create one if necessary. This is very important, don't make any changes to the default schema unless the user specifically asks for that.","code":[]}]}
{"id":"cc944e5c-5ced-44d1-8767-b5346b0ba7b5","name":"Delegated constraints","tests":[{"id":"37a44cdb-4d8e-4a5b-951c-0fb95abdc181","test_prompt":"Refactor my Gel schema. I want to have a base type Named with just the name property.","expected_outcome":"The new schema should be like the updated snippet. Specifically the exclusive constraint should be delegated since it came from multiple types originally.","initial_state":[{"id":"8dd5f422-95de-495d-b3d8-6cf0b347b222","url":"default.gel","code":"module default {\n # Different item types inheriting from base Item\n type Weapon {\n required name: str {\n constraint exclusive;\n }\n required description: str;\n required weight: float64;\n required value: int64;\n required damage: int64;\n damage_type: str;\n range: float64;\n }\n\n type Armour {\n required name: str {\n constraint exclusive;\n }\n required description: str;\n required weight: float64;\n required value: int64;\n required defense: int64;\n armor_type: str;\n slot: str;\n }\n\n # Character type\n type Character {\n required name: str {\n constraint exclusive;\n }\n required level: int64;\n required class: str;\n health: int64;\n mana: int64;\n experience: int64;\n \n # Link to inventory items with their quantities\n multi inventory: InventoryItem;\n }\n\n # Inventory item type to track quantities\n type InventoryItem {\n required link item: Weapon | Armour;\n required quantity: int64;\n }\n}","language":"sdl"},{"id":"abc43602-59a7-4e6e-a0c1-cc1445698282","url":"updated.gel","code":"module default {\n # Base type for named entities\n abstract type Named {\n required name: str {\n # Use delegated constraint to maintain exclusivity per extending type\n delegated constraint exclusive;\n }\n }\n\n type Weapon extending Named {\n required description: str;\n required weight: float64;\n required value: int64;\n required damage: int64;\n damage_type: str;\n range: float64;\n }\n\n type Armour extending Named {\n required description: str;\n required weight: float64;\n required value: int64;\n required defense: int64;\n armor_type: str;\n slot: str;\n }\n\n # Character type\n type Character extending Named {\n required level: int64;\n required class: str;\n health: int64;\n mana: int64;\n experience: int64;\n \n # Link to inventory items with their quantities\n multi inventory: InventoryItem;\n }\n\n # Inventory item type to track quantities\n type InventoryItem {\n required link item: Weapon | Armour;\n required quantity: int64;\n }\n}","language":"sdl"}]}],"examples":[{"id":"18755364-b759-418b-ae2c-a59fd7975d1a","name":"Never forget for schema refactoring","description":"Never forget to do this! This is an important gotcha for refactoring schemas. If refactoring affects unique or excusive properties remember delegated constraints. When handling \"ConstraintViolationError\" during migration caused by an exclusive constraint, check if constraints need to be delegated.","instructions":"1. When refactoring check if any of the links or properties with exclusive constraint get moved to an abstract class.\n2. **Important** that in the abstract class the corresponding property **must have** `delegated` constraint.\n3. **Don't forget to check exclusive constraints**.\n4. Refactored abstract types **must never** have a non-delegated exclusive constraint.\n\nThe `delegated` constraint is enforced in each of the extending types separately rather than across all of the extending types put together.","code":[{"id":"8ad438ba-328a-45c2-b3ca-0432e6857256","url":"schema_refactoring_never_forget_before.gel","code":"module default {\n type Foo {\n required name: str {\n # Pay attention to the constraint!!!\n constraint exclusive;\n }\n val: int64;\n }\n\n type Bar {\n required name: str {\n constraint exclusive;\n }\n desc: str;\n }\n}","language":"sdl"},{"id":"c4fb8fc0-3082-44f3-8a1f-c7ca34c06f9f","url":"schema_refactoring_never_forget_after.gel","code":"module default {\n abstract type Named {\n required name: str {\n # Refactored as delegated constraint!\n delegated constraint exclusive;\n }\n }\n\n type Foo extending Named {\n val: int64;\n }\n\n type Bar extending Named {\n desc: str;\n }\n}","language":"sdl"},{"id":"6d7560d0-b236-4419-83ba-7318f73d8939","url":"schema_refactoring_never_forget_before.esdl","code":"module default {\n type Foo {\n required property name -> str {\n # Pay attention to the constraint!!!\n constraint exclusive;\n }\n property val -> int64;\n }\n\n type Bar {\n required property name -> str {\n constraint exclusive;\n }\n property desc -> str;\n }\n}","language":"sdl"},{"id":"a984835f-8973-4f5b-bb4d-faa36047d9f0","url":"schema_refactoring_never_forget_after.esdl","code":"module default {\n abstract type Named {\n required property name -> str {\n # Refactored as delegated constraint!\n delegated constraint exclusive;\n }\n }\n\n type Foo extending Named {\n property val -> int64;\n }\n\n type Bar extending Named {\n property desc -> str;\n }\n}","language":"sdl"}]}]}