{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a9a99d9d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import { load } from \"jsr:@std/dotenv\";\n",
    "import OpenAI from \"jsr:@openai/openai\";\n",
    "\n",
    "const env = await load({\n",
    "    export: true,\n",
    "});\n",
    "\n",
    "const openai = new OpenAI();\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3430f0fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "{\n",
    "    const response = await openai.responses.create({\n",
    "        model: \"gpt-5-nano\",\n",
    "        input: \"Cuál es el sentido de la vida?\",\n",
    "        background: true,\n",
    "    });\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "89b3fffb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "url http://host.docker.internal:54321\n",
      "anon eyJhbGciOiJFUzI1NiIsImtpZCI6ImI4MTI2OWYxLTIxZDgtNGYyZS1iNzE5LWMyMjQwYTg0MGQ5MCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjIwODQ0NjczNTB9.m2CCND9Ei3-snNczQomvXfCAAchI1S-csdv1pz0r_U5ONS329AYHf4Ihcxi7lPySk13c3UV2J7xbVe4CDtFCzA\n"
     ]
    }
   ],
   "source": [
    "import {\n",
    "    FunctionsFetchError,\n",
    "    FunctionsHttpError,\n",
    "    FunctionsRelayError,\n",
    "} from \"@supabase/supabase-js\";\n",
    "import { createClient } from \"@supabase/supabase-js\";\n",
    "console.log(\"url\", Deno.env.get(\"SUPABASE_URL\"));\n",
    "console.log(\"anon\", Deno.env.get(\"SUPABASE_ANON_KEY\"));\n",
    "const supabaseUrl = Deno.env.get(\"SUPABASE_URL\");\n",
    "const supabaseKey = Deno.env.get(\"SUPABASE_ANON_KEY\");\n",
    "const supabase = createClient(supabaseUrl, supabaseKey);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5e7f628e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"EX2LNkSqViUC\",\n",
      "    etag: \"a5FKnhILr0U\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/EX2LNkSqViUC\",\n",
      "    volumeInfo: {\n",
      "      title: \"CUDA Programming\",\n",
      "      subtitle: \"A Developer's Guide to Parallel Computing with GPUs\",\n",
      "      authors: [ \"Shane Cook\" ],\n",
      "      publisher: \"Newnes\",\n",
      "      publishedDate: \"2012-12-28\",\n",
      "      description: \"If you need to learn CUDA but don't have experience with parallel computing, CUDA Programming: A Developer's Introduction offers a detailed guide to CUDA with a grounding in parallel fundamentals. It starts by introducing CUDA and bringing you up to speed on GPU parallelism and hardware, then delving into CUDA installation. Chapters on core concepts including threads, blocks, grids, and memory focus on both parallel and CUDA-specific issues. Later, the book demonstrates CUDA in practice for optimizing applications, adjusting to new hardware, and solving common problems. - Comprehensive introduction to parallel programming with CUDA, for readers new to both - Detailed instructions help readers optimize the CUDA software development kit - Practical techniques illustrate working with memory, threads, algorithms, resources, and more - Covers CUDA on multiple hardware platforms: Mac, Linux and Windows with several NVIDIA chipsets - Each chapter includes exercises to test reader knowledge\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9780124159884\" },\n",
      "        { type: \"ISBN_10\", identifier: \"0124159885\" }\n",
      "      ],\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 591,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      averageRating: 1,\n",
      "      ratingsCount: 1,\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: true,\n",
      "      contentVersion: \"1.5.5.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=EX2LNkSqViUC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=EX2LNkSqViUC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=EX2LNkSqViUC&printsec=frontcover&dq=CUDA+Programming&hl=&cd=1&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=EX2LNkSqViUC&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=EX2LNkSqViUC\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 664, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 664, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=EX2LNkSqViUC&rdid=book-EX2LNkSqViUC&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/CUDA_Programming-sample-epub.acsm?id=EX2LNkSqViUC&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/CUDA_Programming-sample-pdf.acsm?id=EX2LNkSqViUC&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=EX2LNkSqViUC&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"Later, the book demonstrates CUDA in practice for optimizing applications, adjusting to new hardware, and solving common problems.\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"BkAyEAAAQBAJ\",\n",
      "    etag: \"ZPDBktuk3rY\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/BkAyEAAAQBAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"Multicore and GPU Programming\",\n",
      "      subtitle: \"An Integrated Approach\",\n",
      "      authors: [ \"Gerassimos Barlas\" ],\n",
      "      publisher: \"Morgan Kaufmann\",\n",
      "      publishedDate: \"2022-02-09\",\n",
      "      description: `Multicore and GPU Programming: An Integrated Approach, Second Edition offers broad coverage of key parallel computing tools, essential for multi-core CPU programming and many-core \"massively parallel\" computing. Using threads, OpenMP, MPI, CUDA and other state-of-the-art tools, the book teaches the design and development of software capable of taking advantage of modern computing platforms that incorporate CPUs, GPUs and other accelerators. Presenting material refined over more than two decades of teaching parallel computing, author Gerassimos Barlas minimizes the challenge of transitioning from sequential programming to mastering parallel platforms with multiple examples, extensive case studies, and full source code. By using this book, readers will better understand how to develop programs that run over distributed memory machines using MPI, create multi-threaded applications with either libraries or directives, write optimized applications that balance the workload between available computing resources, and profile and debug programs targeting parallel machines. - Includes comprehensive coverage of all major multi-core and many-core programming tools and platforms, including threads, OpenMP, MPI, CUDA, OpenCL and Thrust - Covers the most recent versions of the above at the time of publication - Demonstrates parallel programming design patterns and examples of how different tools and paradigms can be integrated for superior performance - Updates in the second edition include the use of the C++17 standard for all sample code, a new chapter on concurrent data structures, a new chapter on OpenCL, and the latest research on load balancing - Includes downloadable source code, examples and instructor support materials on the book's companion website`,\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9780128141212\" },\n",
      "        { type: \"ISBN_10\", identifier: \"0128141212\" }\n",
      "      ],\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 1026,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: false,\n",
      "      contentVersion: \"2.5.5.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=BkAyEAAAQBAJ&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=BkAyEAAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=BkAyEAAAQBAJ&pg=PA392&dq=CUDA+Programming&hl=&cd=2&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=BkAyEAAAQBAJ&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=BkAyEAAAQBAJ\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 1170, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 1170, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=BkAyEAAAQBAJ&rdid=book-BkAyEAAAQBAJ&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Multicore_and_GPU_Programming-sample-epub.acsm?id=BkAyEAAAQBAJ&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Multicore_and_GPU_Programming-sample-pdf.acsm?id=BkAyEAAAQBAJ&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=BkAyEAAAQBAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"... programming. Since the OpenMP 4.0 specification published in 2013, it can also target GPUs. OpenMP is covered in Chapter 8. • OpenACC: An open ... <b>GPU programming</b>: CUDA 6.2 <b>CUDA&#39;s programming</b> model: threads, blocks, and grids.\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"hI14CgAAQBAJ\",\n",
      "    etag: \"qO57zyAywhQ\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/hI14CgAAQBAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"GPU Programming in MATLAB\",\n",
      "      authors: [ \"Nikolaos Ploskas\", \"Nikolaos Samaras\" ],\n",
      "      publisher: \"Morgan Kaufmann\",\n",
      "      publishedDate: \"2016-08-25\",\n",
      "      description: \"GPU programming in MATLAB is intended for scientists, engineers, or students who develop or maintain applications in MATLAB and would like to accelerate their codes using GPU programming without losing the many benefits of MATLAB. The book starts with coverage of the Parallel Computing Toolbox and other MATLAB toolboxes for GPU computing, which allow applications to be ported straightforwardly onto GPUs without extensive knowledge of GPU programming. The next part covers built-in, GPU-enabled features of MATLAB, including options to leverage GPUs across multicore or different computer systems. Finally, advanced material includes CUDA code in MATLAB and optimizing existing GPU applications. Throughout the book, examples and source codes illustrate every concept so that readers can immediately apply them to their own development. - Provides in-depth, comprehensive coverage of GPUs with MATLAB, including the parallel computing toolbox and built-in features for other MATLAB toolboxes - Explains how to accelerate computationally heavy applications in MATLAB without the need to re-write them in another language - Presents case studies illustrating key concepts across multiple fields - Includes source code, sample datasets, and lecture slides\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9780128051337\" },\n",
      "        { type: \"ISBN_10\", identifier: \"0128051337\" }\n",
      "      ],\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 320,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: false,\n",
      "      contentVersion: \"1.3.3.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=hI14CgAAQBAJ&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=hI14CgAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=hI14CgAAQBAJ&pg=PA199&dq=CUDA+Programming&hl=&cd=3&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=hI14CgAAQBAJ&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=hI14CgAAQBAJ\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 797, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 797, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=hI14CgAAQBAJ&rdid=book-hI14CgAAQBAJ&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/GPU_Programming_in_MATLAB-sample-epub.acsm?id=hI14CgAAQBAJ&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/GPU_Programming_in_MATLAB-sample-pdf.acsm?id=hI14CgAAQBAJ&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=hI14CgAAQBAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"Nikolaos Ploskas, Nikolaos Samaras. Run. <b>CUDA</b>. or. PTX. code. CHAPTER. 7. CHAPTER. OBJECTIVES. This Chapter explains how to create an executable kernel for a <b>CUDA</b> C code or PTX code and run that kernel on a <b>GPU</b> by calling it through MATLAB&nbsp;...\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"PHS1wwEACAAJ\",\n",
      "    etag: \"uAvN2b0VfsA\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/PHS1wwEACAAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"Hands-On GPU Programming with CUDA\",\n",
      "      authors: [ \"Jaegeun Han\", \"Bharatkumar Sharma\" ],\n",
      "      publishedDate: \"2019-09-27\",\n",
      "      description: \"Explore different GPU programming methods using libraries and directives, such as OpenACC, with extension to languages such as C, C++, and Python Key Features Learn parallel programming principles and practices and performance analysis in GPU computing Get to grips with distributed multi GPU programming and other approaches to GPU programming Understand how GPU acceleration in deep learning models can improve their performance Book Description Compute Unified Device Architecture (CUDA) is NVIDIA's GPU computing platform and application programming interface. It's designed to work with programming languages such as C, C++, and Python. With CUDA, you can leverage a GPU's parallel computing power for a range of high-performance computing applications in the fields of science, healthcare, and deep learning. Learn CUDA Programming will help you learn GPU parallel programming and understand its modern applications. In this book, you'll discover CUDA programming approaches for modern GPU architectures. You'll not only be guided through GPU features, tools, and APIs, you'll also learn how to analyze performance with sample parallel programming algorithms. This book will help you optimize the performance of your apps by giving insights into CUDA programming platforms with various libraries, compiler directives (OpenACC), and other languages. As you progress, you'll learn how additional computing power can be generated using multiple GPUs in a box or in multiple boxes. Finally, you'll explore how CUDA accelerates deep learning algorithms, including convolutional neural networks (CNNs) and recurrent neural networks (RNNs). By the end of this CUDA book, you'll be equipped with the skills you need to integrate the power of GPU computing in your applications. What you will learn Understand general GPU operations and programming patterns in CUDA Uncover the difference between GPU programming and CPU programming Analyze GPU application performance and implement optimization strategies Explore GPU programming, profiling, and debugging tools Grasp parallel programming algorithms and how to implement them Scale GPU-accelerated applications with multi-GPU and multi-nodes Delve into GPU programming platforms with accelerated libraries, Python, and OpenACC Gain insights into deep learning accelerators in CNNs and RNNs using GPUs Who this book is for This beginner-level book is for programmers who want to delve into parallel computing, become part of the high-performance computing community and build modern applications. Basic C and C++ programming experience is assumed. For deep learning enthusiasts, this book covers Python InterOps, DL libraries, and practical examples on performance estimation.\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_10\", identifier: \"1788996240\" },\n",
      "        { type: \"ISBN_13\", identifier: \"9781788996242\" }\n",
      "      ],\n",
      "      readingModes: { text: false, image: false },\n",
      "      pageCount: 508,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: false,\n",
      "      contentVersion: \"preview-1.0.0\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=PHS1wwEACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=PHS1wwEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=PHS1wwEACAAJ&dq=CUDA+Programming&hl=&cd=4&source=gbs_api\",\n",
      "      infoLink: \"http://books.google.com.mx/books?id=PHS1wwEACAAJ&dq=CUDA+Programming&hl=&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://books.google.com/books/about/Hands_On_GPU_Programming_with_CUDA.html?hl=&id=PHS1wwEACAAJ\"\n",
      "    },\n",
      "    saleInfo: { country: \"MX\", saleability: \"NOT_FOR_SALE\", isEbook: false },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"NO_PAGES\",\n",
      "      embeddable: false,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: { isAvailable: false },\n",
      "      pdf: { isAvailable: false },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=PHS1wwEACAAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"NONE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"Learn CUDA Programming will help you learn GPU parallel programming and understand its modern applications. In this book, you&#39;ll discover CUDA programming approaches for modern GPU architectures.\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"3b63x-0P3_UC\",\n",
      "    etag: \"t61uTD2OgFc\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/3b63x-0P3_UC\",\n",
      "    volumeInfo: {\n",
      "      title: \"Computer Organization and Design\",\n",
      "      subtitle: \"The Hardware/Software Interface\",\n",
      "      authors: [ \"David A. Patterson\", \"John L. Hennessy\" ],\n",
      "      publisher: \"Morgan Kaufmann\",\n",
      "      publishedDate: \"2008-11-17\",\n",
      "      description: \"Computer Organization and Design, Fourth Edition, provides a new focus on the revolutionary change taking place in industry today: the switch from uniprocessor to multicore microprocessors. This new emphasis on parallelism is supported by updates reflecting the newest technologies with examples highlighting the latest processor designs, benchmarking standards, languages and tools. As with previous editions, a MIPS processor is the core used to present the fundamentals of hardware technologies, assembly language, computer arithmetic, pipelining, memory hierarchies and I/O. Along with its increased coverage of parallelism, this new edition offers new content on Flash memory and virtual machines as well as a new and important appendix written by industry experts covering the emergence and importance of the modern GPU (graphics processing unit), the highly parallel, highly multithreaded multiprocessor optimized for visual computing. This book contains a new exercise paradigm that allows instructors to reconfigure the 600 exercises included in the book to generate new exercises and solutions of their own. The companion CD provides a toolkit of simulators and compilers along with tutorials for using them as well as advanced content for further study and a search utility for finding content on the CD and in the printed text. This text is designed for professional digital system designers, programmers, application developers, and system software developers as well as undergraduate students in Computer Science, Computer Engineering and Electrical Engineering courses in Computer Organization, Computer Design. A new exercise paradigm allows instructors to reconfigure the 600 exercises included in the book to easily generate new exercises and solutions of their own. The companion CD provides a toolkit of simulators and compilers along with tutorials for using them, as well as advanced content for further study and a search utility for finding content on the CD and in the printed text. For the convenience of readers who have purchased an ebook edition or who may have misplaced the CD-ROM, all CD content is available as a download at http://bit.ly/12XinUx.\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9780080922812\" },\n",
      "        { type: \"ISBN_10\", identifier: \"0080922813\" }\n",
      "      ],\n",
      "      readingModes: { text: false, image: true },\n",
      "      pageCount: 913,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      averageRating: 3.5,\n",
      "      ratingsCount: 4,\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: true,\n",
      "      contentVersion: \"2.3.1.0.preview.1\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=3b63x-0P3_UC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=3b63x-0P3_UC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=3b63x-0P3_UC&pg=SL1-PA17&dq=CUDA+Programming&hl=&cd=5&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=3b63x-0P3_UC&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=3b63x-0P3_UC\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 1196, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 1196, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=3b63x-0P3_UC&rdid=book-3b63x-0P3_UC&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: { isAvailable: false },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Computer_Organization_and_Design-sample-pdf.acsm?id=3b63x-0P3_UC&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=3b63x-0P3_UC&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"... <b>CUDA programming</b> model has provided a far easier way to exploit the scalable high-performance floating-point and memory bandwidth of GPUs with the C programming language. Programming Parallel Computing Applications CUDA, Brook, and CAL&nbsp;...\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"Jgx_BAAAQBAJ\",\n",
      "    etag: \"X/opG42tNjY\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/Jgx_BAAAQBAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"Professional CUDA C Programming\",\n",
      "      authors: [ \"John Cheng\", \"Max Grossman\", \"Ty McKercher\" ],\n",
      "      publisher: \"John Wiley & Sons\",\n",
      "      publishedDate: \"2014-09-08\",\n",
      "      description: 'Break into the powerful world of parallel GPU programming with this down-to-earth, practical guide Designed for professionals across multiple industrial sectors, Professional CUDA C Programming presents CUDA -- a parallel computing platform and programming model designed to ease the development of GPU programming -- fundamentals in an easy-to-follow format, and teaches readers how to think in parallel and implement parallel algorithms on GPUs. Each chapter covers a specific topic, and includes workable examples that demonstrate the development process, allowing readers to explore both the \"hard\" and \"soft\" aspects of GPU programming. Computing architectures are experiencing a fundamental shift toward scalable parallel computing motivated by application requirements in industry and science. This book demonstrates the challenges of efficiently utilizing compute resources at peak performance, presents modern techniques for tackling these challenges, while increasing accessibility for professionals who are not necessarily parallel programming experts. The CUDA programming model and tools empower developers to write high-performance applications on a scalable, parallel computing platform: the GPU. However, CUDA itself can be difficult to learn without extensive programming experience. Recognized CUDA authorities John Cheng, Max Grossman, and Ty McKercher guide readers through essential GPU programming skills and best practices in Professional CUDA C Programming, including: CUDA Programming Model GPU Execution Model GPU Memory model Streams, Event and Concurrency Multi-GPU Programming CUDA Domain-Specific Libraries Profiling and Performance Tuning The book makes complex CUDA concepts easy to understand for anyone with knowledge of basic software development with exercises designed to be both readable and high-performance. For the professional seeking entrance to parallel computing and the high-performance computing community, Professional CUDA C Programming is an invaluable resource, with the most current information available on the market.',\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9781118739310\" },\n",
      "        { type: \"ISBN_10\", identifier: \"1118739310\" }\n",
      "      ],\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 528,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: true,\n",
      "      contentVersion: \"1.14.9.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=Jgx_BAAAQBAJ&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=Jgx_BAAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=Jgx_BAAAQBAJ&printsec=frontcover&dq=CUDA+Programming&hl=&cd=6&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=Jgx_BAAAQBAJ&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=Jgx_BAAAQBAJ\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 639, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 639, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=Jgx_BAAAQBAJ&rdid=book-Jgx_BAAAQBAJ&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Professional_CUDA_C_Programming-sample-epub.acsm?id=Jgx_BAAAQBAJ&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Professional_CUDA_C_Programming-sample-pdf.acsm?id=Jgx_BAAAQBAJ&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=Jgx_BAAAQBAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"Professional CUDA C Programming: Focuses on GPU programming skills and best practices that deliver outstanding performance Shows you how to think in parallel Turns complex subjects into easy-to-understand concepts Makes information ...\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"c-64EQAAQBAJ\",\n",
      "    etag: \"CVz3HI8ANnw\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/c-64EQAAQBAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"Learning CUDA Programming with Modern C++\",\n",
      "      subtitle: \"A Hands-On Guide to Building High-Performance, GPU-Accelerated Applications\",\n",
      "      authors: [ \"CORWAN MARR\" ],\n",
      "      publisher: \"Oladosun Mopelola Opeyemi\",\n",
      "      publishedDate: \"2026-01-28\",\n",
      "      description: 'Are you ready to harness the full power of your computer’s graphics card? Do you want to accelerate your applications and enhance your programming skills with GPU computing? In \"Learning CUDA Programming with Modern C++,\" you’ll learn how to leverage the power of NVIDIA GPUs to create high-performance, GPU-accelerated applications. Whether you’re a C++ developer, a beginner programmer, or someone looking to boost your skills, this book provides a clear, practical guide to writing efficient GPU code. What you’ll learn: l Hands-on techniques: Build real-world projects that teach you how to write and optimize CUDA code for modern GPUs. l Understand CUDA programming: Learn about GPU architecture, memory management, and how to organize threads efficiently with Modern C++. l Maximize performance: Gain insight into profiling, debugging, and optimizing code for faster execution. l Complete projects: From image processing pipelines to Monte Carlo simulations, the projects in this book help you apply what you’ve learned in practical ways. This book is designed to help you write powerful, maintainable code that runs on GPUs, offering you the skills needed to tackle complex problems and build applications that perform at scale. Don’t just read about high-performance programming — start writing your own GPU-accelerated applications today. Buy your copy now and begin mastering CUDA programming!',\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 244,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: false,\n",
      "      contentVersion: \"2.3.3.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=c-64EQAAQBAJ&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=c-64EQAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=c-64EQAAQBAJ&printsec=frontcover&dq=CUDA+Programming&hl=&cd=7&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=c-64EQAAQBAJ&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=c-64EQAAQBAJ\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 109, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 109, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=c-64EQAAQBAJ&rdid=book-c-64EQAAQBAJ&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Learning_CUDA_Programming_with_Modern_C+-sample-epub.acsm?id=c-64EQAAQBAJ&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Learning_CUDA_Programming_with_Modern_C+-sample-pdf.acsm?id=c-64EQAAQBAJ&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=c-64EQAAQBAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"This book is designed to help you write powerful, maintainable code that runs on GPUs, offering you the skills needed to tackle complex problems and build applications that perform at scale.\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"WWMNAAAAQBAJ\",\n",
      "    etag: \"JpA5i0aBAWk\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/WWMNAAAAQBAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"Proceedings of 2013 Chinese Intelligent Automation Conference\",\n",
      "      subtitle: \"Intelligent Automation & Intelligent Technology and Systems\",\n",
      "      authors: [ \"Zengqi Sun\", \"Zhidong Deng\" ],\n",
      "      publisher: \"Springer Science & Business Media\",\n",
      "      publishedDate: \"2013-07-10\",\n",
      "      description: \"Proceedings of the 2013 Chinese Intelligent Automation Conference presents selected research papers from the CIAC’13, held in Yangzhou, China. The topics include e.g. adaptive control, fuzzy control, neural network based control, knowledge based control, hybrid intelligent control, learning control, evolutionary mechanism based control, multi-sensor integration, failure diagnosis, and reconfigurable control. Engineers and researchers from academia, industry, and government can gain an inside view of new solutions combining ideas from multiple disciplines in the field of intelligent automation. Zengqi Sun and Zhidong Deng are professors at the Department of Computer Science, Tsinghua University, China.\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9783642384608\" },\n",
      "        { type: \"ISBN_10\", identifier: \"3642384609\" }\n",
      "      ],\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 840,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Technology & Engineering\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: false,\n",
      "      contentVersion: \"1.12.10.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=WWMNAAAAQBAJ&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=WWMNAAAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=WWMNAAAAQBAJ&pg=PA253&dq=CUDA+Programming&hl=&cd=8&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=WWMNAAAAQBAJ&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=WWMNAAAAQBAJ\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 4229.91, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 4229.91, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=WWMNAAAAQBAJ&rdid=book-WWMNAAAAQBAJ&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Proceedings_of_2013_Chinese_Intelligent-sample-epub.acsm?id=WWMNAAAAQBAJ&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      pdf: {\n",
      "        isAvailable: true,\n",
      "        acsTokenLink: \"http://books.google.com.mx/books/download/Proceedings_of_2013_Chinese_Intelligent-sample-pdf.acsm?id=WWMNAAAAQBAJ&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api\"\n",
      "      },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=WWMNAAAAQBAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"... CUDA Main Memory CPU • Copy data • Copy result Memory for GPU • Instruct the processing • GPU:Execute parallel in each core code that runs on the GPU (usually ... <b>CUDA Programming</b> in Mathematica 28.4...<b>CUDA Programming</b> in MATLAB.\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"KUxsAQAAQBAJ\",\n",
      "    etag: \"64FtqjyzOz8\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/KUxsAQAAQBAJ\",\n",
      "    volumeInfo: {\n",
      "      title: \"The CUDA Handbook\",\n",
      "      subtitle: \"A Comprehensive Guide to GPU Programming\",\n",
      "      authors: [ \"Nicholas Wilt\" ],\n",
      "      publisher: \"Pearson Education\",\n",
      "      publishedDate: \"2013\",\n",
      "      description: \"'The CUDA Handbook' begins where 'CUDA by Example' leaves off, discussing both CUDA hardware and software in detail that will engage any CUDA developer, from the casual to the most hardcore. Newer CUDA developers will see how the hardware processes commands and the driver checks progress; hardcore CUDA developers will appreciate topics such as the driver API, context migration, and how best to structure CPU/GPU data interchange and synchronization. The book is partly a reference resource and partly a cookbook.\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9780321809469\" },\n",
      "        { type: \"ISBN_10\", identifier: \"0321809467\" }\n",
      "      ],\n",
      "      readingModes: { text: false, image: false },\n",
      "      pageCount: 526,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: false,\n",
      "      contentVersion: \"0.2.2.0.preview.0\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=KUxsAQAAQBAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=KUxsAQAAQBAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=KUxsAQAAQBAJ&dq=CUDA+Programming&hl=&cd=9&source=gbs_api\",\n",
      "      infoLink: \"http://books.google.com.mx/books?id=KUxsAQAAQBAJ&dq=CUDA+Programming&hl=&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://books.google.com/books/about/The_CUDA_Handbook.html?hl=&id=KUxsAQAAQBAJ\"\n",
      "    },\n",
      "    saleInfo: { country: \"MX\", saleability: \"NOT_FOR_SALE\", isEbook: false },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"NO_PAGES\",\n",
      "      embeddable: false,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED\",\n",
      "      epub: { isAvailable: false },\n",
      "      pdf: { isAvailable: true },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=KUxsAQAAQBAJ&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"NONE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"&#39;The CUDA Handbook&#39; begins where &#39;CUDA by Example&#39; leaves off, discussing both CUDA hardware and software in detail that will engage any CUDA developer, from the casual to the most hardcore.\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    kind: \"books#volume\",\n",
      "    id: \"49OmnOmTEtQC\",\n",
      "    etag: \"PkMJKeDmDrU\",\n",
      "    selfLink: \"https://www.googleapis.com/books/v1/volumes/49OmnOmTEtQC\",\n",
      "    volumeInfo: {\n",
      "      title: \"CUDA by Example\",\n",
      "      subtitle: \"An Introduction to General-Purpose GPU Programming\",\n",
      "      authors: [ \"Jason Sanders\", \"Edward Kandrot\" ],\n",
      "      publisher: \"Addison-Wesley Professional\",\n",
      "      publishedDate: \"2010-07-19\",\n",
      "      description: \"CUDA is a computing architecture designed to facilitate the development of parallel programs. In conjunction with a comprehensive software platform, the CUDA Architecture enables programmers to draw on the immense power of graphics processing units (GPUs) when building high-performance applications. GPUs, of course, have long been available for demanding graphics and game applications. CUDA now brings this valuable resource to programmers working on applications in other domains, including science, engineering, and finance. No knowledge of graphics programming is required—just the ability to program in a modestly extended version of C. CUDA by Example, written by two senior members of the CUDA software platform team, shows programmers how to employ this new technology. The authors introduce each area of CUDA development through working examples. After a concise introduction to the CUDA platform and architecture, as well as a quick-start guide to CUDA C, the book details the techniques and trade-offs associated with each key CUDA feature. You’ll discover when to use each CUDA C extension and how to write CUDA software that delivers truly outstanding performance. Major topics covered include Parallel programming Thread cooperation Constant memory and events Texture memory Graphics interoperability Atomics Streams CUDA C on multiple GPUs Advanced atomics Additional CUDA resources All the CUDA software tools you’ll need are freely available for download from NVIDIA. http://developer.nvidia.com/object/cuda-by-example.html\",\n",
      "      industryIdentifiers: [\n",
      "        { type: \"ISBN_13\", identifier: \"9780132180139\" },\n",
      "        { type: \"ISBN_10\", identifier: \"0132180138\" }\n",
      "      ],\n",
      "      readingModes: { text: true, image: true },\n",
      "      pageCount: 524,\n",
      "      printType: \"BOOK\",\n",
      "      categories: [ \"Computers\" ],\n",
      "      maturityRating: \"NOT_MATURE\",\n",
      "      allowAnonLogging: true,\n",
      "      contentVersion: \"1.13.10.0.preview.3\",\n",
      "      panelizationSummary: { containsEpubBubbles: false, containsImageBubbles: false },\n",
      "      imageLinks: {\n",
      "        smallThumbnail: \"http://books.google.com/books/content?id=49OmnOmTEtQC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api\",\n",
      "        thumbnail: \"http://books.google.com/books/content?id=49OmnOmTEtQC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api\"\n",
      "      },\n",
      "      language: \"en\",\n",
      "      previewLink: \"http://books.google.com.mx/books?id=49OmnOmTEtQC&printsec=frontcover&dq=CUDA+Programming&hl=&cd=10&source=gbs_api\",\n",
      "      infoLink: \"https://play.google.com/store/books/details?id=49OmnOmTEtQC&source=gbs_api\",\n",
      "      canonicalVolumeLink: \"https://play.google.com/store/books/details?id=49OmnOmTEtQC\"\n",
      "    },\n",
      "    saleInfo: {\n",
      "      country: \"MX\",\n",
      "      saleability: \"FOR_SALE\",\n",
      "      isEbook: true,\n",
      "      listPrice: { amount: 567.79, currencyCode: \"MXN\" },\n",
      "      retailPrice: { amount: 567.79, currencyCode: \"MXN\" },\n",
      "      buyLink: \"https://play.google.com/store/books/details?id=49OmnOmTEtQC&rdid=book-49OmnOmTEtQC&rdot=1&source=gbs_api\",\n",
      "      offers: [\n",
      "        {\n",
      "          finskyOfferType: 1,\n",
      "          listPrice: [Object],\n",
      "          retailPrice: [Object],\n",
      "          giftable: true\n",
      "        }\n",
      "      ]\n",
      "    },\n",
      "    accessInfo: {\n",
      "      country: \"MX\",\n",
      "      viewability: \"PARTIAL\",\n",
      "      embeddable: true,\n",
      "      publicDomain: false,\n",
      "      textToSpeechPermission: \"ALLOWED_FOR_ACCESSIBILITY\",\n",
      "      epub: { isAvailable: false },\n",
      "      pdf: { isAvailable: false },\n",
      "      webReaderLink: \"http://play.google.com/books/reader?id=49OmnOmTEtQC&hl=&source=gbs_api\",\n",
      "      accessViewStatus: \"SAMPLE\",\n",
      "      quoteSharingAllowed: false\n",
      "    },\n",
      "    searchInfo: {\n",
      "      textSnippet: \"After a concise introduction to the CUDA platform and architecture, as well as a quick-start guide to CUDA C, the book details the techniques and trade-offs associated with each key CUDA feature.\"\n",
      "    }\n",
      "  }\n",
      "]\n"
     ]
    }
   ],
   "source": [
    "const { data, error } = await supabase.functions.invoke(\"buscar-bibliografia\", {\n",
    "    body: {\n",
    "        searchTerms: {\n",
    "            q: \"CUDA Programming\",\n",
    "            maxResults: 10,\n",
    "            orderBy: \"relevance\", // opcional: \"newest\" | \"relevance\"\n",
    "        },\n",
    "    },\n",
    "});\n",
    "\n",
    "if (error instanceof FunctionsHttpError) {\n",
    "    const errorMessage = await error.context.json();\n",
    "    console.log(\"Function returned an error\", errorMessage);\n",
    "} else if (error instanceof FunctionsRelayError) {\n",
    "    console.log(\"Relay error:\", error.message);\n",
    "} else if (error instanceof FunctionsFetchError) {\n",
    "    console.log(\"Fetch error:\", error.message);\n",
    "}\n",
    "console.log(data); // array de volumes (items[])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fea911a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{\n",
       "  id: \u001b[32m\"4660b774-a6e2-44f4-a340-747b41235c7c\"\u001b[39m,\n",
       "  carrera_id: \u001b[32m\"089cdeda-d557-4a57-b49f-eb44921dfa3a\"\u001b[39m,\n",
       "  estructura_id: \u001b[32m\"69fb2b77-5a95-47e0-bf1f-389d384200e4\"\u001b[39m,\n",
       "  nombre: \u001b[32m\"Ingeniería en Sistemas Domóticos (2027)\"\u001b[39m,\n",
       "  nivel: \u001b[32m\"Otro\"\u001b[39m,\n",
       "  tipo_ciclo: \u001b[32m\"Semestre\"\u001b[39m,\n",
       "  numero_ciclos: \u001b[33m9\u001b[39m,\n",
       "  datos: {\n",
       "    nivel: \u001b[32m\"Bachillerato\"\u001b[39m,\n",
       "    nombre: \u001b[32m\"Especialización en Gravedad Cuántica de Bucles\"\u001b[39m,\n",
       "    area_de_estudio: \u001b[32m\"Ciencias Físico-Matemáticas\"\u001b[39m,\n",
       "    perfil_de_egreso: \u001b[32m\"La Specialización en Gravedad Cuántica de Bucles formará a un especialista capaz de integrar creativamente conocimientos avanzados en física, matemáticas y computación para enfrentar problemas teóricos y fenomenológicos en la intersección de la relatividad general y la mecánica cuántica. Al finalizar el programa, el egresado será capaz de: 1) Comprender y aplicar los fundamentos de la gravedad cuántica de bucles, incluyendo su formulación canónica, las variables de Ashtekar y el formalismo de redes de espín; 2) Desarrollar modelos y simulaciones rigurosas de fenómenos cuántico-gravitacionales, empleando métodos numéricos y herramientas de cómputo científico para analizar redes y espumas de espín, así como su relación con la cosmología cuántica; 3) Utilizar y conectar conceptos avanzados de geometría diferencial, teoría de grupos de Lie, representaciones y espinores para la construcción de estados cuánticos geométricos; 4) Resolver y comunicar de manera crítica problemas de frontera en física teórica contemporánea, integrando procesos de modelado matemático, análisis computacional y validación fenomenológica; 5) Evaluar y proponer soluciones innovadoras en entornos de trabajo colaborativo, mostrando habilidad para desarrollar proyectos científicos reproducibles bajo principios éticos y de buenas prácticas en la investigación; 6) Integrarse a comunidades científicas y continuar con estudios de posgrado o desempeñarse en entornos interdisciplinares que involucren física matemática, simulación, cosmología, información cuántica o modelado de sistemas complejos.\"\u001b[39m,\n",
       "    diseno_curricular: \u001b[32m\"Rígido\"\u001b[39m,\n",
       "    perfil_de_ingreso: \u001b[32m\"El aspirante debe haber concluido el bachillerato con perfil Área 1 (Ciencias Físico-Matemáticas), lo que implica sólidas bases en matemáticas, física, química, razonamiento lógico y competencia en análisis de problemas. Se espera capacidad para el aprendizaje autónomo y familiaridad con herramientas y conceptos científicos y tecnológicos, así como interés en la resolución de problemas complejos y trabajo experimental.\"\u001b[39m,\n",
       "    curso_propedeutico: \u001b[32m\"No tiene\"\u001b[39m,\n",
       "    modalidad_educativa: \u001b[32m\"Escolar\"\u001b[39m,\n",
       "    antecedente_academico: \u001b[32m\"Bachillerato en Ciencias Físico-Matemáticas, con orientación en matemáticas y física; requisito previo para ingreso a la especialización. El plan asume que el aspirante ha concluido un bachillerato con áreas de Ciencias Físico-Matemáticas.\"\u001b[39m,\n",
       "    carga_horaria_a_la_semana: \u001b[33m27\u001b[39m,\n",
       "    programa_de_investigacion: \u001b[32m\"No aplica\"\u001b[39m,\n",
       "    clave_del_plan_de_estudios: \u001b[32m\"2020\"\u001b[39m,\n",
       "    duracion_del_ciclo_escolar: \u001b[32m\"16 semanas\"\u001b[39m,\n",
       "    fines_de_aprendizaje_o_formacion: \u001b[32m\"Analizar fundamentos de la gravedad cuántica de bucles y su relación con la relatividad general; Diseñar modelos computacionales para explorar redes de espín y espumas cuánticas, con enfoque en cosmología cuántica; Evaluar resultados numéricos mediante criterios de reproducibilidad y validación fenomenológica; Comunicar resultados científicos de forma clara, estructurada y técnica; Integrar conceptos de domótica, electrónica, control y sistemas computacionales mediante herramientas de simulación para proyectos interdisciplinarios y el desarrollo de asistentes virtuales; Aplicar herramientas de cómputo para la creación de proyectos con código reproducible y documentación adecuada; Desarrollar capacidades de trabajo en equipo, ética científica y buenas prácticas en investigación.\"\u001b[39m,\n",
       "    total_de_ciclos_del_plan_de_estudios: \u001b[32m\"9\"\u001b[39m,\n",
       "    sustento_teorico_del_modelo_curricular: \u001b[32m\"No aplica\"\u001b[39m,\n",
       "    justificacion_de_la_propuesta_curricular: \u001b[32m\"No aplica\"\u001b[39m,\n",
       "    administracion_y_operatividad_del_plan_de_estudios: \u001b[32m\"La administración y operatividad del plan de estudios se ubica bajo la Dirección de Asuntos Académicos - Anexo 1; modalidad escolar; estructura rígida con 9 ciclos; carga horaria semanal de 27 horas; responsable: Lic. María González Pérez, Directora Académica; procesos de revisión y actualización conforme a la Propuesta de Evaluación Periódica y a los lineamientos del Acuerdo 17/11/17.\"\u001b[39m,\n",
       "    propuesta_de_evaluacion_periodica_del_plan_de_estudios: \u001b[32m\"Nivel de evaluación curricular interna: diagnóstico de estructura y operación. Análisis técnico-pedagógico del planteamiento curricular vigente; consulta a directivos del área académica para valorar problemáticas de formación y operación; consulta a docentes sobre problemáticas de formación, operación y necesidades disciplinarias; estudio de opinión de estudiantes sobre la formación y operación. Nivel de evaluación curricular externa: diagnóstico de impacto y prácticas profesionales. Análisis del estado del conocimiento en campos disciplinarios vinculados al programa, comparación de planes y tendencias en criterios de organismos evaluadores; estudio con egresados y empleadores para valorar inserción laboral y requerimientos actuales; recopilación de criterios y reformas necesarias para mantener el programa actualizado y acorde con la disciplina.\"\u001b[39m\n",
       "  },\n",
       "  estado_actual_id: \u001b[32m\"18f49b67-8077-4371-be6e-2019a3be3562\"\u001b[39m,\n",
       "  activo: \u001b[33mtrue\u001b[39m,\n",
       "  tipo_origen: \u001b[32m\"IA\"\u001b[39m,\n",
       "  meta_origen: {\n",
       "    iaConfig: {\n",
       "      usarMCP: \u001b[33mfalse\u001b[39m,\n",
       "      notasAdicionales: \u001b[32m\"Agrega a los asistentes virtuales\"\u001b[39m,\n",
       "      descripcionEnfoque: \u001b[32m\"Carrera relacionada con la domótica, electrónica, control y sistemas computacionales\"\u001b[39m\n",
       "    },\n",
       "    referencias: { repositoriosIds: [], archivosReferenciaIds: [] },\n",
       "    generado_por: \u001b[32m\"ai_generate_plan\"\u001b[39m,\n",
       "    ai_structured: {\n",
       "      model: \u001b[32m\"gpt-5-nano-2025-08-07\"\u001b[39m,\n",
       "      usage: {\n",
       "        input_tokens: \u001b[33m9812\u001b[39m,\n",
       "        total_tokens: \u001b[33m19204\u001b[39m,\n",
       "        output_tokens: \u001b[33m9392\u001b[39m,\n",
       "        input_tokens_details: { cached_tokens: \u001b[33m0\u001b[39m },\n",
       "        output_tokens_details: { reasoning_tokens: \u001b[33m8256\u001b[39m }\n",
       "      },\n",
       "      responseId: \u001b[32m\"resp_0b1339b15ea08d51006973b4892a20819c954b7fe00a35e1ed\"\u001b[39m,\n",
       "      conversationId: \u001b[1mnull\u001b[22m\n",
       "    }\n",
       "  },\n",
       "  creado_por: \u001b[1mnull\u001b[22m,\n",
       "  actualizado_por: \u001b[1mnull\u001b[22m,\n",
       "  creado_en: \u001b[32m\"2026-01-23T17:50:00.85346+00:00\"\u001b[39m,\n",
       "  actualizado_en: \u001b[32m\"2026-01-23T22:00:33.119999+00:00\"\u001b[39m,\n",
       "  nombre_search: \u001b[32m\"ingenieria en sistemas domoticos (2027)\"\u001b[39m,\n",
       "  plan_hash: \u001b[32m\"d7a4bd1c6d444ceb11be1dba\"\u001b[39m,\n",
       "  estructuras_plan: {\n",
       "    definicion: {\n",
       "      type: \u001b[32m\"object\"\u001b[39m,\n",
       "      required: [\n",
       "        \u001b[32m\"nombre_autorizado_de_la_institucion\"\u001b[39m,\n",
       "        \u001b[32m\"nivel_y_nombre_del_plan_de_estudios\"\u001b[39m,\n",
       "        \u001b[32m\"modalidad_educativa\"\u001b[39m,\n",
       "        \u001b[32m\"vigencia\"\u001b[39m,\n",
       "        \u001b[32m\"antecedente_academico\"\u001b[39m,\n",
       "        \u001b[32m\"area_de_estudio\"\u001b[39m,\n",
       "        \u001b[32m\"clave_del_plan_de_estudios\"\u001b[39m,\n",
       "        \u001b[32m\"diseno_curricular\"\u001b[39m,\n",
       "        \u001b[32m\"total_de_ciclos_del_plan_de_estudios\"\u001b[39m,\n",
       "        \u001b[32m\"duracion_del_ciclo_escolar\"\u001b[39m,\n",
       "        \u001b[32m\"carga_horaria_a_la_semana\"\u001b[39m,\n",
       "        \u001b[32m\"fines_de_aprendizaje_o_formacion\"\u001b[39m,\n",
       "        \u001b[32m\"perfil_de_egreso\"\u001b[39m,\n",
       "        \u001b[32m\"programa_de_investigacion\"\u001b[39m,\n",
       "        \u001b[32m\"curso_propedeutico\"\u001b[39m,\n",
       "        \u001b[32m\"perfil_de_ingreso\"\u001b[39m,\n",
       "        \u001b[32m\"administracion_y_operatividad_del_plan_de_estudios\"\u001b[39m,\n",
       "        \u001b[32m\"sustento_teorico_del_modelo_curricular\"\u001b[39m,\n",
       "        \u001b[32m\"justificacion_de_la_propuesta_curricular\"\u001b[39m,\n",
       "        \u001b[32m\"propuesta_de_evaluacion_periodica_del_plan_de_estudios\"\u001b[39m,\n",
       "        \u001b[32m\"nombre_y_cargo_de_la_persona_facultada_para_autorizar_el_plan_de_estudios\"\u001b[39m\n",
       "      ],\n",
       "      properties: {\n",
       "        vigencia: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Vigencia\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"(Espacio para uso exclusivo de la autoridad educativa)\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Dato administrativo del Anexo 1.\"\u001b[39m\n",
       "        },\n",
       "        area_de_estudio: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Área de estudio\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Señalar el “campo amplio” al que pertenece el plan de estudios. Para ello, considerar la Clasificación Mexicana de Planes de Estudio por Campos de Formación Académica (CMPE 2016), publicado por INEGI.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Deberá vincularse con el fin de aprendizaje y perfil de egreso del plan de estudios.\"\u001b[39m\n",
       "        },\n",
       "        perfil_de_egreso: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Perfil de egreso\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Describir los atributos que habrán desarrollado los estudiantes al concluir el plan de estudios, acordes al nivel educativo y denominación propuesta. De preferencia, dividirlo en conocimientos, habilidades y actitudes.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito 'Perfil de egreso' del Artículo 8, fracción VI del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        diseno_curricular: {\n",
       "          enum: \u001b[36m[Array]\u001b[39m,\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Diseño curricular\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Indicar si es “Rígido” o “Flexible”.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Define la estructura para el requisito 'Mapa curricular' del Artículo 8, fracción VII del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        perfil_de_ingreso: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Perfil de ingreso\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Indicar las condiciones académicas ideales (conocimientos, habilidades y aptitudes), para incorporarse al plan de estudios. Deberá vincularse con el nivel educativo y campo de estudio.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito 'Perfil de ingreso' (condiciones mínimas requeridas) del Artículo 8, fracción V del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        curso_propedeutico: {\n",
       "          type: \u001b[36m[Array]\u001b[39m,\n",
       "          title: \u001b[32m\"Curso propedéutico\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Señalar las situaciones en las que aplicará el curso propedéutico, la población a la que estará dirigido, su duración, la relación con el plan de estudios, así como la información que considere relevante.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Elemento opcional mencionado en las guías de llenado del Anexo 1.\"\u001b[39m\n",
       "        },\n",
       "        modalidad_educativa: {\n",
       "          enum: \u001b[36m[Array]\u001b[39m,\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Modalidad educativa\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Señalar la modalidad educativa en la que se impartirá el plan de estudios: escolar, no escolarizada o mixta.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito de 'Modalidad educativa' del Artículo 8, fracción II del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        antecedente_academico: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Antecedente académico\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Señalar el nivel educativo requerido para ingresar al plan de estudios. Para posgrados, además del nivel educativo; indicar la(s) disciplina(s) o área(s) afín(es) al plan de estudios.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito 'Perfil de ingreso' (antecedente académico necesario) del Artículo 8, fracción V del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        carga_horaria_a_la_semana: {\n",
       "          type: \u001b[32m\"number\"\u001b[39m,\n",
       "          title: \u001b[32m\"Carga horaria a la semana\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Indicar la máxima carga horaria impartida a la semana; no mayor a 50 horas bajo la conducción de un académico.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde a la restricción 'sin exceder una carga máxima de 50 horas efectivas por semana' del Artículo 8, fracción III del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        programa_de_investigacion: {\n",
       "          type: \u001b[36m[Array]\u001b[39m,\n",
       "          title: \u001b[32m\"Programa de investigación\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"(Obligatorio para el nivel de Doctorado y para aquéllas Maestrías orientadas a la investigación). Presentar el programa de investigación que describa los objetivos del programa y líneas de investigación con sus respectivos objetivos. Asimismo, detallar la vinculación con las asignaturas que conforman el plan de estudios, la metodología y presentación de las investigaciones, así como el perfil de los docentes que guiarán su desarrollo.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Requisito obligatorio solo para Doctorados o Maestrías con orientación a investigación según el Artículo 10, fracción III incisos b) y c) del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        clave_del_plan_de_estudios: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Clave / Año del plan\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Señalar el año en el que solicita el trámite.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Dato administrativo del Anexo 1.\"\u001b[39m\n",
       "        },\n",
       "        duracion_del_ciclo_escolar: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Duración mínima en semanas de cada ciclo escolar\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Señalar el número mínimo de semanas efectivas de clase que integran el tipo de ciclo en el que se imparte el plan de estudios.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde exactamente al requisito 'Duración mínima en semanas' del Artículo 8, fracción III del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        fines_de_aprendizaje_o_formacion: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Fin de aprendizaje o formación\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Describir los aprendizajes que lograrán los estudiantes al concluir el plan de estudios. Deberá corresponder con el nivel educativo y la denominación del plan de estudios.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito 'Descripción de los fines del aprendizaje o formación' del Artículo 8, fracción IV del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        nivel_y_nombre_del_plan_de_estudios: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Nivel y nombre del plan de estudios\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Indicar el nivel educativo y denominación del plan de estudios.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito 'Nivel y denominación del plan de estudios' del Artículo 8, fracción I del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        nombre_autorizado_de_la_institucion: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Nombre autorizado de la institución\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Proporcionar el nombre de la institución autorizado por SEP.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Dato administrativo del Anexo 1.\"\u001b[39m\n",
       "        },\n",
       "        total_de_ciclos_del_plan_de_estudios: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Número de ciclos escolares que integrarán el plan de estudio\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"En diseño flexible especificar mínimo y máximo de ciclos. En diseño rígido especificar el total de ciclos.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde a 'señalando el número de ciclos en que se impartirá' del Artículo 8, fracción III del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        sustento_teorico_del_modelo_curricular: {\n",
       "          type: \u001b[36m[Array]\u001b[39m,\n",
       "          title: \u001b[32m\"Sustento teórico del modelo curricular\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Presentar de forma concreta el marco conceptual en el que se justifica y fundamenta el diseño y organización curricular del plan de estudios.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al 'sustento teórico del modelo curricular' que el particular puede incluir según el Artículo 8 (párrafo tercero) del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        justificacion_de_la_propuesta_curricular: {\n",
       "          type: \u001b[36m[Array]\u001b[39m,\n",
       "          title: \u001b[32m\"Justificación de la propuesta curricular en la modalidad no escolarizada o mixta\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"(Exclusivo para modalidades no escolarizada y mixta). Describir cómo se impartirá el plan de estudios en la modalidad educativa elegida, los recursos tecnológicos y/o didácticos que emplearán para su desarrollo y su vinculación con las asignaturas y actividades de aprendizaje.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde a lo solicitado en el Artículo 14 (justificación de modalidad) y Artículo 15 (especificaciones de plataforma/modelo) del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        administracion_y_operatividad_del_plan_de_estudios: {\n",
       "          type: \u001b[36m[Array]\u001b[39m,\n",
       "          title: \u001b[32m\"Administración y operatividad del plan de estudios\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Describir la administración del plan de estudios, así como su operatividad; considerando el tipo de diseño curricular empleado. Si es flexible; incorporar el número mínimo y máximo de asignaturas que se cursarán por ciclo.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde a la 'descripción detallada de la(s) forma(s) de administración y operatividad' permitida en el Artículo 8 (párrafo tercero) del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        propuesta_de_evaluacion_periodica_del_plan_de_estudios: {\n",
       "          type: \u001b[36m[Array]\u001b[39m,\n",
       "          title: \u001b[32m\"Propuesta de evaluación periódica del plan de estudios\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Describir de manera detallada la metodología que emplearán para la evaluación del plan de estudios, incluyendo los instrumentos y periodicidad en la que se llevará a cabo; con la finalidad de mantenerlo actualizado y acorde a las necesidades educativas y disciplinares.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Corresponde al requisito 'Propuesta de evaluación periódica del Plan de estudio' del Artículo 8, fracción VIII del Acuerdo 17/11/17.\"\u001b[39m\n",
       "        },\n",
       "        nombre_y_cargo_de_la_persona_facultada_para_autorizar_el_plan_de_estudios: {\n",
       "          type: \u001b[32m\"string\"\u001b[39m,\n",
       "          title: \u001b[32m\"Nombre y cargo de la persona facultada para autorizar el plan de estudios\"\u001b[39m,\n",
       "          examples: \u001b[36m[Array]\u001b[39m,\n",
       "          description: \u001b[32m\"Indicar el nombre y cargo de la persona facultada para autorizar el plan de estudios.\"\u001b[39m,\n",
       "          referencia_normativa: \u001b[32m\"Dato administrativo del Anexo 1.\"\u001b[39m\n",
       "        }\n",
       "      },\n",
       "      additionalProperties: \u001b[33mfalse\u001b[39m\n",
       "    }\n",
       "  }\n",
       "}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "const { data: input } = await supabase.from(\"planes_estudio\")\n",
    "    .select(\"*, estructuras_plan (definicion)\").limit(1).single();\n",
    "input;\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "33290880",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{ id: \u001b[32m\"fc36eaac-1e0f-43a2-8406-62e260c6ae06\"\u001b[39m }"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// Create a conversation for a plan de estudio\n",
    "const openaiConversation = await openai.conversations.create({\n",
    "    metadata: {\n",
    "        \"tabla\": \"planes_estudio\",\n",
    "        \"id\": input.id,\n",
    "\n",
    "        instanciador: \"alex\",\n",
    "    },\n",
    "\n",
    "    items: [\n",
    "        {\n",
    "            type: \"message\",\n",
    "            role: \"system\",\n",
    "            content:\n",
    "                \"En caso de que te pidan algo que no tiene nada que ver con planes de estudio o asignatura responde con un refusal.\",\n",
    "        },\n",
    "    ],\n",
    "});\n",
    "\n",
    "const { data: conversationPlane } = await supabase.from(\"conversaciones_plan\")\n",
    "    .insert({\n",
    "        openai_conversation_id: openaiConversation.id,\n",
    "        plan_estudio_id: input.id,\n",
    "    }).select(\"id\").single();\n",
    "\n",
    "conversationPlane;\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2c222219",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4660b774-a6e2-44f4-a340-747b41235c7c fc36eaac-1e0f-43a2-8406-62e260c6ae06 conv_6994e936d58c8193b1879a403aac5adf057bd8aacc77d01f\n"
     ]
    }
   ],
   "source": [
    "console.log(input.id, conversationPlane.id, openaiConversation.id);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f726b80e",
   "metadata": {},
   "outputs": [
    {
     "ename": "Error",
     "evalue": "404 Conversation with id 'conv_698f3438114c8194a400f01568cf1a56058487a13fa1da16' not found.",
     "output_type": "error",
     "traceback": [
      "Stack trace:",
      "Error: 404 Conversation with id 'conv_698f3438114c8194a400f01568cf1a56058487a13fa1da16' not found.",
      "    at APIError.generate (https://jsr.io/@openai/openai/6.16.0/core/error.ts:84:14)",
      "    at OpenAI.makeStatusError (https://jsr.io/@openai/openai/6.16.0/client.ts:478:28)",
      "    at OpenAI.makeRequest (https://jsr.io/@openai/openai/6.16.0/client.ts:728:24)",
      "    at eventLoopTick (ext:core/01_core.js:187:7)",
      "    at async <anonymous>:8:1"
     ]
    }
   ],
   "source": [
    "// Archivar una conversación\n",
    "const items = await openai.conversations.items.list(\n",
    "    conversation.openai_conversation_id,\n",
    ");\n",
    "await supabase.from(\"conversaciones_plan\").update({\n",
    "    estado: \"ARCHIVANDO\",\n",
    "    conversacion_json: items,\n",
    "    openai_conversation_id: null,\n",
    "}).eq(\"id\", conversationPlane.id);\n",
    "\n",
    "await openai.conversations.delete(conversation.openai_conversation_id);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "cfae6e48",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[32m\"{\\n\"\u001b[39m +\n",
       "  \u001b[32m'  \"options\": {\\n'\u001b[39m +\n",
       "  \u001b[32m'    \"method\": \"get\",\\n'\u001b[39m +\n",
       "  \u001b[32m'    \"path\": \"/conversations/conv_6994e936d58c8193b1879a403aac5adf057bd8aacc77d01f/items\",\\n'\u001b[39m +\n",
       "  \u001b[32m'    \"query\": {}\\n'\u001b[39m +\n",
       "  \u001b[32m\"  },\\n\"\u001b[39m +\n",
       "  \u001b[32m'  \"response\": {},\\n'\u001b[39m +\n",
       "  \u001b[32m'  \"body\": {\\n'\u001b[39m +\n",
       "  \u001b[32m'    \"object\": \"list\",\\n'\u001b[39m +\n",
       "  \u001b[32m'    \"data\": [\\n'\u001b[39m +\n",
       "  \u001b[32m\"      {\\n\"\u001b[39m +\n",
       "  \u001b[32m'        \"id\": \"msg_057bd8aacc77d01f006994e962676081939ca17c51310d416f\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"type\": \"message\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"status\": \"completed\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"content\": [\\n'\u001b[39m +\n",
       "  \u001b[32m\"          {\\n\"\u001b[39m +\n",
       "  \u001b[32m'            \"type\": \"output_text\",\\n'\u001b[39m +\n",
       "  \u001b[32m'            \"annotations\": [],\\n'\u001b[39m +\n",
       "  \u001b[32m'            \"logprobs\": [],\\n'\u001b[39m +\n",
       "  \u001b[32m'            \"text\": \"{\\\\\"vigencia\\\\\":\\\\\"(Espacio para uso exclusivo de la autoridad educativa)\\\\\",\\\\\"area_de_estudio\\\\\":\\\\\"Ciencias Físico-Matemáticas\\\\\",\\\\\"perfil_de_egreso\\\\\":\\\\\"La Specialización en Gravedad Cuántica de Bucles formará a un especialista capaz de integrar creativamente conocimientos avanzados en física, matemáticas y computación para enfrentar problemas teóricos y fenomenológicos en la intersección de la relatividad general y la mecánica cuántica. Al finalizar el programa, el egresado será capaz de: 1) Comprender y aplicar los fundamentos de la gravedad cuántica de bucles, incluyendo su formulación canónica, las variables de Ashtekar y el formalismo de redes de espín; 2) Desarrollar modelos y simulaciones rigurosas de fenómenos cuántico-gravitacionales, empleando métodos numéricos y herramientas de cómputo científico para analizar redes y espumas de espín, así como su relación con la cosmología cuántica; 3) Utilizar y conectar conceptos avanzados de geometría diferencial, teoría de grupos de Lie, representaciones y espinores para la construcción de estados cuánticos geométricos; 4) Resolver y comunicar de manera crítica problemas de frontera en física teórica contemporánea, integrando procesos de modelado matemático, análisis computacional y validación fenomenológica; 5) Evaluar y proponer soluciones innovadoras en entornos de trabajo colaborativo, mostrando habilidad para desarrollar proyectos científicos reproducibles bajo principios éticos y de buenas prácticas en la investigación; 6) Integrarse a comunidades científicas y continuar con estudios de posgrado o desempeñarse en entornos interdisciplinares que involucren física matemática, simulación, cosmología, información cuántica o modelado de sistemas complejos.\\\\\",\\\\\"diseno_curricular\\\\\":\\\\\"Rígido\\\\\",\\\\\"perfil_de_ingreso\\\\\":\\\\\"El aspirante debe haber concluido el Bachillerato con perfil Área 1 (Ciencias Físico-Matemáticas), lo que implica sólidas bases en matemáticas, física, química, razonamiento lógico y competencia en análisis de problemas. Se espera capacidad para el aprendizaje autónomo y familiaridad con herramientas y conceptos científicos y tecnológicos, así como interés en la resolución de problemas complejos y trabajo experimental.\\\\\",\\\\\"curso_propedeutico\\\\\":\\\\\"No tiene\\\\\",\\\\\"modalidad_educativa\\\\\":\\\\\"Escolar\\\\\",\\\\\"antecedente_academico\\\\\":\\\\\"Bachillerato en Ciencias Físico-Matemáticas, con orientación en matemáticas y física; requisito previo para ingreso a la especialización. El plan asume que el aspirante ha concluido un bachillerato con áreas de Ciencias Físico-Matemáticas.\\\\\",\\\\\"carga_horaria_a_la_semana\\\\\":27,\\\\\"programa_de_investigacion\\\\\":\\\\\"No aplica\\\\\",\\\\\"clave_del_plan_de_estudios\\\\\":\\\\\"2020\\\\\",\\\\\"duracion_del_ciclo_escolar\\\\\":\\\\\"16 semanas\\\\\",\\\\\"fines_de_aprendizaje_o_formacion\\\\\":\\\\\"Analizar fundamentos de la gravedad cuántica de bucles y su relación con la relatividad general; Diseñar modelos computacionales para explorar redes de espín y espumas cuánticas, con enfoque en cosmología cuántica; Evaluar resultados numéricos mediante criterios de reproducibilidad y validación fenomenológica; Comunicar resultados científicos de forma clara, estructurada y técnica; Integrar conceptos de domótica, electrónica, control y sistemas computacionales mediante herramientas de simulación para proyectos interdisciplinarios y el desarrollo de asistentes virtuales; Aplicar herramientas de cómputo para la creación de proyectos con código reproducible y documentación adecuada; Desarrollar capacidades de trabajo en equipo, ética científica y buenas prácticas en investigación.\\\\\",\\\\\"nivel_y_nombre_del_plan_de_estudios\\\\\":\\\\\"Nivel y nombre del plan de estudios\\\\\",\\\\\"nombre_autorizado_de_la_institucion\\\\\":\\\\\"Nombre autorizado de la institución\\\\\",\\\\\"total_de_ciclos_del_plan_de_estudios\\\\\":\\\\\"9\\\\\",\\\\\"sustento_teorico_del_modelo_curricular\\\\\":\\\\\"No aplica\\\\\",\\\\\"justificacion_de_la_propuesta_curricular\\\\\":\\\\\"No aplica\\\\\",\\\\\"administracion_y_operatividad_del_plan_de_estudios\\\\\":\\\\\"La administración y operatividad del plan de estudios se ubica bajo la Dirección de Asuntos Académicos - Anexo 1; modalidad escolar; estructura rígida con 9 ciclos; carga horaria semanal de 27 horas; responsable: Lic. María González Pérez, Directora Académica; procesos de revisión y actualización conforme a la Propuesta de Evaluación Periódica y a los lineamientos del Acuerdo 17/11/17.\\\\\",\\\\\"propuesta_de_evaluacion_periodica_del_plan_de_estudios\\\\\":\\\\\"Nivel de evaluación curricular interna: diagnóstico de estructura y operación. Análisis técnico-pedagógico del planteamiento curricular vigente; consulta a directivos del área académica para valorar problemáticas de formación y operación; consulta a docentes sobre problemáticas de formación, operación y necesidades disciplinarias; estudio de opinión de estudiantes sobre la formación y operación. Nivel de evaluación curricular externa: diagnóstico de impacto y prácticas profesionales. Análisis del estado del conocimiento en campos disciplinarios vinculados al programa, comparación de planes y tendencias en criterios de organismos evaluadores; estudio con egresados y empleadores para valorar inserción laboral y requerimientos actuales; recopilación de criterios y reformas necesarias para mantener el programa actualizado y acorde con la disciplina.\\\\\",\\\\\"nombre_y_cargo_de_la_persona_facultada_para_autorizar_el_plan_de_estudios\\\\\":\\\\\"Nombre y cargo de la persona facultada para autorizar el plan de estudios\\\\\",\\\\\"ai-message\\\\\":\\\\\"He entendido la solicitud y he propuesto una mejora en la redacción del perfil de ingreso, así como una sugerencia de tema de investigación relevante para el plan de estudio. Si quieres, puedo adaptar también el texto del tema a un formato específico para el campo de programa_de_investigacion.\\\\\"}\"\\n'\u001b[39m +\n",
       "  \u001b[32m\"          }\\n\"\u001b[39m +\n",
       "  \u001b[32m\"        ],\\n\"\u001b[39m +\n",
       "  \u001b[32m'        \"role\": \"assistant\"\\n'\u001b[39m +\n",
       "  \u001b[32m\"      },\\n\"\u001b[39m +\n",
       "  \u001b[32m\"      {\\n\"\u001b[39m +\n",
       "  \u001b[32m'        \"id\": \"rs_057bd8aacc77d01f006994e94329388193a9794adaa7187ce3\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"type\": \"reasoning\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"summary\": []\\n'\u001b[39m +\n",
       "  \u001b[32m\"      },\\n\"\u001b[39m +\n",
       "  \u001b[32m\"      {\\n\"\u001b[39m +\n",
       "  \u001b[32m'        \"id\": \"msg_057bd8aacc77d01f006994e942d98481938f35bf58dacf126d\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"type\": \"message\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"status\": \"completed\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"content\": [\\n'\u001b[39m +\n",
       "  \u001b[32m\"          {\\n\"\u001b[39m +\n",
       "  \u001b[32m'            \"type\": \"input_text\",\\n'\u001b[39m +\n",
       "  \u001b[32m'            \"text\": \"Dale una mejor redacción al perfil de ingreso y para el programa de investigación sugiere un tema de investigación relevante para el plan de estudio.\"\\n'\u001b[39m +\n",
       "  \u001b[32m\"          }\\n\"\u001b[39m +\n",
       "  \u001b[32m\"        ],\\n\"\u001b[39m +\n",
       "  \u001b[32m'        \"role\": \"user\"\\n'\u001b[39m +\n",
       "  \u001b[32m\"      },\\n\"\u001b[39m +\n",
       "  \u001b[32m\"      {\\n\"\u001b[39m +\n",
       "  \u001b[32m'        \"id\": \"msg_057bd8aacc77d01f006994e942d978819393e30d26e86c3ad8\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"type\": \"message\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"status\": \"completed\",\\n'\u001b[39m +\n",
       "  \u001b[32m'        \"content\": [\\n'\u001b[39m +\n",
       "  \u001b[32m\"          {\\n\"\u001b[39m +\n",
       "  \u001b[32m'            \"type\": \"input_text\",\\n'\u001b[39m +\n",
       "  \u001b[32m'            \"text\": \"Eres un asistente que ayuda a mejorar este plan de estudio: {\\\\\"id\\\\\":\\\\\"4660b774-a6e2-44f4-a340-747b41235c7c\\\\\",\\\\\"carrera_id\\\\\":\\\\\"089cdeda-d557-4a57-b49f-eb44921dfa3a\\\\\",\\\\\"estructura_id\\\\\":\\\\\"69fb2b77-5a95-47e0-bf1f-389d384200e4\\\\\",\\\\\"nombre\\\\\":\\\\\"Ingeniería en Sistemas Domóticos (2027)\\\\\",\\\\\"nivel\\\\\":\\\\\"Otro\\\\\",\\\\\"tipo_ciclo\\\\\":\\\\\"Semestre\\\\\",\\\\\"numero_ciclos\\\\\":9,\\\\\"datos\\\\\":{\\\\\"nivel\\\\\":\\\\\"Bachillerato\\\\\",\\\\\"nombre\\\\\":\\\\\"Especialización en Gravedad Cuántica de Bucles\\\\\",\\\\\"area_de_estudio\\\\\":\\\\\"Ciencias Físico-Matemáticas\\\\\",\\\\\"perfil_de_egreso\\\\\":\\\\\"La Specialización en Gravedad Cuántica de Bucles formará a un especialista capaz de integrar creativamente conocimientos avanzados en física, matemáticas y computación para enfrentar problemas teóricos y fenomenológicos en la intersección de la relatividad general y la mecánica cuántica. Al finalizar el programa, el egresado será capaz de: 1) Comprender y aplicar los fundamentos de la gravedad cuántica de bucles, incluyendo su formulación canónica, las variables de Ashtekar y el formalismo de redes de espín; 2) Desarrollar modelos y simulaciones rigurosas de fenómenos cuántico-gravitacionales, empleando métodos numéricos y herramientas de cómputo científico para analizar redes y espumas de espín, así como su relación con la cosmología cuántica; 3) Utilizar y conectar conceptos avanzados de geometría diferencial, teoría de grupos de Lie, representaciones y espinores para la construcción de estados cuánticos geométricos; 4) Resolver y comunicar de manera crítica problemas de frontera en física teórica contemporánea, integrando procesos de modelado matemático, análisis computacional y validación fenomenológica; 5) Evaluar y proponer soluciones innovadoras en entornos de trabajo colaborativo, mostrando habilidad para desarrollar proyectos científicos reproducibles bajo principios éticos y de buenas prácticas en la investigación; 6) Integrarse a comunidades científicas y continuar con estudios de posgrado o desempeñarse en entornos interdisciplinares que involucren física matemática, simulación, cosmología, información cuántica o modelado de sistemas complejos.\\\\\",\\\\\"diseno_curricular\\\\\":\\\\\"Rígido\\\\\",\\\\\"perfil_de_ingreso\\\\\":\\\\\"El aspirante debe haber concluido el bachillerato con perfil Área 1 (Ciencias Físico-Matemáticas), lo que implica sólidas bases en matemáticas, física, química, razonamiento lógico y competencia en análisis de problemas. Se espera capacidad para el aprendizaje autónomo y familiaridad con herramientas y conceptos científicos y tecnológicos, así como interés en la resolución de problemas complejos y trabajo experimental.\\\\\",\\\\\"curso_propedeutico\\\\\":\\\\\"No tiene\\\\\",\\\\\"modalidad_educativa\\\\\":\\\\\"Escolar\\\\\",\\\\\"antecedente_academico\\\\\":\\\\\"Bachillerato en Ciencias Físico-Matemáticas, con orientación en matemáticas y física; requisito previo para ingreso a la especialización. El plan asume que el aspirante ha concluido un bachillerato con áreas de Ciencias Físico-Matemáticas.\\\\'\u001b[39m... 18175 more characters"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// Listar mensajes dado una conversacion_plan.id\n",
    "const { data: conversation } = await supabase.from(\"conversaciones_plan\")\n",
    "    .select(\"openai_conversation_id\").eq(\"id\", conversationPlane.id).single();\n",
    "const items = await openai.conversations.items.list(\n",
    "    conversation.openai_conversation_id,\n",
    ");\n",
    "// items.data.filter((item) => item.type === \"message\" && [\"assistant\", \"user\"].includes(item.role))\n",
    "JSON.stringify(items, null, 2);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83e060ae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{\n",
       "  vigencia: \u001b[32m\"(Espacio para uso exclusivo de la autoridad educativa)\"\u001b[39m,\n",
       "  area_de_estudio: \u001b[32m\"Ciencias Físico-Matemáticas\"\u001b[39m,\n",
       "  perfil_de_egreso: \u001b[32m\"La Specialización en Gravedad Cuántica de Bucles formará a un especialista capaz de integrar creativamente conocimientos avanzados en física, matemáticas y computación para enfrentar problemas teóricos y fenomenológicos en la intersección de la relatividad general y la mecánica cuántica. Al finalizar el programa, el egresado será capaz de: 1) Comprender y aplicar los fundamentos de la gravedad cuántica de bucles, incluyendo su formulación canónica, las variables de Ashtekar y el formalismo de redes de espín; 2) Desarrollar modelos y simulaciones rigurosas de fenómenos cuántico-gravitacionales, empleando métodos numéricos y herramientas de cómputo científico para analizar redes y espumas de espín, así como su relación con la cosmología cuántica; 3) Utilizar y conectar conceptos avanzados de geometría diferencial, teoría de grupos de Lie, representaciones y espinores para la construcción de estados cuánticos geométricos; 4) Resolver y comunicar de manera crítica problemas de frontera en física teórica contemporánea, integrando procesos de modelado matemático, análisis computacional y validación fenomenológica; 5) Evaluar y proponer soluciones innovadoras en entornos de trabajo colaborativo, mostrando habilidad para desarrollar proyectos científicos reproducibles bajo principios éticos y de buenas prácticas en la investigación; 6) Integrarse a comunidades científicas y continuar con estudios de posgrado o desempeñarse en entornos interdisciplinares que involucren física matemática, simulación, cosmología, información cuántica o modelado de sistemas complejos.\"\u001b[39m,\n",
       "  diseno_curricular: \u001b[32m\"Rígido\"\u001b[39m,\n",
       "  perfil_de_ingreso: \u001b[32m\"El aspirante debe haber concluido el Bachillerato con perfil Área 1 (Ciencias Físico-Matemáticas), lo que implica sólidas bases en matemáticas, física, química, razonamiento lógico y competencia en análisis de problemas. Se espera capacidad para el aprendizaje autónomo y familiaridad con herramientas y conceptos científicos y tecnológicos, así como interés en la resolución de problemas complejos y trabajo experimental.\"\u001b[39m,\n",
       "  curso_propedeutico: \u001b[32m\"No tiene\"\u001b[39m,\n",
       "  modalidad_educativa: \u001b[32m\"Escolar\"\u001b[39m,\n",
       "  antecedente_academico: \u001b[32m\"Bachillerato en Ciencias Físico-Matemáticas, con orientación en matemáticas y física; requisito previo para ingreso a la especialización. El plan asume que el aspirante ha concluido un bachillerato con áreas de Ciencias Físico-Matemáticas.\"\u001b[39m,\n",
       "  carga_horaria_a_la_semana: \u001b[33m27\u001b[39m,\n",
       "  programa_de_investigacion: \u001b[32m\"No aplica\"\u001b[39m,\n",
       "  clave_del_plan_de_estudios: \u001b[32m\"2020\"\u001b[39m,\n",
       "  duracion_del_ciclo_escolar: \u001b[32m\"16 semanas\"\u001b[39m,\n",
       "  fines_de_aprendizaje_o_formacion: \u001b[32m\"Analizar fundamentos de la gravedad cuántica de bucles y su relación con la relatividad general; Diseñar modelos computacionales para explorar redes de espín y espumas cuánticas, con enfoque en cosmología cuántica; Evaluar resultados numéricos mediante criterios de reproducibilidad y validación fenomenológica; Comunicar resultados científicos de forma clara, estructurada y técnica; Integrar conceptos de domótica, electrónica, control y sistemas computacionales mediante herramientas de simulación para proyectos interdisciplinarios y el desarrollo de asistentes virtuales; Aplicar herramientas de cómputo para la creación de proyectos con código reproducible y documentación adecuada; Desarrollar capacidades de trabajo en equipo, ética científica y buenas prácticas en investigación.\"\u001b[39m,\n",
       "  nivel_y_nombre_del_plan_de_estudios: \u001b[32m\"Nivel y nombre del plan de estudios\"\u001b[39m,\n",
       "  nombre_autorizado_de_la_institucion: \u001b[32m\"Nombre autorizado de la institución\"\u001b[39m,\n",
       "  total_de_ciclos_del_plan_de_estudios: \u001b[32m\"9\"\u001b[39m,\n",
       "  sustento_teorico_del_modelo_curricular: \u001b[32m\"No aplica\"\u001b[39m,\n",
       "  justificacion_de_la_propuesta_curricular: \u001b[32m\"No aplica\"\u001b[39m,\n",
       "  administracion_y_operatividad_del_plan_de_estudios: \u001b[32m\"La administración y operatividad del plan de estudios se ubica bajo la Dirección de Asuntos Académicos - Anexo 1; modalidad escolar; estructura rígida con 9 ciclos; carga horaria semanal de 27 horas; responsable: Lic. María González Pérez, Directora Académica; procesos de revisión y actualización conforme a la Propuesta de Evaluación Periódica y a los lineamientos del Acuerdo 17/11/17.\"\u001b[39m,\n",
       "  propuesta_de_evaluacion_periodica_del_plan_de_estudios: \u001b[32m\"Nivel de evaluación curricular interna: diagnóstico de estructura y operación. Análisis técnico-pedagógico del planteamiento curricular vigente; consulta a directivos del área académica para valorar problemáticas de formación y operación; consulta a docentes sobre problemáticas de formación, operación y necesidades disciplinarias; estudio de opinión de estudiantes sobre la formación y operación. Nivel de evaluación curricular externa: diagnóstico de impacto y prácticas profesionales. Análisis del estado del conocimiento en campos disciplinarios vinculados al programa, comparación de planes y tendencias en criterios de organismos evaluadores; estudio con egresados y empleadores para valorar inserción laboral y requerimientos actuales; recopilación de criterios y reformas necesarias para mantener el programa actualizado y acorde con la disciplina.\"\u001b[39m,\n",
       "  nombre_y_cargo_de_la_persona_facultada_para_autorizar_el_plan_de_estudios: \u001b[32m\"Nombre y cargo de la persona facultada para autorizar el plan de estudios\"\u001b[39m,\n",
       "  \u001b[32m\"ai-message\"\u001b[39m: \u001b[32m\"He entendido la solicitud y he propuesto una mejora en la redacción del perfil de ingreso, así como una sugerencia de tema de investigación relevante para el plan de estudio. Si quieres, puedo adaptar también el texto del tema a un formato específico para el campo de programa_de_investigacion.\"\u001b[39m\n",
       "}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// Add a message to the conversation\n",
    "const campos = [\"programa_de_investigacion\", \"perfil_de_ingreso\"];\n",
    "\n",
    "const { data: conversationToUpdate } = await supabase.from(\n",
    "    \"conversaciones_plan\",\n",
    ").select(\"openai_conversation_id\").eq(\n",
    "    \"id\",\n",
    "    conversationPlane.id,\n",
    ").single();\n",
    "\n",
    "const definicion = input.estructuras_plan.definicion;\n",
    "\n",
    "// Estructura que hace que la IA incluya mensaje, en la estructura le agregará otro campo llamado \"ai-mensaje\"\n",
    "const estructura_complementaria_de_respuesta = {\n",
    "    properties: {\n",
    "        \"ai-message\": {\n",
    "            type: \"string\",\n",
    "            description:\n",
    "                \"Un mensaje que la IA incluirá en su respuesta para el usuario final que le confirme que ha entendido la solicitud y que ha mejorado el plan de estudio\",\n",
    "            examples: [\n",
    "                \"Claro, aquí tienes una mejor redacción para el perfil de ingreso. Además, he sugerido el siguiente tema de investigación relevante para el plan de estudio.\",\n",
    "            ],\n",
    "        },\n",
    "        \"is_refusal\": {\n",
    "            type: \"boolean\",\n",
    "            description:\n",
    "                \"Un campo booleano que la IA incluirá en su respuesta. Si el mensaje del usuario no tiene nada que ver con planes de estudio o asignaturas, la IA responderá con un refusal, lo que se indicará con este campo en true y el campo ai-message tendrá un mensaje para el usuario final indicando que no puede responder a esa solicitud.\",\n",
    "        },\n",
    "    },\n",
    "};\n",
    "\n",
    "if (definicion?.type === \"object\" && definicion?.properties) {\n",
    "    const entries = Object.entries(definicion.properties).filter(([key]) =>\n",
    "        campos.includes(key)\n",
    "    );\n",
    "\n",
    "    input.estructuras_plan.definicion = {\n",
    "        ...definicion,\n",
    "        properties: Object.fromEntries(entries),\n",
    "        required: Array.isArray(definicion.required)\n",
    "            ? definicion.required.filter((key) => campos.includes(key))\n",
    "            : undefined,\n",
    "    };\n",
    "}\n",
    "\n",
    "if (definicion?.properties) {\n",
    "    definicion.properties = {\n",
    "        ...definicion.properties,\n",
    "        ...estructura_complementaria_de_respuesta.properties,\n",
    "    };\n",
    "    definicion.required = [\n",
    "        ...(definicion.required || []),\n",
    "        ...Object.keys(estructura_complementaria_de_respuesta.properties),\n",
    "    ];\n",
    "}\n",
    "\n",
    "const plan_sin_estructura = { ...input, estructuras_plan: undefined };\n",
    "\n",
    "const mejoras = await openai.responses.create({\n",
    "    conversation: conversationToUpdate.openai_conversation_id,\n",
    "    model: \"gpt-5-nano\",\n",
    "    text: {\n",
    "        format: { type: \"json_schema\", name: \"definicion\", schema: definicion },\n",
    "    },\n",
    "    metadata: {\n",
    "        usuario: \"admin\",\n",
    "        plan_estudio_id: input.id,\n",
    "    },\n",
    "    input: [{\n",
    "        role: \"system\",\n",
    "        content: `Eres un asistente que ayuda a mejorar este plan de estudio: ${\n",
    "            JSON.stringify(plan_sin_estructura)\n",
    "        }. Si te hacen una pregunta que no tiene nada que ver con el plan de estudio, responde con un refusal.`,\n",
    "    }, {\n",
    "        role: \"user\",\n",
    "        content:\n",
    "            \"Dale una mejor redacción al perfil de ingreso y para el programa de investigación sugiere un tema de investigación relevante para el plan de estudio.\",\n",
    "    }],\n",
    "});\n",
    "JSON.parse(mejoras.output_text);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "3e705a02",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{ data: { ok: true }, error: null }\n"
     ]
    }
   ],
   "source": [
    "const { data, error } = await supabase.functions.invoke(\n",
    "    \"create-chat-conversation/health\",\n",
    "    {\n",
    "        method: \"GET\",\n",
    "    },\n",
    ");\n",
    "\n",
    "console.log({ data, error });\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "57e06acc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  data: {\n",
      "    conversation_plan: {\n",
      "      id: \"e9063a5c-c48f-4682-9f9a-1eef805a3e51\",\n",
      "      plan_estudio_id: \"4660b774-a6e2-44f4-a340-747b41235c7c\",\n",
      "      openai_conversation_id: \"conv_698f6651077c8194b9f75e0b65443a7d0bf4bdc062c70308\",\n",
      "      estado: \"ACTIVA\"\n",
      "    }\n",
      "  },\n",
      "  error: null\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "const { data, error } = await supabase.functions.invoke(\n",
    "    \"create-chat-conversation/conversations\",\n",
    "    {\n",
    "        method: \"POST\",\n",
    "        body: {\n",
    "            plan_estudio_id: input.id,\n",
    "            instanciador: \"alex\",\n",
    "        },\n",
    "    },\n",
    ");\n",
    "\n",
    "console.log({ data, error });\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "3426d5ff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  respuesta: {\n",
      "    ok: true,\n",
      "    openai_response_id: \"resp_0bf4bdc062c7030800698f6653ae5c819490e18346014719d7\",\n",
      "    raw: '{\"perfil_de_ingreso\":\"El aspirante debe haber concluido el bachillerato con perfil Área 1 (Ciencias Físico-Matemáticas). Se requieren fundamentos sólidos en matemáticas (álgebra lineal, cálculo, análisis), física (mecánica clásica y electromagnetismo a nivel de bachillerato; introducción a la física cuántica) y química básica, así como razonamiento lógico, capacidad de análisis de problemas y habilidades de lectura científica. Se valorará experiencia en actividades de laboratorio y en el manejo de herramientas computacionales para simulación (p. ej., programación en Python, MATLAB u otros). El candidato debe demostrar autonomía en el aprendizaje, claridad en la comunicación escrita y oral, facilidad para trabajar en equipo, ética en la investigación y un interés demostrado por problemáticas complejas de la física teórica y su relación con la tecnología y el modelado computacional. Se espera disposición para abordar conceptos avanzados de forma progresiva, con competencia para supervisar proyectos cortos y colaborar de forma responsable.\",\"programa_de_investigacion\":\"Propuesta de programa de investigación orientado al Bachillerato en Gravedad Cuántica de Bucles: Línea principal: Modelos simplificados de redes de espín para ilustrar la geometría cuántica emergente. Objetivos: (i) implementar simulaciones simples de redes de espín en 2D; (ii) estudiar observables básicos que permitan visualizar la transición entre estructuras discretas y conceptos geométros; (iii) desarrollar recursos didácticos (cuadernos de ejercicios, cuadernos Jupyter) para divulgación y aprendizaje. Vinculación con asignaturas: Física y Matemáticas (bases teóricas), Informática (programación y simulación). Metodología: prácticas computacionales con Python/NumPy, análisis de resultados y presentaciones; evaluación a través de bitácoras, informes reproducibles y presentaciones orales. Perfil docente: docentes con experiencia en física teórica, simulación numérica y didáctica de conceptos complejos. Observaciones: el programa se adecua a un plan de Bachillerato con enfoque pedagógico y reproducibilidad.\",\"ai-message\":\"Se mejoró la redacción del perfil de ingreso para mayor claridad y se propuso un tema de investigación orientado a líneas didácticas y prácticas computacionales para la gravedad cuántica de bucles.\"}'\n",
      "  },\n",
      "  error: null\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "const { data: respuesta, error } = await supabase.functions.invoke(\n",
    "    `create-chat-conversation/conversations/${data.conversation_plan.id}/messages`,\n",
    "    {\n",
    "        method: \"POST\",\n",
    "        body: {\n",
    "            content:\n",
    "                \"Dale mejor redacción al perfil de ingreso y sugiere tema de investigación.\",\n",
    "            campos: [\"perfil_de_ingreso\", \"programa_de_investigacion\"],\n",
    "        },\n",
    "    },\n",
    ");\n",
    "\n",
    "console.log({ respuesta, error });\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "c68073e8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"source\": \"openai\",\n",
      "  \"items\": [\n",
      "    {\n",
      "      \"role\": \"assistant\",\n",
      "      \"content\": {\n",
      "        \"perfil_de_ingreso\": \"El aspirante debe haber concluido el bachillerato con perfil Área 1 (Ciencias Físico-Matemáticas). Se requieren fundamentos sólidos en matemáticas (álgebra lineal, cálculo, análisis), física (mecánica clásica y electromagnetismo a nivel de bachillerato; introducción a la física cuántica) y química básica, así como razonamiento lógico, capacidad de análisis de problemas y habilidades de lectura científica. Se valorará experiencia en actividades de laboratorio y en el manejo de herramientas computacionales para simulación (p. ej., programación en Python, MATLAB u otros). El candidato debe demostrar autonomía en el aprendizaje, claridad en la comunicación escrita y oral, facilidad para trabajar en equipo, ética en la investigación y un interés demostrado por problemáticas complejas de la física teórica y su relación con la tecnología y el modelado computacional. Se espera disposición para abordar conceptos avanzados de forma progresiva, con competencia para supervisar proyectos cortos y colaborar de forma responsable.\",\n",
      "        \"programa_de_investigacion\": \"Propuesta de programa de investigación orientado al Bachillerato en Gravedad Cuántica de Bucles: Línea principal: Modelos simplificados de redes de espín para ilustrar la geometría cuántica emergente. Objetivos: (i) implementar simulaciones simples de redes de espín en 2D; (ii) estudiar observables básicos que permitan visualizar la transición entre estructuras discretas y conceptos geométros; (iii) desarrollar recursos didácticos (cuadernos de ejercicios, cuadernos Jupyter) para divulgación y aprendizaje. Vinculación con asignaturas: Física y Matemáticas (bases teóricas), Informática (programación y simulación). Metodología: prácticas computacionales con Python/NumPy, análisis de resultados y presentaciones; evaluación a través de bitácoras, informes reproducibles y presentaciones orales. Perfil docente: docentes con experiencia en física teórica, simulación numérica y didáctica de conceptos complejos. Observaciones: el programa se adecua a un plan de Bachillerato con enfoque pedagógico y reproducibilidad.\",\n",
      "        \"ai-message\": \"Se mejoró la redacción del perfil de ingreso para mayor claridad y se propuso un tema de investigación orientado a líneas didácticas y prácticas computacionales para la gravedad cuántica de bucles.\"\n",
      "      }\n",
      "    },\n",
      "    {\n",
      "      \"role\": \"user\",\n",
      "      \"content\": \"Dale mejor redacción al perfil de ingreso y sugiere tema de investigación.\"\n",
      "    }\n",
      "  ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "const { data: respuesta, error } = await supabase.functions.invoke(\n",
    "    `create-chat-conversation/conversations/${data.conversation_plan.id}/messages`,\n",
    "    {\n",
    "        method: \"GET\",\n",
    "    },\n",
    ");\n",
    "\n",
    "console.log(JSON.stringify(respuesta, null, 2));\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7fbae7c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{ ok: \u001b[33mtrue\u001b[39m }"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "const { data: respuesta, error } = await supabase.functions.invoke(\n",
    "    `create-chat-conversation/conversations/${data.conversation_plan.id}/archive`,\n",
    "    {\n",
    "        method: \"DELETE\",\n",
    "    },\n",
    ");\n",
    "\n",
    "respuesta;\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "852fa8b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[32m\"conv_6994e936d58c8193b1879a403aac5adf057bd8aacc77d01f\"\u001b[39m"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conversationToUpdate.openai_conversation_id;\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "622026da",
   "metadata": {},
   "outputs": [
    {
     "ename": "Error",
     "evalue": "400 Invalid 'thread_id': 'conv_6994e936d58c8193b1879a403aac5adf057bd8aacc77d01f'. Expected an ID that begins with 'thread'.",
     "output_type": "error",
     "traceback": [
      "Stack trace:",
      "Error: 400 Invalid 'thread_id': 'conv_6994e936d58c8193b1879a403aac5adf057bd8aacc77d01f'. Expected an ID that begins with 'thread'.",
      "    at APIError.generate (https://jsr.io/@openai/openai/6.16.0/core/error.ts:72:14)",
      "    at OpenAI.makeStatusError (https://jsr.io/@openai/openai/6.16.0/client.ts:478:28)",
      "    at OpenAI.makeRequest (https://jsr.io/@openai/openai/6.16.0/client.ts:728:24)",
      "    at eventLoopTick (ext:core/01_core.js:187:7)",
      "    at async <anonymous>:1:22"
     ]
    }
   ],
   "source": [
    "await openai.beta.threads.messages.retrieve(\n",
    "    \"msg_057bd8aacc77d01f006994e942d98481938f35bf58dacf126d\",\n",
    "    { thread_id: conversationToUpdate.openai_conversation_id },\n",
    ");\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb6e9cb8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Deno",
   "language": "typescript",
   "name": "deno"
  },
  "language_info": {
   "codemirror_mode": "typescript",
   "file_extension": ".ts",
   "mimetype": "text/x.typescript",
   "name": "typescript",
   "nbconvert_exporter": "script",
   "pygments_lexer": "typescript",
   "version": "5.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
