# embeddings_queue

created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 6cee0db9-8896-4c43-a512-65b065a6413c
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"6cee0db9-8896-4c43-a512-65b065a6413c\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"3678aec0-f200-4b15-9bf2-709223c53c7a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"57fbcc7889cfdfe39ed183bb0a83eac93e46878023c8ab7b47132e8af66f3bba\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e60d315c-32b8-4f23-8905-8eee0b8dd101\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"9494567576bf19e6efd626c8802f6e519e4b30ae3772115610f74cf87376f541\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10330, \"end_char_idx\": 13904, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "const pdfContents = await pdfParse(buffer);\n            return pdfContents.text;\n        } else if (fileType === '.txt') {\n            // If the type is txt, it does not need to create a stream and instead just grabs the content\n            response = await client.api(filePath).get();\n            return response;\n        }  else if (fileType === '.csv') {\n            response = await client.api(filePath).getStream();\n            let chunks = [];\n            for await (let chunk of response) {\n                chunks.push(chunk);\n            }\n            let buffer = Buffer.concat(chunks);\n            let dataString = buffer.toString('utf-8');\n            return dataString\n            \n    } else {\n        return 'Unsupported File Type';\n    }\n     \n    } catch (error) {\n        console.error('Error fetching drive content:', error);\n        throw new Error(`Failed to fetch content for ${name}: ${error.message}`);\n    }\n};\n```\n\n#### Integrating GPT 4o mini for Text Analysis\n\nThis function utilizes the OpenAI SDK to analyze text extracted from documents and find relevant information based on a user query. This helps to ensure only relevant text to the user\u2019s question is returned to the GPT.\u00a0\n\n```javascript\nconst getRelevantParts = async (text, query) => {\n    try {\n        // We use your OpenAI key to initialize the OpenAI client\n        const openAIKey = process.env[\"OPENAI_API_KEY\"];\n        const openai = new OpenAI({\n            apiKey: openAIKey,\n        });\n        const response = await openai.chat.completions.create({\n            // Using gpt-4o-mini due to speed to prevent timeouts. You can tweak this prompt as needed\n            model: \"gpt-4o-mini\",\n            messages: [\n                {\"role\": \"system\", \"content\": \"You are a helpful assistant that finds relevant content in text based on a query. You only return the relevant sentences, and you return a maximum of 10 sentences\"},\n                {\"role\": \"user\", \"content\": `Based on this question: **\"${query}\"**, get the relevant parts from the following text:*****\\n\\n${text}*****. If you cannot answer the question based on the text, respond with 'No information provided'`}\n            ],\n            // using temperature of 0 since we want to just extract the relevant content\n            temperature: 0,\n            // using max_tokens of 1000, but you can customize this based on the number of documents you are searching. \n            max_tokens: 1000\n        });\n        return response.choices[0].message.content;\n    } catch (error) {\n        console.error('Error with OpenAI:', error);\n        return 'Error processing text with OpenAI' + error;\n    }\n};\n```\n\n#### Creating the Azure Function to Handle Requests\n\nNow that we have all these helper functions, the Azure Function will orchestrate the flow, by authenticating the user, performing the search, and iterating through the search results to extract the text and retrieve the relevant parts of the text to the GPT.\n\n**Handling HTTP Requests:** The function starts by extracting the query and searchTerm from the HTTP request. It checks if the Authorization header is present and extracts the bearer token.\n\n**Authentication:** Using the bearer token, it obtains an OBO token from Microsoft's identity platform using getOboToken defined above.\n\n**Initializing the Graph Client:** With the OBO token, it initializes the Microsoft Graph client using initGraphClient defined above.\n\n**Document Search:** It constructs a search query and sends it to the Microsoft Graph API to find documents based on the searchTerm."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: e60d315c-32b8-4f23-8905-8eee0b8dd101
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"e60d315c-32b8-4f23-8905-8eee0b8dd101\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6cee0db9-8896-4c43-a512-65b065a6413c\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"21f4995f091e83614940aecbcab00a273dd2bdb311e1a49053f8d2cb24a2687b\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"2c52bd69-5e7b-4196-bf53-a6f622b8ffef\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"be676deb2006b94321d8fc57dd8b857e6530e26b35a2d894bfc254d7714d0e76\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 12169, \"end_char_idx\": 15817, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "You only return the relevant sentences, and you return a maximum of 10 sentences\"},\n                {\"role\": \"user\", \"content\": `Based on this question: **\"${query}\"**, get the relevant parts from the following text:*****\\n\\n${text}*****. If you cannot answer the question based on the text, respond with 'No information provided'`}\n            ],\n            // using temperature of 0 since we want to just extract the relevant content\n            temperature: 0,\n            // using max_tokens of 1000, but you can customize this based on the number of documents you are searching. \n            max_tokens: 1000\n        });\n        return response.choices[0].message.content;\n    } catch (error) {\n        console.error('Error with OpenAI:', error);\n        return 'Error processing text with OpenAI' + error;\n    }\n};\n```\n\n#### Creating the Azure Function to Handle Requests\n\nNow that we have all these helper functions, the Azure Function will orchestrate the flow, by authenticating the user, performing the search, and iterating through the search results to extract the text and retrieve the relevant parts of the text to the GPT.\n\n**Handling HTTP Requests:** The function starts by extracting the query and searchTerm from the HTTP request. It checks if the Authorization header is present and extracts the bearer token.\n\n**Authentication:** Using the bearer token, it obtains an OBO token from Microsoft's identity platform using getOboToken defined above.\n\n**Initializing the Graph Client:** With the OBO token, it initializes the Microsoft Graph client using initGraphClient defined above.\n\n**Document Search:** It constructs a search query and sends it to the Microsoft Graph API to find documents based on the searchTerm.\n\n**Document Processing**: For each document returned by the search:\n\n- It retrieves the document content using getDriveItemContent.\n\n- If the file type is supported, it analyzes the content using getRelevantParts, which sends the text to OpenAI's model for extracting relevant information based on the query.\n\n- It collects the analysis results and includes metadata like the document name and URL.\n\n**Response**: The function sorts the results by relevance and sends them back in the HTTP response.\n\n```javascript\nmodule.exports = async function (context, req) {\n    const query = req.query.query || (req.body && req.body.query);\n    const searchTerm = req.query.searchTerm || (req.body && req.body.searchTerm);\n    if (!req.headers.authorization) {\n        context.res = {\n            status: 400,\n            body: 'Authorization header is missing'\n        };\n        return;\n    }\n    /// The below takes the token passed to the function, to use to get an OBO token.\n    const bearerToken = req.headers.authorization.split(' ')[1];\n    let accessToken;\n    try {\n        accessToken = await getOboToken(bearerToken);\n    } catch (error) {\n        context.res = {\n            status: 500,\n            body: `Failed to obtain OBO token: ${error.message}`\n        };\n        return;\n    }\n    // Initialize the Graph Client using the initGraphClient function defined above\n    let client = initGraphClient(accessToken);\n    // this is the search body to be used in the Microsft Graph Search API: https://learn.microsoft.com/en-us/graph/search-concept-files\n    const requestBody = {\n        requests: [\n            {\n                entityTypes: ['driveItem'],\n                query: {\n                    queryString: searchTerm\n                },\n                from: 0,\n                // the below is set to summarize the top 10 search results from the Graph API, but can configure based on your documents."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 2c52bd69-5e7b-4196-bf53-a6f622b8ffef
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"2c52bd69-5e7b-4196-bf53-a6f622b8ffef\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e60d315c-32b8-4f23-8905-8eee0b8dd101\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"ec8691a09a2693c4fb4442a92b8114ac104e46beeedfa71db4dad97e15ed3c75\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"46495823-25ea-47bf-89e2-1f6bb234a04e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ada524fd571cbf3ec2ccf3fb2a52eb3955843ac086c1ae47598e4412f3e09ed2\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 13906, \"end_char_idx\": 15950, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "**Document Processing**: For each document returned by the search:\n\n- It retrieves the document content using getDriveItemContent.\n\n- If the file type is supported, it analyzes the content using getRelevantParts, which sends the text to OpenAI's model for extracting relevant information based on the query.\n\n- It collects the analysis results and includes metadata like the document name and URL.\n\n**Response**: The function sorts the results by relevance and sends them back in the HTTP response.\n\n```javascript\nmodule.exports = async function (context, req) {\n    const query = req.query.query || (req.body && req.body.query);\n    const searchTerm = req.query.searchTerm || (req.body && req.body.searchTerm);\n    if (!req.headers.authorization) {\n        context.res = {\n            status: 400,\n            body: 'Authorization header is missing'\n        };\n        return;\n    }\n    /// The below takes the token passed to the function, to use to get an OBO token.\n    const bearerToken = req.headers.authorization.split(' ')[1];\n    let accessToken;\n    try {\n        accessToken = await getOboToken(bearerToken);\n    } catch (error) {\n        context.res = {\n            status: 500,\n            body: `Failed to obtain OBO token: ${error.message}`\n        };\n        return;\n    }\n    // Initialize the Graph Client using the initGraphClient function defined above\n    let client = initGraphClient(accessToken);\n    // this is the search body to be used in the Microsft Graph Search API: https://learn.microsoft.com/en-us/graph/search-concept-files\n    const requestBody = {\n        requests: [\n            {\n                entityTypes: ['driveItem'],\n                query: {\n                    queryString: searchTerm\n                },\n                from: 0,\n                // the below is set to summarize the top 10 search results from the Graph API, but can configure based on your documents. \n                size: 10\n            }\n        ]\n    };\n\n    try { \n        // Function to tokenize content (e.g., based on words)."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 46495823-25ea-47bf-89e2-1f6bb234a04e
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"46495823-25ea-47bf-89e2-1f6bb234a04e\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"2c52bd69-5e7b-4196-bf53-a6f622b8ffef\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"79789c425d13ac78eb190bac032e217ffee3f3e60cf88fa87381551221c8e9e9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"abab3bc3-dc35-4488-8074-5bf5c5ef1d04\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"4285ee4fb199e3ef7d27569ec6aac3e35e01892efbd1ac4423a78556ac2ae142\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 14038, \"end_char_idx\": 19238, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "- If the file type is supported, it analyzes the content using getRelevantParts, which sends the text to OpenAI's model for extracting relevant information based on the query.\n\n- It collects the analysis results and includes metadata like the document name and URL.\n\n**Response**: The function sorts the results by relevance and sends them back in the HTTP response.\n\n```javascript\nmodule.exports = async function (context, req) {\n    const query = req.query.query || (req.body && req.body.query);\n    const searchTerm = req.query.searchTerm || (req.body && req.body.searchTerm);\n    if (!req.headers.authorization) {\n        context.res = {\n            status: 400,\n            body: 'Authorization header is missing'\n        };\n        return;\n    }\n    /// The below takes the token passed to the function, to use to get an OBO token.\n    const bearerToken = req.headers.authorization.split(' ')[1];\n    let accessToken;\n    try {\n        accessToken = await getOboToken(bearerToken);\n    } catch (error) {\n        context.res = {\n            status: 500,\n            body: `Failed to obtain OBO token: ${error.message}`\n        };\n        return;\n    }\n    // Initialize the Graph Client using the initGraphClient function defined above\n    let client = initGraphClient(accessToken);\n    // this is the search body to be used in the Microsft Graph Search API: https://learn.microsoft.com/en-us/graph/search-concept-files\n    const requestBody = {\n        requests: [\n            {\n                entityTypes: ['driveItem'],\n                query: {\n                    queryString: searchTerm\n                },\n                from: 0,\n                // the below is set to summarize the top 10 search results from the Graph API, but can configure based on your documents. \n                size: 10\n            }\n        ]\n    };\n\n    try { \n        // Function to tokenize content (e.g., based on words). \n        const tokenizeContent = (content) => {\n            return content.split(/\\s+/);\n        };\n\n        // Function to break tokens into 10k token windows for gpt-4o-mini\n        const breakIntoTokenWindows = (tokens) => {\n            const tokenWindows = []\n            const maxWindowTokens = 10000; // 10k tokens\n            let startIndex = 0;\n\n            while (startIndex < tokens.length) {\n                const window = tokens.slice(startIndex, startIndex + maxWindowTokens);\n                tokenWindows.push(window);\n                startIndex += maxWindowTokens;\n            }\n\n            return tokenWindows;\n        };\n        // This is where we are doing the search\n        const list = await client.api('/search/query').post(requestBody);\n\n        const processList = async () => {\n            // This will go through and for each search response, grab the contents of the file and summarize with gpt-4o-mini\n            const results = [];\n\n            await Promise.all(list.value[0].hitsContainers.map(async (container) => {\n                for (const hit of container.hits) {\n                    if (hit.resource[\"@odata.type\"] === \"#microsoft.graph.driveItem\") {\n                        const { name, id } = hit.resource;\n                        // We use the below to grab the URL of the file to include in the response\n                        const webUrl = hit.resource.webUrl.replace(/\\s/g, \"%20\");\n                        // The Microsoft Graph API ranks the reponses, so we use this to order it\n                        const rank = hit.rank;\n                        // The below is where the file lives\n                        const driveId = hit.resource.parentReference.driveId;\n                        const contents = await getDriveItemContent(client, driveId, id, name);\n                        if (contents !== 'Unsupported File Type') {\n                            // Tokenize content using function defined previously\n                            const tokens = tokenizeContent(contents);\n\n                            // Break tokens into 10k token windows\n                            const tokenWindows = breakIntoTokenWindows(tokens);\n\n                            // Process each token window and combine results\n                            const relevantPartsPromises = tokenWindows.map(window => getRelevantParts(window.join(' '), query));\n                            const relevantParts = await Promise.all(relevantPartsPromises);\n                            const combinedResults = relevantParts.join('\\n'); // Combine results\n\n                            results.push({ name, webUrl, rank, contents: combinedResults });\n                        } \n                        else {\n                            results.push({ name, webUrl, rank, contents: 'Unsupported File Type' });\n                        }\n                    }\n                }\n            }));\n\n            return results;\n        };\n        let results;\n        if (list.value[0].hitsContainers[0].total == 0) {\n            // Return no results found to the API if the Microsoft Graph API returns no results\n            results = 'No results found';\n        } else {\n            // If the Microsoft Graph API does return results, then run processList to iterate through."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: abab3bc3-dc35-4488-8074-5bf5c5ef1d04
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"abab3bc3-dc35-4488-8074-5bf5c5ef1d04\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"46495823-25ea-47bf-89e2-1f6bb234a04e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"06499acc0aa9a5b19d2d70f013274e16876f971ee71744c8ad7c89afd3408cfb\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"9a1dac56-2e42-470f-8954-d3bcffe0985b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"81b5ea3f42ac50c6082230d37b203b4a8293be492fc29a8321e924bbc74fa81b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 19251, \"end_char_idx\": 21083, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "results = await processList();\n            results.sort((a, b) => a.rank - b.rank);\n        }\n        context.res = {\n            status: 200,\n            body: results\n        };\n    } catch (error) {\n        context.res = {\n            status: 500,\n            body: `Error performing search or processing results: ${error.message}`,\n        };\n    }\n};\n```\n\n### Customizations\n\nBelow are some potential areas to customize.\u00a0\n\n- You can customize the GPT prompt to search again a certain amount of times if nothing is found.\n\n- You can customize the code to only search through specific SharePoint sites or O365 Drives by customizing the search query. This will help focus the search and improve the retrieval. The function as setup now looks through all files the logged-in user can access.\n\n- You could use gpt-4o instead of gpt-4o-mini. This would slightly increase the cost and latency, but you may get higher quality summarizations.\n\n- You can customize the amount of files it searches through within the call to Microsoft Graph.\n\n\n### Considerations\n\nNote that all the same limitations of Actions apply here, with regards to returning 100K characters or less and the [45 second timeout](https://platform.openai.com/docs/actions/production/timeouts).\n\n\n- This only works for text, not for images. With some additional code in the Azure Function, you could customize this by using GPT-4o to extract summarizations of images.\n\n- This does not work for structured data. We recommend Solution 1 if structured data is a major part of your use case.\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\nOnce you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 9a1dac56-2e42-470f-8954-d3bcffe0985b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"9a1dac56-2e42-470f-8954-d3bcffe0985b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"abab3bc3-dc35-4488-8074-5bf5c5ef1d04\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"01a224aae8edb27c52d00ba114df8c160ec82ef9c86c4469720ef262b3d32c74\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"932af17e-a54a-48a6-b990-b30d129dded4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"087d3578ad1060509da92b5592ca5dae883e732b59df56a47dbf6617393fdb31\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 19251, \"end_char_idx\": 23258, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "results = await processList();\n            results.sort((a, b) => a.rank - b.rank);\n        }\n        context.res = {\n            status: 200,\n            body: results\n        };\n    } catch (error) {\n        context.res = {\n            status: 500,\n            body: `Error performing search or processing results: ${error.message}`,\n        };\n    }\n};\n```\n\n### Customizations\n\nBelow are some potential areas to customize.\u00a0\n\n- You can customize the GPT prompt to search again a certain amount of times if nothing is found.\n\n- You can customize the code to only search through specific SharePoint sites or O365 Drives by customizing the search query. This will help focus the search and improve the retrieval. The function as setup now looks through all files the logged-in user can access.\n\n- You could use gpt-4o instead of gpt-4o-mini. This would slightly increase the cost and latency, but you may get higher quality summarizations.\n\n- You can customize the amount of files it searches through within the call to Microsoft Graph.\n\n\n### Considerations\n\nNote that all the same limitations of Actions apply here, with regards to returning 100K characters or less and the [45 second timeout](https://platform.openai.com/docs/actions/production/timeouts).\n\n\n- This only works for text, not for images. With some additional code in the Azure Function, you could customize this by using GPT-4o to extract summarizations of images.\n\n- This does not work for structured data. We recommend Solution 1 if structured data is a major part of your use case.\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\nOnce you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n\n```python\nYou are a Q&A helper that helps answer users questions. You have access to a documents repository through your API action. When a user asks a question, you pass in that question exactly as stated to the \"query\" parameter, and for the \"searchTerm\" you use a single keyword or term you think you should use for the search.\n\n****\n\nScenario 1: There are answers\n\nIf your action returns results, then you take the results from the action and summarize concisely with the webUrl returned from the action. You answer the users question to the best of your knowledge from the action\n\n****\n\nScenario 2: No results found\n\nIf the response you get from the action is \"No results found\", stop there and let the user know there were no results and that you are going to try a different search term, and explain why. You must always let the user know before conducting another search.\n\nExample:\n\n****\n\nI found no results for \"DEI\". I am now going to try [insert term] because [insert explanation]\n\n****\n\nThen, try a different searchTerm that is similar to the one you tried before, with a single word.\u00a0\n\nTry this three times. After the third time, then let the user know you did not find any relevant documents to answer the question, and to check SharePoint. Be sure to be explicit about what you are searching for at each step.\n\n****\n\nIn either scenario, try to answer the user's question. If you cannot answer the user's question based on the knowledge you find, let the user know and ask them to go check the HR Docs in SharePoint. If the file is a CSV, XLSX, or XLS, you can tell the user to download the file using the link and re-upload to use Advanced Data Analysis.\n```\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\nThe below spec passes in the `query` parameter to inform the pre-processing and a `searchTerm` to find the right files in Microsoft Graph.\n>Make sure to switch the function app name, function name and code based on link copied in screenshot above"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 932af17e-a54a-48a6-b990-b30d129dded4
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"932af17e-a54a-48a6-b990-b30d129dded4\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"9a1dac56-2e42-470f-8954-d3bcffe0985b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"00a91a6650e9d22a0145b8d36df74f132f355109bf3164e1eaf128f76945d98d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"7968d94b-dc76-44ce-ac74-46e2f9e474c6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"9da297155d9b7eccca24550bdaef40745cde3f4162cabb0cf922ba571d183b39\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 23261, \"end_char_idx\": 26896, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "```python\nopenapi: 3.1.0\ninfo:\n  title: SharePoint Search API\n  description: API for searching SharePoint documents.\n  version: 1.0.0\nservers:\n  - url: https://{your_function_app_name}.azurewebsites.net/api\n    description: SharePoint Search API server\npaths:\n  /{your_function_name}?code={enter your specific endpoint id here}:\n    post:\n      operationId: searchSharePoint\n      summary: Searches SharePoint for documents matching a query and term.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                query:\n                  type: string\n                  description: The full query to search for in SharePoint documents.\n                searchTerm:\n                  type: string\n                  description: A specific term to search for within the documents.\n      responses:\n        '200':\n          description: Search results\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  type: object\n                  properties:\n                    documentName:\n                      type: string\n                      description: The name of the document.\n                    snippet:\n                      type: string\n                      description: A snippet from the document containing the search term.\n                    url:\n                      type: string\n                      description: The URL to access the document.\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n*See above and on the [Azure Function cookbook](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function) for more detailed instructions on authentication.*\n\n## FAQ & Troubleshooting\n\n- Why are you using the Microsoft Graph API in your code instead of the [SharePoint API](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom)?\n\n  - The SharePoint API is legacy - per the Microsoft documentation [here](https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph), \u201cFor SharePoint Online, innovation using a REST API against SharePoint is driven via the Microsoft Graph REST API's.\u201d The Graph API gives us more flexibility, and the SharePoint API still runs into the same file issues listed in the [Why is this necessary instead of interacting with the Microsoft Graph API directly?](#why-is-this-necessary-instead-of-interacting-with-the-microsoft-api-directly) section.\n\n- What types of files does this support?\n    1. This supports all files listed in the documentation for the Convert File endpoint [_here_](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http). Specifically, it supports _pdf, doc, docx, odp, ods, odt, pot, potm, potx, pps, ppsx, ppsxm, ppt, pptm, pptx, rtf_.\n\n    2. When a search result returns XLS, XLSX, or CSV, this prompts the user to download the file and re-upload to ask questions using Advanced Data Analysis. As stated above, we recommend solution 1 if structured data is part of your use case.\n\n- Why do I need to request an OBO token?\n\n  - When you try to use the same token to authenticate to the Graph API as the one you use to authenticate into the Azure Function, you get an \u201cinvalid audience\u201d token."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 7968d94b-dc76-44ce-ac74-46e2f9e474c6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb", "title": "GPT Action Library: Sharepoint (Return as Document)", "tokens": 5886, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"7968d94b-dc76-44ce-ac74-46e2f9e474c6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0bad2d8c-273e-43e2-b615-c2fef5fbfe4e\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"0bff53afb5fc2cd1b87081629e296d8f636618662e6925d2d8357e7df8ffa7c0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"932af17e-a54a-48a6-b990-b30d129dded4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return as Document)\", \"tokens\": 5886, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"18f6776e6e1eecb908ef07f3dee85c19f314a20bf447ceaad8d70483a16484d9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 25287, \"end_char_idx\": 27731, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "ref_doc_id": "0bad2d8c-273e-43e2-b615-c2fef5fbfe4e", "chroma:document": "*\n\n## FAQ & Troubleshooting\n\n- Why are you using the Microsoft Graph API in your code instead of the [SharePoint API](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom)?\n\n  - The SharePoint API is legacy - per the Microsoft documentation [here](https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph), \u201cFor SharePoint Online, innovation using a REST API against SharePoint is driven via the Microsoft Graph REST API's.\u201d The Graph API gives us more flexibility, and the SharePoint API still runs into the same file issues listed in the [Why is this necessary instead of interacting with the Microsoft Graph API directly?](#why-is-this-necessary-instead-of-interacting-with-the-microsoft-api-directly) section.\n\n- What types of files does this support?\n    1. This supports all files listed in the documentation for the Convert File endpoint [_here_](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http). Specifically, it supports _pdf, doc, docx, odp, ods, odt, pot, potm, potx, pps, ppsx, ppsxm, ppt, pptm, pptx, rtf_.\n\n    2. When a search result returns XLS, XLSX, or CSV, this prompts the user to download the file and re-upload to ask questions using Advanced Data Analysis. As stated above, we recommend solution 1 if structured data is part of your use case.\n\n- Why do I need to request an OBO token?\n\n  - When you try to use the same token to authenticate to the Graph API as the one you use to authenticate into the Azure Function, you get an \u201cinvalid audience\u201d token. This is because the audience for the token can only be user\\_impersonation.\n\n  - To address this, the function requests a new token scoped to Files.Read.All within the app using the [On Behalf Of flow](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-on-behalf-of-flow). This will inherit the permissions of the logged in user, meaning this function will only search through files the logged-in user has access to.\u00a0\n\n  - We are purposefully requesting a new On Behalf Of token with each request, because Azure Function Apps are meant to be stateless. You could potentially integrate this with Azure Key Vault to store the secret and retrieve programmatically.\u00a0\n\n*Are there integrations that you\u2019d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we\u2019ll take a look.*"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: f2cb3e6e-3a94-4c60-8eae-5192865d49b2
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"f2cb3e6e-3a94-4c60-8eae-5192865d49b2\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b575f1eb-e9e3-4d25-b4a1-4479ce571379\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b6afc9f6eeff315579f086f30055e8e7d2391e2b89f79446e7e193156d033725\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3573, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "# GPT Action Library: Canvas LMS\n\n## Introduction\n\nThis page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information: \n- [Introduction to GPT Actions](https://platform.openai.com/docs/actions)\n- [Introduction to GPT Actions Library](https://platform.openai.com/docs/actions/actions-library)\n- [Example of Buliding a GPT Action from Scratch](https://platform.openai.com/docs/actions/getting-started)\n\nThis particular GPT Action provides an overview of how to connect to Canvas (infrastructure.canvas.com), a widely used LMS tool for course material, grading and general education purposes. \n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to Canvas\n\n**Example Use Cases**:\n- Query content from LMS \n- Build quizzes\n- Create new modules\n- Understand topics from assigned courses\n\n## Application Information\n\n### Application Key Links\n\nCheck out these links from the application before you get started:\n- Application Website: https://canvas.instructure.com/login/canvas \n- Application API Documentation: https://canvas.instructure.com/doc/api/\n \n\n### Application Prerequisites\n\nBefore you get started, make sure you go through the following steps in your application environment:\n- Ensure you have the access and permissions in Canvas to create an approved integration with an Access Token for testing\n- For OAuth connection see here : https://canvas.instructure.com/doc/api/file.oauth.html\n\n\n![gptactions_canvaslms_approvedintegrations.png](../../../images/gptactions_canvaslms_approvedintegrations.png)\n\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\nOnce you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n\n```python\n**Context** : You are a helpful friendly university level course helper designed to search across canvas courses to help students and educators, this GPT is intended to help students and teachers understand course material, take quiz's and tests from information stored in canvas.  \n\n\n**Instructions**\nWhen asked to perform a task, use the available actions via the canvas.infrastructure.com API\n\n\nYou should be professional and verbose with answers, provide clear pedagogical experience for users. \n\n\nOffer assistance with tasks around summarizing course material, understanding module and quiz information. \n\n\nAsk for clarification when needed to ensure accuracy and completeness in fulfilling user requests. It should also respect user privacy and handle all data securely.\n\n\nIf a user uploads a file, help the user analyze the file before callin the canvas API.\n\n```\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: Canvas LMS API\n  description: >\n    This is the API of the Canvas LMS, providing access to various resources such as accounts, courses, users,\n    assignments, quizzes, files, and more.\n  version: 1.0.0\nservers:\n  - url: https://canvas.instructure.com\n    description: Canvas LMS Production Server\npaths:\n  /api/v1/accounts:\n    get:\n      summary: List accounts\n      operationId: listAccounts"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: b575f1eb-e9e3-4d25-b4a1-4479ce571379
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"b575f1eb-e9e3-4d25-b4a1-4479ce571379\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"f2cb3e6e-3a94-4c60-8eae-5192865d49b2\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"f13fd9080d94907424561425992635c9c09c1d55492cf3ef79ba62ae7fa77539\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d7136ef1-ec9b-43f4-8845-f91d42af6f2e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"8f7ad2cf854720b6866d86498ff64a56dd6c3e402b58ce71053dafedfeb5d2ee\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2005, \"end_char_idx\": 4429, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "```python\n**Context** : You are a helpful friendly university level course helper designed to search across canvas courses to help students and educators, this GPT is intended to help students and teachers understand course material, take quiz's and tests from information stored in canvas.  \n\n\n**Instructions**\nWhen asked to perform a task, use the available actions via the canvas.infrastructure.com API\n\n\nYou should be professional and verbose with answers, provide clear pedagogical experience for users. \n\n\nOffer assistance with tasks around summarizing course material, understanding module and quiz information. \n\n\nAsk for clarification when needed to ensure accuracy and completeness in fulfilling user requests. It should also respect user privacy and handle all data securely.\n\n\nIf a user uploads a file, help the user analyze the file before callin the canvas API.\n\n```\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: Canvas LMS API\n  description: >\n    This is the API of the Canvas LMS, providing access to various resources such as accounts, courses, users,\n    assignments, quizzes, files, and more.\n  version: 1.0.0\nservers:\n  - url: https://canvas.instructure.com\n    description: Canvas LMS Production Server\npaths:\n  /api/v1/accounts:\n    get:\n      summary: List accounts\n      operationId: listAccounts\n      responses:\n        \"200\":\n          description: A paginated list of accounts\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Account\"\n  /api/v1/accounts/{account_id}:\n    get:\n      summary: Get a single account\n      operationId: getAccount\n      parameters:\n        - name: account_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Account details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Account\"\n  /api/v1/courses:\n    get:\n      summary: List courses\n      operationId: listCourses\n      responses:\n        \"200\":\n          description: A paginated list"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: d7136ef1-ec9b-43f4-8845-f91d42af6f2e
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"d7136ef1-ec9b-43f4-8845-f91d42af6f2e\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b575f1eb-e9e3-4d25-b4a1-4479ce571379\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d71f66cb3debf2b83159dee919b1abf778c2257e0971aa3ccd4634fd51e39367\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"32136f73-5b66-44ae-8c71-cca7c71569c6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1699ee8c932e1fe51530e65a952947fb6a694dd0432f874fffc4e8791dbfee18\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3599, \"end_char_idx\": 5182, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "\"200\":\n          description: A paginated list of accounts\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Account\"\n  /api/v1/accounts/{account_id}:\n    get:\n      summary: Get a single account\n      operationId: getAccount\n      parameters:\n        - name: account_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Account details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Account\"\n  /api/v1/courses:\n    get:\n      summary: List courses\n      operationId: listCourses\n      responses:\n        \"200\":\n          description: A paginated list of courses\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Course\"\n  /api/v1/courses/{course_id}:\n    get:\n      summary: Get a single course\n      operationId: getCourse\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Course details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Course\"\n  /api/v1/courses/{course_id}/assignments:\n    get:\n      summary: List assignments\n      operationId: listAssignments\n      parameters:"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 32136f73-5b66-44ae-8c71-cca7c71569c6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"32136f73-5b66-44ae-8c71-cca7c71569c6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d7136ef1-ec9b-43f4-8845-f91d42af6f2e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"6803944c8d377b546aacc420b991cd4cadb7a55fe4634a0511090e64a2eb645b\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5d2af374-3226-4921-ad6b-c54c627bfa4f\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b3c2541a0ef9224c7da301064ff21ea8ff287ea5a7ea1137202392841ee4fd08\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4364, \"end_char_idx\": 5927, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "responses:\n        \"200\":\n          description: A paginated list of courses\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Course\"\n  /api/v1/courses/{course_id}:\n    get:\n      summary: Get a single course\n      operationId: getCourse\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Course details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Course\"\n  /api/v1/courses/{course_id}/assignments:\n    get:\n      summary: List assignments\n      operationId: listAssignments\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: A paginated list of assignments\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Assignment\"\n  /api/v1/courses/{course_id}/assignments/{assignment_id}:\n    get:\n      summary: Get a single assignment\n      operationId: getAssignment\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: assignment_id\n          in: path\n          required: true\n          schema:"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 5d2af374-3226-4921-ad6b-c54c627bfa4f
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"5d2af374-3226-4921-ad6b-c54c627bfa4f\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"32136f73-5b66-44ae-8c71-cca7c71569c6\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"e1965e7c9e0c3e36f1ee981d56a64cb21318f8f24ae78cb450eda7e0689ce214\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"bb4fa7eb-15ed-410d-b42e-d4f795daef38\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"790eac1f0947e78ac163e910bfcfb0b6fdac4cee2bed9c05def4ec8dd03b0adc\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5104, \"end_char_idx\": 6650, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "summary: List assignments\n      operationId: listAssignments\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: A paginated list of assignments\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Assignment\"\n  /api/v1/courses/{course_id}/assignments/{assignment_id}:\n    get:\n      summary: Get a single assignment\n      operationId: getAssignment\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: assignment_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Assignment details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Assignment\"\n  /api/v1/courses/{course_id}/quizzes:\n    get:\n      summary: List quizzes\n      operationId: listQuizzes\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: A paginated list of quizzes\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Quiz\""}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: bb4fa7eb-15ed-410d-b42e-d4f795daef38
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"bb4fa7eb-15ed-410d-b42e-d4f795daef38\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5d2af374-3226-4921-ad6b-c54c627bfa4f\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"9ec6fb7250c4109f644e096c6d12ed441b60194f1635cad37d2ba82893a16037\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5f84abc1-909b-4adf-9242-c133600ea355\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"5f18597081ca8b34e0a30d0e79295c780a2603cc6f593e8f2d3fa23ed65d217b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5876, \"end_char_idx\": 7410, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Assignment details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Assignment\"\n  /api/v1/courses/{course_id}/quizzes:\n    get:\n      summary: List quizzes\n      operationId: listQuizzes\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: A paginated list of quizzes\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: \"#/components/schemas/Quiz\"\n  /api/v1/courses/{course_id}/quizzes/{quiz_id}:\n    get:\n      summary: Get a single quiz\n      operationId: getQuiz\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: quiz_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Quiz details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Quiz\"\n  /api/v1/courses/{course_id}/students/{student_id}/grades:\n     get:\n       summary: List grades for a student\n       operationId: listGrades\n       parameters:\n         - name: course_id\n           in: path"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 5f84abc1-909b-4adf-9242-c133600ea355
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"5f84abc1-909b-4adf-9242-c133600ea355\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bb4fa7eb-15ed-410d-b42e-d4f795daef38\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"cb957e21074fe352b98f4bfcc723a2a6150bb46adf763275472d712678dae754\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"0b1ce1e3-ebfb-412e-862b-5c14462fb6c6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c42e6bf7ec31646ea9b259c219f63ba525fbf4c7b208ed16c9f46010d34b7b01\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6592, \"end_char_idx\": 8122, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "items:\n                  $ref: \"#/components/schemas/Quiz\"\n  /api/v1/courses/{course_id}/quizzes/{quiz_id}:\n    get:\n      summary: Get a single quiz\n      operationId: getQuiz\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: quiz_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        \"200\":\n          description: Quiz details\n          content:\n            application/json:\n              schema:\n                $ref: \"#/components/schemas/Quiz\"\n  /api/v1/courses/{course_id}/students/{student_id}/grades:\n     get:\n       summary: List grades for a student\n       operationId: listGrades\n       parameters:\n         - name: course_id\n           in: path\n           required: true\n           schema:\n             type: integer\n         - name: student_id\n           in: path\n           required: true\n           schema:\n             type: integer\n       responses:\n         '200':\n           description: A list of grades for the student\n           content:\n             application/json:\n               schema:\n                 type: array\n                 items:\n                   $ref: '#/components/schemas/Grade'\n  /api/v1/courses/{course_id}/students/{student_id}/grades/{grade_id}:\n    get:\n      summary: Get a single grade\n      operationId: getGrade\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 0b1ce1e3-ebfb-412e-862b-5c14462fb6c6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"0b1ce1e3-ebfb-412e-862b-5c14462fb6c6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5f84abc1-909b-4adf-9242-c133600ea355\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"a293abfc86e00d743f27bfa21aabd888efa28d7af744bf2c7079634b50477ef3\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e1af7f9a-84c3-444d-b6e2-ba395ae2adbc\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"2f2dc3497a52a52e7e50ee32a030a4812df06ee8b5c284fa76a73dbe45f18401\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7352, \"end_char_idx\": 8831, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "parameters:\n         - name: course_id\n           in: path\n           required: true\n           schema:\n             type: integer\n         - name: student_id\n           in: path\n           required: true\n           schema:\n             type: integer\n       responses:\n         '200':\n           description: A list of grades for the student\n           content:\n             application/json:\n               schema:\n                 type: array\n                 items:\n                   $ref: '#/components/schemas/Grade'\n  /api/v1/courses/{course_id}/students/{student_id}/grades/{grade_id}:\n    get:\n      summary: Get a single grade\n      operationId: getGrade\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: student_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: grade_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: Grade details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Grade'\n  /api/v1/courses/{course_id}/syllabus:\n    get:\n      summary: Get course syllabus\n      operationId: getSyllabus\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: e1af7f9a-84c3-444d-b6e2-ba395ae2adbc
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"e1af7f9a-84c3-444d-b6e2-ba395ae2adbc\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"0b1ce1e3-ebfb-412e-862b-5c14462fb6c6\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"9c8833bae106d8b545b697f7aee34635e4f063ac392f5aabaaa1c446898d3f8d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"a261bce1-9feb-42a0-af8d-03018d50795f\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"561056e86e60a6c03b05bba153f73c7d09d4420a9391f0470f17d4aaac50c65e\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8071, \"end_char_idx\": 9588, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "in: path\n          required: true\n          schema:\n            type: integer\n        - name: student_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: grade_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: Grade details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Grade'\n  /api/v1/courses/{course_id}/syllabus:\n    get:\n      summary: Get course syllabus\n      operationId: getSyllabus\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: Syllabus details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Syllabus'\n  /api/v1/courses/{course_id}/modules:\n    get:\n      summary: List modules\n      operationId: listModules\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: A list of modules in the course\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/Module'\n  /api/v1/courses/{course_id}/modules/{module_id}:\n    get:\n      summary:"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: a261bce1-9feb-42a0-af8d-03018d50795f
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"a261bce1-9feb-42a0-af8d-03018d50795f\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e1af7f9a-84c3-444d-b6e2-ba395ae2adbc\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"bcadd1540f2cbf450357f0dde9a81b8c4c1114bf8a1553c339ea6529eac85a79\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6b321eed-439e-474b-917a-0accf2b0ccdb\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f2bb1445c10a451995847b2ccdededf8b2f175ef358a10d3b69ba52d6287118f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8781, \"end_char_idx\": 10318, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "schema:\n            type: integer\n      responses:\n        '200':\n          description: Syllabus details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Syllabus'\n  /api/v1/courses/{course_id}/modules:\n    get:\n      summary: List modules\n      operationId: listModules\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: A list of modules in the course\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/Module'\n  /api/v1/courses/{course_id}/modules/{module_id}:\n    get:\n      summary: Get a single module\n      operationId: getModule\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: module_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: Module details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Module'\ncomponents:\n  schemas:\n    Account:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        workflow_state:\n          type: string\n    Course:\n      type: object\n      properties:"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 6b321eed-439e-474b-917a-0accf2b0ccdb
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"6b321eed-439e-474b-917a-0accf2b0ccdb\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"a261bce1-9feb-42a0-af8d-03018d50795f\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"2af5087974481defe8db7bf4f04d8e4eda71bcfca8365b7a86e31197945e774f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"eca93c7a-9862-43f8-805f-1131f40a7e53\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b132c387a92272479eab6c7f1c75eb108e93eb746b43fefc7bf16d26788f38b3\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9516, \"end_char_idx\": 11021, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "/api/v1/courses/{course_id}/modules/{module_id}:\n    get:\n      summary: Get a single module\n      operationId: getModule\n      parameters:\n        - name: course_id\n          in: path\n          required: true\n          schema:\n            type: integer\n        - name: module_id\n          in: path\n          required: true\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: Module details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Module'\ncomponents:\n  schemas:\n    Account:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        workflow_state:\n          type: string\n    Course:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        account_id:\n          type: integer\n        start_at:\n          type: string\n          format: date-time\n        end_at:\n          type: string\n          format: date-time\n    Assignment:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        description:\n          type: string\n        due_at:\n          type: string\n          format: date-time\n        points_possible:\n          type: number\n    Quiz:\n      type: object\n      properties:\n        id:\n          type: integer\n        title:\n          type: string\n        description:\n          type: string"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: eca93c7a-9862-43f8-805f-1131f40a7e53
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"eca93c7a-9862-43f8-805f-1131f40a7e53\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6b321eed-439e-474b-917a-0accf2b0ccdb\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"e00e551a533fb993d4028c1ce0ba604df4fbbcdab92ef19b9288bc1bfe854c3f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"2c579557-3e1d-4222-a9be-24ea7c6bc960\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"9649608b95afbb434245406dc0aead34f2a4919f0932d85f31b52e772309efe0\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10257, \"end_char_idx\": 11706, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "type: string\n    Course:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        account_id:\n          type: integer\n        start_at:\n          type: string\n          format: date-time\n        end_at:\n          type: string\n          format: date-time\n    Assignment:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        description:\n          type: string\n        due_at:\n          type: string\n          format: date-time\n        points_possible:\n          type: number\n    Quiz:\n      type: object\n      properties:\n        id:\n          type: integer\n        title:\n          type: string\n        description:\n          type: string\n        due_at:\n          type: string\n          format: date-time\n        points_possible:\n          type: number\n    Grade:\n      type: object\n      properties:\n        id:\n          type: integer\n        student_id:\n          type: integer\n        course_id:\n          type: integer\n        assignment_id:\n          type: integer\n        score:\n          type: number\n        grade:\n          type: string\n    Syllabus:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        account_id:\n          type: integer\n        start_at:\n          type: string\n          format: date-time\n        end_at:\n          type: string"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 2c579557-3e1d-4222-a9be-24ea7c6bc960
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"2c579557-3e1d-4222-a9be-24ea7c6bc960\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"eca93c7a-9862-43f8-805f-1131f40a7e53\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"bbc76407950d69339a613235b9a7baf98cc6f6de39d7baf6aaa96ddf221bde32\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"3e29b086-bdfa-4475-bf9c-5f6de1ec81db\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"a77bb54a3415cc72a6dd24888762b5e467f066b99f5327e7671df294d6cd2d03\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10965, \"end_char_idx\": 12754, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "type: string\n        description:\n          type: string\n        due_at:\n          type: string\n          format: date-time\n        points_possible:\n          type: number\n    Grade:\n      type: object\n      properties:\n        id:\n          type: integer\n        student_id:\n          type: integer\n        course_id:\n          type: integer\n        assignment_id:\n          type: integer\n        score:\n          type: number\n        grade:\n          type: string\n    Syllabus:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        account_id:\n          type: integer\n        start_at:\n          type: string\n          format: date-time\n        end_at:\n          type: string\n          format: date-time\n        syllabus_body:\n          type: string\n        syllabus_url:\n          type: string\n    Module:\n     type: object\n     properties:\n       id:\n         type: integer\n       name:\n         type: string\n       position:\n         type: integer\n       unlock_at:\n         type: string\n         format: date-time\n       require_sequential_progress:\n         type: boolean\n       state:\n         type: string\n  securitySchemes:\n    bearerAuth:\n      type: http\n      scheme: bearer\n      bearerFormat: JWT\nsecurity:\n  - bearerAuth: []\n```\n\n**Note : this schema above does not contain all possible API endpoints, be sure to edit the schema to produce the appropriate actions from canvas [API documentation](https://canvas.instructure.com/doc/api/)**\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 3e29b086-bdfa-4475-bf9c-5f6de1ec81db
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"3e29b086-bdfa-4475-bf9c-5f6de1ec81db\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"2c579557-3e1d-4222-a9be-24ea7c6bc960\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"5549c6195c034df4d7e6387f86639b4ac46092913f47f03c00a6ab42862fd6cf\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"dcb81dde-9a54-4113-bed5-f5f8f31df6fa\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"982d739678175bf3b3244fa608fced3f3b7ecd5bb022e9753f1a07380dc0c44a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 11650, \"end_char_idx\": 14058, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "format: date-time\n        end_at:\n          type: string\n          format: date-time\n        syllabus_body:\n          type: string\n        syllabus_url:\n          type: string\n    Module:\n     type: object\n     properties:\n       id:\n         type: integer\n       name:\n         type: string\n       position:\n         type: integer\n       unlock_at:\n         type: string\n         format: date-time\n       require_sequential_progress:\n         type: boolean\n       state:\n         type: string\n  securitySchemes:\n    bearerAuth:\n      type: http\n      scheme: bearer\n      bearerFormat: JWT\nsecurity:\n  - bearerAuth: []\n```\n\n**Note : this schema above does not contain all possible API endpoints, be sure to edit the schema to produce the appropriate actions from canvas [API documentation](https://canvas.instructure.com/doc/api/)**\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n### Pre-Action Steps\n\nBefore you set up authentication in ChatGPT, please take the following steps in the application. Our sample integration below is utilizing a secret key, which is an easier method for testing. In production, it is more common to establish an OAuth connection to ensure permissions are respected from ChatGPT to Canvas, ensuring users the appropriate access. \n\n1. Canvas accounts : The first step is to ensure the canvas environment has users assigned to the appropriate role (student / teacher) with any access to appropriate courses\n2. For testing purposes or service level account access create an approved integration access token as seen below\n- Under Account -> Settings -> Approved Integrations\n\n<br> ![gptactions_canvaslms_settings.png](../../../images/gptactions_canvaslms_settings.png)\n\n- Create new Access Token\n\n<br> ![gptactions_canvaslms_integrationslist.png](../../../images/gptactions_canvaslms_integrationslist.png)\n\n- Provide purpose and expiration\n\n<br> ![gptactions_canvaslms_tokencreate.png](../../../images/gptactions_canvaslms_tokencreate.png)\n\n- Copy the new Token to use in the GPT Action (the token will not be accessible once you leave the page - ensure proper token management access is maintained to prevent unauthorzied access from another application."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: dcb81dde-9a54-4113-bed5-f5f8f31df6fa
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb", "title": "GPT Action Library: Canvas LMS", "tokens": 3423, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"dcb81dde-9a54-4113-bed5-f5f8f31df6fa\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"77823857-3df4-42e7-aa34-5d94a78e1ee1\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"94b1bde47101cf087949750031e313f87df27618d84507d355689fa8ea94f8f9\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"3e29b086-bdfa-4475-bf9c-5f6de1ec81db\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb\", \"title\": \"GPT Action Library: Canvas LMS\", \"tokens\": 3423, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"cac8cd5441c02905ddead5d4caa0ac65c4d45bbe7e4e849b7a257daceb3910a9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 12202, \"end_char_idx\": 16078, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "ref_doc_id": "77823857-3df4-42e7-aa34-5d94a78e1ee1", "chroma:document": "scheme: bearer\n      bearerFormat: JWT\nsecurity:\n  - bearerAuth: []\n```\n\n**Note : this schema above does not contain all possible API endpoints, be sure to edit the schema to produce the appropriate actions from canvas [API documentation](https://canvas.instructure.com/doc/api/)**\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n### Pre-Action Steps\n\nBefore you set up authentication in ChatGPT, please take the following steps in the application. Our sample integration below is utilizing a secret key, which is an easier method for testing. In production, it is more common to establish an OAuth connection to ensure permissions are respected from ChatGPT to Canvas, ensuring users the appropriate access. \n\n1. Canvas accounts : The first step is to ensure the canvas environment has users assigned to the appropriate role (student / teacher) with any access to appropriate courses\n2. For testing purposes or service level account access create an approved integration access token as seen below\n- Under Account -> Settings -> Approved Integrations\n\n<br> ![gptactions_canvaslms_settings.png](../../../images/gptactions_canvaslms_settings.png)\n\n- Create new Access Token\n\n<br> ![gptactions_canvaslms_integrationslist.png](../../../images/gptactions_canvaslms_integrationslist.png)\n\n- Provide purpose and expiration\n\n<br> ![gptactions_canvaslms_tokencreate.png](../../../images/gptactions_canvaslms_tokencreate.png)\n\n- Copy the new Token to use in the GPT Action (the token will not be accessible once you leave the page - ensure proper token management access is maintained to prevent unauthorzied access from another application.\n\n\n### In ChatGPT\n\nIn ChatGPT, click on \"Authentication\" and choose **\"API Key\"**. Enter in the information below. API Key provides general access to the Canvas environment based on the users permissions that created the API key, to follow permission models in Canvas use the OAuth method described below.\n\n- **API Key**: Use the token from above \n- **Auth Type**: Bearer\n\n<br> ![gptactions_canvaslms_auth.png](../../../images/gptactions_canvaslms_auth.png)\n\n**OAuth Connection**\n\nIf you want to implement OAuth, follow the guide here : https://canvas.instructure.com/doc/api/file.oauth.html - specific instructions can vary depending on the Canvas implementation.\n\nParameters for GPT Configuration\n- Client ID - obtained from site owner\n- Client Secret - obtained from site owner \n- Authorization URL - : https://< canvas-install-url >/login/oauth2/auth?client_id=XXX&response_type=code&redirect_uri=https://example.com/oauth_complete&state=YYY&scope=< value_1 >%20< value_2 >%20< value_n >\n- Token URL : https://< canvas-install-url> /login/oauth2/token \n\n### Post-Action Steps\n\nOnce you've set up authentication in ChatGPT, follow the steps below in the application to test the Action.\n\n- You will see a list of available actions from the API schema for Canvas, you can test the endpoints from the GPT builder to ensure Canvas can be reached. Once you verified connection make sure to save the GPT and share it witht the appropriate user base.\n- Note: if you are using OAuth, you will need to set up the callback URL from ChatGPT in the Canvas app\n\n### FAQ & Troubleshooting\n\n- *Schema calls the wrong project or dataset:* If ChatGPT calls the wrong project or dataset, consider updating your instructions to make it more explicit either (a) which project / dataset should be called or (b) to require the user provide those exact details before it runs the query\n\n*Are there integrations that you\u2019d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we\u2019ll take a look.*"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 8604bb32-5b12-4557-ba82-45264a52e4d2
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"8604bb32-5b12-4557-ba82-45264a52e4d2\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"ad9e168c-0566-4eea-9e1c-0be0eba1e43b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"9608d55c1f2b80d30ebe7365dc5c7671ef9154d3ef96c80bef4755b36e919a24\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3151, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "# GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\n\n## Introduction\n\nThis page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information: \n- [Introduction to GPT Actions](https://platform.openai.com/docs/actions)\n- [Introduction to GPT Actions Library](https://platform.openai.com/docs/actions/actions-library)\n- [Example of Building a GPT Action from Scratch](https://platform.openai.com/docs/actions/getting-started)\n\nThis solution enables a GPT action to answer a user\u2019s question with the context of files the user can access in SharePoint or Office365, using Microsoft\u2019s Graph API [search capabilities](https://learn.microsoft.com/en-us/graph/api/resources/search-api-overview?view=graph-rest-1.0) and the ability to [retrieve files](https://learn.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0\\&tabs=http). It uses Azure Functions to process the Graph API response and convert it to a human readable format or structure it in a way ChatGPT understands. This code is meant to be directional, and you should modify it to your requirements.\n\nThis solution uses the ability to[ retrieve files in Actions](https://platform.openai.com/docs/actions/sending-files) and use them as if you had uploaded them directly to a conversation. The Azure Function returns a base64 string that ChatGPT converts into a file. This solution can handle both structured and unstructured data, but does have size volume limitations (see docs [here](https://platform.openai.com/docs/actions/sending-files))\n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to files in Sharpeoint\n\n**Example Use Cases**: \n- A user needs to look up which files relate to a certain topic\n- A user needs an answer to a critical question, buried deep in documents\n\n## Architecture / Example\n\n![](../../../images/solution_1.gif)\n\n\nThis solution uses a Node.js Azure Function to, based on the logged in user:\n\n1. Search for a relevant file that the user has access to, based on the user\u2019s initial question.\u00a0\n\n2. For each file that is found, convert it to a base64 string.\n\n3. Format the data in the structure ChatGPT is expecting [here](https://platform.openai.com/docs/actions/sending-files/inline-option).\n\n4. Return that to ChatGPT. The GPT then can use those files as if you had uploaded it to the conversation.\n\n![](../../../images/solution_1_architecture.png)\n\n## Application Information\n\n### Application Key Links\n\nCheck out these links from the application before you get started:\n- Application Website: https://www.microsoft.com/en-us/microsoft-365/sharepoint/collaboration\n- Application API Documentation: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/\n\n### Application Prerequisites\n\nBefore you get started, make sure you go through the following steps in your application environment:\n- Access to a Sharepoint environment \n- Postman (and knowledge of APIs and OAuth)"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: ad9e168c-0566-4eea-9e1c-0be0eba1e43b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"ad9e168c-0566-4eea-9e1c-0be0eba1e43b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8604bb32-5b12-4557-ba82-45264a52e4d2\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"f58601a40c41fbb3ad3530b4f171b56fffbe534e528a5fa2b85e129981ec7e34\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8148f734-15f3-4f51-8f1d-0341d00dff0e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"34da1156f1121dfd44962762f258e9bbd4c662859a2c3abe2f2e88a259e51727\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2056, \"end_char_idx\": 5474, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "This solution uses a Node.js Azure Function to, based on the logged in user:\n\n1. Search for a relevant file that the user has access to, based on the user\u2019s initial question.\u00a0\n\n2. For each file that is found, convert it to a base64 string.\n\n3. Format the data in the structure ChatGPT is expecting [here](https://platform.openai.com/docs/actions/sending-files/inline-option).\n\n4. Return that to ChatGPT. The GPT then can use those files as if you had uploaded it to the conversation.\n\n![](../../../images/solution_1_architecture.png)\n\n## Application Information\n\n### Application Key Links\n\nCheck out these links from the application before you get started:\n- Application Website: https://www.microsoft.com/en-us/microsoft-365/sharepoint/collaboration\n- Application API Documentation: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/\n\n### Application Prerequisites\n\nBefore you get started, make sure you go through the following steps in your application environment:\n- Access to a Sharepoint environment \n- Postman (and knowledge of APIs and OAuth)\n\n\n## Middleware Information\n\nIf you follow the [search concept files guide](https://learn.microsoft.com/en-us/graph/search-concept-files), the [Microsoft Graph Search API](https://learn.microsoft.com/en-us/graph/search-concept-files) returns references to files that fit the criteria, but not the file contents themselves. Therefore, middleware is required, rather than hitting the MSFT endpoints directly.\n\nWe need to restructure the response from that API so that it matches the expected structure in `openaiFileResponse` outlined [here](https://platform.openai.com/docs/actions/getting-started/inline-option).\n\n### Additional Steps\n\n#### Set up Azure Function\n\n1. Set up an Azure Function using the steps in the [Azure Function cookbook](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function)\n\n#### Add in Function Code\n\nNow that you have an authenticated Azure Function, we can update the function to search SharePoint / O365\n\n2. Go to your test function and paste in the code from [this file](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_one_file_retrieval.js). Save the function.\n\n> **This code is meant to be directional** - while it should work out of the box, it is designed to be customized to your needs (see examples towards the end of this document).\n\n3. Set up the following env variables by going to the **Configuration** tab on the left under **Settings.** Note that this may be listed directly in **Environment Variables** depending on your Azure UI.\n\n    1. `TENANT_ID`: copied from previous section\n\n    2. `CLIENT_ID`: copied from previous section\n\n4. Go to the **Console** tab under the **Development Tools**\n\n    1. Install the following packages in console\n\n       1. `npm install @microsoft/microsoft-graph-client`\n\n       2. `npm install axios`\n\n5. Once this is complete, try calling the function (POST call) from Postman again, putting the below into body (using a query and search term you think will generate responses).\n\n     ```json\n    {\n        \"searchTerm\": \"<choose a search term>\"\n    }\n    ```\n\n6. If you get a response, you are ready to set this up with a Custom GPT! See the ChatGPT Section of the Azure Function page for more details on setting this up\n\n\n## More Detailed Walkthrough"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 8148f734-15f3-4f51-8f1d-0341d00dff0e
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"8148f734-15f3-4f51-8f1d-0341d00dff0e\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"ad9e168c-0566-4eea-9e1c-0be0eba1e43b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"685dc0487785887fc3e29d6b4613f156980f2e8e47fc801a0df76a9168f6f696\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"98e411eb-eea2-4f32-8ec7-a3225dcbffca\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"98227c9a5ba660ee865051b4ae2f8386c509d94287b093f95cdacb8180c472e0\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5446, \"end_char_idx\": 7934, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "## More Detailed Walkthrough\n\n\nThe below walks through setup instructions and walkthrough unique to this solution. You can find the entire code [here](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_one_file_retrieval.js).\n\n### Code Walkthrough\n\nThe below walks through the different parts of the function. Before you begin, ensure you have the required packages installed and environment variables set up (see the Installation Steps section).\n\n\n#### Implementing the Authentication\u00a0\n\nBelow we have a few helper functions that we\u2019ll use in the function.\n\n\n##### Initializing the Microsoft Graph Client\n\nCreate a function to initialize the Graph client with an access token. This will be used to search through Office 365 and SharePoint.\n\n```javascript\nconst { Client } = require('@microsoft/microsoft-graph-client');\n\nfunction initGraphClient(accessToken) {\n    return Client.init({\n        authProvider: (done) => {\n            done(null, accessToken);\n        }\n    });\n}\n```\n\n##### Obtaining an On-Behalf-Of (OBO) Token\n\nThis function uses an existing bearer token to request an OBO token from Microsoft's identity platform. This enables passing through the credentials to ensure the search only returns files the logged-in user can access.\n\n```javascript\nconst axios = require('axios');\nconst qs = require('querystring');\n\nasync function getOboToken(userAccessToken) {\n\u00a0\u00a0\u00a0\u00a0const { TENANT_ID, CLIENT_ID, MICROSOFT_PROVIDER_AUTHENTICATION_SECRET } = process.env;\n\u00a0\u00a0\u00a0\u00a0const params = {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0client_id: CLIENT_ID,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0client_secret: MICROSOFT_PROVIDER_AUTHENTICATION_SECRET,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertion: userAccessToken,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0requested_token_use: 'on_behalf_of',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0scope: 'https://graph.microsoft.com/.default'\n\u00a0\u00a0\u00a0\u00a0};\n\n\u00a0\u00a0\u00a0\u00a0const url = `https\\://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token`;\n\u00a0\u00a0\u00a0\u00a0try {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const response = await axios.post(url, qs.stringify(params), {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0headers: { 'Content-Type': 'application/x-www-form-urlencoded' }\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return response.data.access\\_token;\n\u00a0\u00a0\u00a0\u00a0} catch (error) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0console.error('Error obtaining OBO token:', error.response?.data || error.message);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0throw error;\n\u00a0\u00a0\u00a0\u00a0}\n}\n```\n\n#### Retrieving Content from O365 / SharePoint Items\n\nThis function fetches the content of drive items, converts it to a base64 string, and restructures to match the `openaiFileResponse` format."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 98e411eb-eea2-4f32-8ec7-a3225dcbffca
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"98e411eb-eea2-4f32-8ec7-a3225dcbffca\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8148f734-15f3-4f51-8f1d-0341d00dff0e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"a6d7d686ce71c70789e8ab73b70f818ea5cc2cae2571615bc7b24e75c7c49a92\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"02e0d23e-8f2e-408b-8c29-a92e8f81eb6a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"4938b5c03c6fa5a7a2c2b52ae6043e6e7fc2daf7327352fc674fde37ce3deabc\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6240, \"end_char_idx\": 9420, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "```javascript\nconst { Client } = require('@microsoft/microsoft-graph-client');\n\nfunction initGraphClient(accessToken) {\n    return Client.init({\n        authProvider: (done) => {\n            done(null, accessToken);\n        }\n    });\n}\n```\n\n##### Obtaining an On-Behalf-Of (OBO) Token\n\nThis function uses an existing bearer token to request an OBO token from Microsoft's identity platform. This enables passing through the credentials to ensure the search only returns files the logged-in user can access.\n\n```javascript\nconst axios = require('axios');\nconst qs = require('querystring');\n\nasync function getOboToken(userAccessToken) {\n\u00a0\u00a0\u00a0\u00a0const { TENANT_ID, CLIENT_ID, MICROSOFT_PROVIDER_AUTHENTICATION_SECRET } = process.env;\n\u00a0\u00a0\u00a0\u00a0const params = {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0client_id: CLIENT_ID,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0client_secret: MICROSOFT_PROVIDER_AUTHENTICATION_SECRET,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertion: userAccessToken,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0requested_token_use: 'on_behalf_of',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0scope: 'https://graph.microsoft.com/.default'\n\u00a0\u00a0\u00a0\u00a0};\n\n\u00a0\u00a0\u00a0\u00a0const url = `https\\://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token`;\n\u00a0\u00a0\u00a0\u00a0try {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const response = await axios.post(url, qs.stringify(params), {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0headers: { 'Content-Type': 'application/x-www-form-urlencoded' }\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return response.data.access\\_token;\n\u00a0\u00a0\u00a0\u00a0} catch (error) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0console.error('Error obtaining OBO token:', error.response?.data || error.message);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0throw error;\n\u00a0\u00a0\u00a0\u00a0}\n}\n```\n\n#### Retrieving Content from O365 / SharePoint Items\n\nThis function fetches the content of drive items, converts it to a base64 string, and restructures to match the `openaiFileResponse` format.\n```javascript\nconst getDriveItemContent = async (client, driveId, itemId, name) => {\n\u00a0\u00a0\u00a0try\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const filePath = `/drives/${driveId}/items/${itemId}`;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const downloadPath = filePath + `/content`\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0// this is where we get the contents and convert to base64\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const fileStream = await client.api(downloadPath).getStream();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0let chunks = [];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for await (let chunk of fileStream) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chunks.push(chunk);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const base64String = Buffer.concat(chunks).toString('base64');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0// this is where we get the other metadata to include in response\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const file = await client.api(filePath).get();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const mime_type = file.file.mimeType;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const name = file.name;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return {\"name\":name, \"mime_type\":mime_type, \"content\":base64String}\n\u00a0\u00a0\u00a0} catch (error) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0console.error('Error fetching drive content:', error);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0throw new Error(`Failed to fetch content for ${name}: ${error.message}`);\n\u00a0\u00a0\u00a0}\n```\n\n#### Creating the Azure Function to Handle Requests\n\nNow that we have all these helper functions, the Azure Function will orchestrate the flow, by authenticating the user, performing the search, and iterating through the search results to extract the text and retrieve the relevant parts of the text to the GPT.\n\n**Handling HTTP Requests:** The function starts by extracting the query and searchTerm from the HTTP request. It checks if the Authorization header is present and extracts the bearer token."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 02e0d23e-8f2e-408b-8c29-a92e8f81eb6a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"02e0d23e-8f2e-408b-8c29-a92e8f81eb6a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"98e411eb-eea2-4f32-8ec7-a3225dcbffca\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"4b30dbc0cac6d27b5d7742da5606889b2d9d54fb952e8d5d395d3dae812ca22d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"a7b466c1-f64b-481d-a795-079dc72f75e8\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7db814d396dcc8e6ee55df676c6bb3bd6db91b0492137bfde266e988f624d8bb\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7935, \"end_char_idx\": 10597, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "```javascript\nconst getDriveItemContent = async (client, driveId, itemId, name) => {\n\u00a0\u00a0\u00a0try\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const filePath = `/drives/${driveId}/items/${itemId}`;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const downloadPath = filePath + `/content`\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0// this is where we get the contents and convert to base64\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const fileStream = await client.api(downloadPath).getStream();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0let chunks = [];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for await (let chunk of fileStream) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chunks.push(chunk);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const base64String = Buffer.concat(chunks).toString('base64');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0// this is where we get the other metadata to include in response\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const file = await client.api(filePath).get();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const mime_type = file.file.mimeType;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const name = file.name;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return {\"name\":name, \"mime_type\":mime_type, \"content\":base64String}\n\u00a0\u00a0\u00a0} catch (error) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0console.error('Error fetching drive content:', error);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0throw new Error(`Failed to fetch content for ${name}: ${error.message}`);\n\u00a0\u00a0\u00a0}\n```\n\n#### Creating the Azure Function to Handle Requests\n\nNow that we have all these helper functions, the Azure Function will orchestrate the flow, by authenticating the user, performing the search, and iterating through the search results to extract the text and retrieve the relevant parts of the text to the GPT.\n\n**Handling HTTP Requests:** The function starts by extracting the query and searchTerm from the HTTP request. It checks if the Authorization header is present and extracts the bearer token.\n\n**Authentication:** Using the bearer token, it obtains an OBO token from Microsoft's identity platform using getOboToken defined above.\n\n**Initializing the Graph Client:** With the OBO token, it initializes the Microsoft Graph client using initGraphClient defined above.\n\n**Document Search:** It constructs a search query and sends it to the Microsoft Graph API to find documents based on the searchTerm.\n\n**Document Processing**: For each document returned by the search:\n\n- It retrieves the document content using getDriveItemContent.\n\n- It converts the document to base64 string and restructures it to match the `openaiFileResponse` structure.\n\n**Response**: The function sends them back in the HTTP response.\n```javascript\nmodule.exports = async function (context, req) {\n   // const query = req.query.query || (req.body && req.body.query);\n   const searchTerm = req.query.searchTerm || (req.body && req.body.searchTerm);\n   if (!req.headers.authorization) {\n       context.res = {\n           status: 400,\n           body: 'Authorization header is missing'\n       };\n       return;\n   }\n   /// The below takes the token passed to the function, to use to get an OBO token."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: a7b466c1-f64b-481d-a795-079dc72f75e8
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"a7b466c1-f64b-481d-a795-079dc72f75e8\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"02e0d23e-8f2e-408b-8c29-a92e8f81eb6a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"4937d323d7af63a3cbca536e709afdbe6db36f3090787c633eaebde7ab00b45d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"16e52957-bbcd-4542-91ad-e1b48b179661\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"33d7e4d8119d1ad5d98e5b33283c58f314f50b8bab21a98a4d791cb812724687\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9231, \"end_char_idx\": 11568, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "**Handling HTTP Requests:** The function starts by extracting the query and searchTerm from the HTTP request. It checks if the Authorization header is present and extracts the bearer token.\n\n**Authentication:** Using the bearer token, it obtains an OBO token from Microsoft's identity platform using getOboToken defined above.\n\n**Initializing the Graph Client:** With the OBO token, it initializes the Microsoft Graph client using initGraphClient defined above.\n\n**Document Search:** It constructs a search query and sends it to the Microsoft Graph API to find documents based on the searchTerm.\n\n**Document Processing**: For each document returned by the search:\n\n- It retrieves the document content using getDriveItemContent.\n\n- It converts the document to base64 string and restructures it to match the `openaiFileResponse` structure.\n\n**Response**: The function sends them back in the HTTP response.\n```javascript\nmodule.exports = async function (context, req) {\n   // const query = req.query.query || (req.body && req.body.query);\n   const searchTerm = req.query.searchTerm || (req.body && req.body.searchTerm);\n   if (!req.headers.authorization) {\n       context.res = {\n           status: 400,\n           body: 'Authorization header is missing'\n       };\n       return;\n   }\n   /// The below takes the token passed to the function, to use to get an OBO token.\n   const bearerToken = req.headers.authorization.split(' ')[1];\n   let accessToken;\n   try {\n       accessToken = await getOboToken(bearerToken);\n   } catch (error) {\n       context.res = {\n           status: 500,\n           body: `Failed to obtain OBO token: ${error.message}`\n       };\n       return;\n   }\n   // Initialize the Graph Client using the initGraphClient function defined above\n   let client = initGraphClient(accessToken);\n   // this is the search body to be used in the Microsft Graph Search API: https://learn.microsoft.com/en-us/graph/search-concept-files\n   const requestBody = {\n       requests: [\n           {\n               entityTypes: ['driveItem'],\n               query: {\n                   queryString: searchTerm\n               },\n               from: 0,\n               // the below is set to summarize the top 10 search results from the Graph API, but can configure based on your documents.\n               size: 10\n           }\n       ]\n   };"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 16e52957-bbcd-4542-91ad-e1b48b179661
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"16e52957-bbcd-4542-91ad-e1b48b179661\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"a7b466c1-f64b-481d-a795-079dc72f75e8\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d616f58395c3479ecf1000fbe7b36b616c718f7dd39079f13342551a099c6e90\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"50eb12a0-4ff8-4ecd-8216-122abbdafa8b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"d6bc1de29bb1b4e65039297ca5c50478d93fad34849cb001480d93da08a7db9f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9694, \"end_char_idx\": 14970, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "**Document Search:** It constructs a search query and sends it to the Microsoft Graph API to find documents based on the searchTerm.\n\n**Document Processing**: For each document returned by the search:\n\n- It retrieves the document content using getDriveItemContent.\n\n- It converts the document to base64 string and restructures it to match the `openaiFileResponse` structure.\n\n**Response**: The function sends them back in the HTTP response.\n```javascript\nmodule.exports = async function (context, req) {\n   // const query = req.query.query || (req.body && req.body.query);\n   const searchTerm = req.query.searchTerm || (req.body && req.body.searchTerm);\n   if (!req.headers.authorization) {\n       context.res = {\n           status: 400,\n           body: 'Authorization header is missing'\n       };\n       return;\n   }\n   /// The below takes the token passed to the function, to use to get an OBO token.\n   const bearerToken = req.headers.authorization.split(' ')[1];\n   let accessToken;\n   try {\n       accessToken = await getOboToken(bearerToken);\n   } catch (error) {\n       context.res = {\n           status: 500,\n           body: `Failed to obtain OBO token: ${error.message}`\n       };\n       return;\n   }\n   // Initialize the Graph Client using the initGraphClient function defined above\n   let client = initGraphClient(accessToken);\n   // this is the search body to be used in the Microsft Graph Search API: https://learn.microsoft.com/en-us/graph/search-concept-files\n   const requestBody = {\n       requests: [\n           {\n               entityTypes: ['driveItem'],\n               query: {\n                   queryString: searchTerm\n               },\n               from: 0,\n               // the below is set to summarize the top 10 search results from the Graph API, but can configure based on your documents.\n               size: 10\n           }\n       ]\n   };\n\n\n   try {\n       // This is where we are doing the search\n       const list = await client.api('/search/query').post(requestBody);\n       const processList = async () => {\n           // This will go through and for each search response, grab the contents of the file and summarize with gpt-3.5-turbo\n           const results = [];\n           await Promise.all(list.value[0].hitsContainers.map(async (container) => {\n               for (const hit of container.hits) {\n                   if (hit.resource[\"@odata.type\"] === \"#microsoft.graph.driveItem\") {\n                       const { name, id } = hit.resource;\n                       // The below is where the file lives\n                       const driveId = hit.resource.parentReference.driveId;\n                       // we use the helper function we defined above to get the contents, convert to base64, and restructure it\n                       const contents = await getDriveItemContent(client, driveId, id, name);\n                       results.push(contents)\n               }\n           }));\n           return results;\n       };\n       let results;\n       if (list.value[0].hitsContainers[0].total == 0) {\n           // Return no results found to the API if the Microsoft Graph API returns no results\n           results = 'No results found';\n       } else {\n           // If the Microsoft Graph API does return results, then run processList to iterate through.\n           results = await processList();\n           // this is where we structure the response so ChatGPT knows they are files\n           results = {'openaiFileResponse': results}\n       }\n       context.res = {\n           status: 200,\n           body: results\n       };\n   } catch (error) {\n       context.res = {\n           status: 500,\n           body: `Error performing search or processing results: ${error.message}`,\n       };\n   }\n};\n```\n### Customizations\n\nBelow are some potential areas to customize.\u00a0\n\n- You can customize the GPT prompt to search again a certain amount of times if nothing is found.\n\n- You can customize the code to only search through specific SharePoint sites or O365 Drives by customizing the search query. This will help focus the search and improve the retrieval. The function as setup now looks through all files the logged-in user can access.\n\n- You can update the code to only return certain types of files. For example, only return structured data / CSVs.\u00a0\n\n- You can customize the amount of files it searches through within the call to Microsoft Graph. Note that you should only put a maximum of 10 files based on the documentation [here](https://platform.openai.com/docs/actions/getting-started).\u00a0\n\n### Considerations\n\nNote that all the same limitations of Actions apply here, with regards to returning 100K characters or less and the [45 second timeout](https://platform.openai.com/docs/actions/production/timeouts).\n\n- Make sure you read the documentation here around [returning files](https://platform.openai.com/docs/actions/sending-files) and [file uploads](https://help.openai.com/en/articles/8555545-file-uploads-faq), as those limitations apply here.\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\nOnce you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 50eb12a0-4ff8-4ecd-8216-122abbdafa8b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"50eb12a0-4ff8-4ecd-8216-122abbdafa8b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"16e52957-bbcd-4542-91ad-e1b48b179661\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"1fe8e9731b2cf4324ff268bc7f907d8db749eeb0db5064ed0b61d91aacab0c4c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"cfd419df-649c-4622-a3ca-772d4ff86b74\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"239ad5ff878a9dde46688b3b0d0a27073511141f13099a810a28471167ce0fec\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 14973, \"end_char_idx\": 18814, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "```python\nYou are a Q&A helper that helps answer users questions. You have access to a documents repository through your API action. When a user asks a question, you pass in the \"searchTerm\" a single keyword or term you think you should use for the search.\n\n****\n\nScenario 1: There are answers\n\nIf your action returns results, then you take the results from the action and try to answer the users question.\u00a0\n\n****\n\nScenario 2: No results found\n\nIf the response you get from the action is \"No results found\", stop there and let the user know there were no results and that you are going to try a different search term, and explain why. You must always let the user know before conducting another search.\n\nExample:\n\n****\n\nI found no results for \"DEI\". I am now going to try [insert term] because [insert explanation]\n\n****\n\nThen, try a different searchTerm that is similar to the one you tried before, with a single word.\u00a0\n\nTry this three times. After the third time, then let the user know you did not find any relevant documents to answer the question, and to check SharePoint. \nBe sure to be explicit about what you are searching for at each step.\n\n****\n\nIn either scenario, try to answer the user's question. If you cannot answer the user's question based on the knowledge you find, let the user know and ask them to go check the HR Docs in SharePoint.\u00a0\n```\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\nThis expects a response that matches the file retrieval structure in our doc [here](https://platform.openai.com/docs/actions/sending-files) and passes in a `searchTerm` parameter to inform the search.\n>Make sure to switch the function app name, function name and code based on link copied in screenshot above\n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: SharePoint Search API\n  description: API for searching SharePoint documents.\n  version: 1.0.0\nservers:\n  - url: https://{your_function_app_name}.azurewebsites.net/api\n    description: SharePoint Search API server\npaths:\n  /{your_function_name}?code={enter your specific endpoint id here}:\n    post:\n      operationId: searchSharePoint\n      summary: Searches SharePoint for documents matching a query and term.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                searchTerm:\n                  type: string\n                  description: A specific term to search for within the documents.\n      responses:\n        '200':\n          description: A CSV file of query results encoded in base64.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  openaiFileResponseData:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n                          description: The name of the file.\n                        mime_type:\n                          type: string\n                          description: The MIME type of the file.\n                        content:\n                          type: string\n                          format: byte\n                          description: The base64 encoded contents of the file.\n        '400':\n          description: Bad request when the SQL query parameter is missing.\n        '413':\n          description: Payload too large if the response exceeds the size limit.\n        '500':\n          description: Server error when there are issues executing the query or encoding the results."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: cfd419df-649c-4622-a3ca-772d4ff86b74
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"cfd419df-649c-4622-a3ca-772d4ff86b74\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"50eb12a0-4ff8-4ecd-8216-122abbdafa8b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"f810912a82e47e5cc0846cd1fce47a44f7e97f14acf4a8a74e8e64e98437d17e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"56d5b8dc-51e4-40d6-9251-50b0505962ca\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b13c8625b9d2d7684307167b38be391b31451b3645dcb08ae4cc7d001b551ee3\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 16896, \"end_char_idx\": 20548, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "```python\nopenapi: 3.1.0\ninfo:\n  title: SharePoint Search API\n  description: API for searching SharePoint documents.\n  version: 1.0.0\nservers:\n  - url: https://{your_function_app_name}.azurewebsites.net/api\n    description: SharePoint Search API server\npaths:\n  /{your_function_name}?code={enter your specific endpoint id here}:\n    post:\n      operationId: searchSharePoint\n      summary: Searches SharePoint for documents matching a query and term.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                searchTerm:\n                  type: string\n                  description: A specific term to search for within the documents.\n      responses:\n        '200':\n          description: A CSV file of query results encoded in base64.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  openaiFileResponseData:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n                          description: The name of the file.\n                        mime_type:\n                          type: string\n                          description: The MIME type of the file.\n                        content:\n                          type: string\n                          format: byte\n                          description: The base64 encoded contents of the file.\n        '400':\n          description: Bad request when the SQL query parameter is missing.\n        '413':\n          description: Payload too large if the response exceeds the size limit.\n        '500':\n          description: Server error when there are issues executing the query or encoding the results.\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n*See above and on the [Azure Function cookbook](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function) for more detailed instructions on authentication.*\n\n## FAQ & Troubleshooting\n\n- Why are you using the Microsoft Graph API in your code instead of the [SharePoint API](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom)?\n\n  - The SharePoint API is legacy - per the Microsoft documentation [here](https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph), \u201cFor SharePoint Online, innovation using a REST API against SharePoint is driven via the Microsoft Graph REST API's.\u201d The Graph API gives us more flexibility, and the SharePoint API still runs into the same file issues listed in the [Why is this necessary instead of interacting with the Microsoft Graph API directly?](#why-is-this-necessary-instead-of-interacting-with-the-microsoft-api-directly) section.\n\n- What types of files does this support?\n\n  It follows the same guidelines as the documentation [here](https://help.openai.com/en/articles/8555545-file-uploads-faq) about file uploads.\u00a0\n\n- Why do I need to request an OBO token?\n\n  - When you try to use the same token to authenticate to the Graph API as the one you use to authenticate into the Azure Function, you get an \u201cinvalid audience\u201d token. This is because the audience for the token can only be user\\_impersonation."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 56d5b8dc-51e4-40d6-9251-50b0505962ca
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb", "title": "GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)", "tokens": 4540, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"56d5b8dc-51e4-40d6-9251-50b0505962ca\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"a5c3ef77-5559-4b78-9e02-640583cab1e4\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"d2e5c63b1e3260d78cca7bbfacb2ed3c112c802fb86b331b889cd944956900ae\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"cfd419df-649c-4622-a3ca-772d4ff86b74\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc.ipynb\", \"title\": \"GPT Action Library: Sharepoint (Return file for Data Analysis / Document Summarization)\", \"tokens\": 4540, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"eb227e100ec44f746c42999049f6121580778ea90f13123efdefa0d79ed2907e\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 18705, \"end_char_idx\": 21307, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "ref_doc_id": "a5c3ef77-5559-4b78-9e02-640583cab1e4", "chroma:document": "'500':\n          description: Server error when there are issues executing the query or encoding the results.\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n*See above and on the [Azure Function cookbook](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function) for more detailed instructions on authentication.*\n\n## FAQ & Troubleshooting\n\n- Why are you using the Microsoft Graph API in your code instead of the [SharePoint API](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom)?\n\n  - The SharePoint API is legacy - per the Microsoft documentation [here](https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph), \u201cFor SharePoint Online, innovation using a REST API against SharePoint is driven via the Microsoft Graph REST API's.\u201d The Graph API gives us more flexibility, and the SharePoint API still runs into the same file issues listed in the [Why is this necessary instead of interacting with the Microsoft Graph API directly?](#why-is-this-necessary-instead-of-interacting-with-the-microsoft-api-directly) section.\n\n- What types of files does this support?\n\n  It follows the same guidelines as the documentation [here](https://help.openai.com/en/articles/8555545-file-uploads-faq) about file uploads.\u00a0\n\n- Why do I need to request an OBO token?\n\n  - When you try to use the same token to authenticate to the Graph API as the one you use to authenticate into the Azure Function, you get an \u201cinvalid audience\u201d token. This is because the audience for the token can only be user\\_impersonation.\n\n  - To address this, the function requests a new token scoped to Files.Read.All within the app using the [On Behalf Of flow](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-on-behalf-of-flow). This will inherit the permissions of the logged in user, meaning this function will only search through files the logged-in user has access to.\u00a0\n\n  - We are purposefully requesting a new On Behalf Of token with each request, because Azure Function Apps are meant to be stateless. You could potentially integrate this with Azure Key Vault to store the secret and retrieve programmatically.\u00a0\n\n*Are there integrations that you\u2019d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we\u2019ll take a look.*"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 84721557-39f0-4887-93c9-cb0f5a6a2c4d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"84721557-39f0-4887-93c9-cb0f5a6a2c4d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"95a92665-2cfd-406f-b078-fc54f01692ba\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f856140c7b0a5d694bf611feac6f24a0c9e26d03e7eb662989461beffb70ce34\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2242, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "# GPT Action Library: Gmail\n\n## Introduction\n\nThis page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information: \n- [Introduction to GPT Actions](https://platform.openai.com/docs/actions)\n- [Introduction to GPT Actions Library](https://platform.openai.com/docs/actions/actions-library)\n- [Example of Building a GPT Action from Scratch](https://platform.openai.com/docs/actions/getting-started)\n\nThis GPT Action provides an overview of how to connect to Google Gmail, Google\u2019s Private & Secure Email for Personal or Business. This Action is connected to the Google Gmail APIs that can read, send, list, and draft emails in the authorized account. \n\n### Value + Example Business Use Cases\n\n**Value**: The Gmail GPT will serve as a powerful tool to streamline communication processes, improve customer engagement, and optimize resource allocation.\n\n**Example Use Cases**: \n- Manage internal communications by summarizing lengthy emails and drafting responses based on previous email threads.\n- Support agents can provide customers with instant responses adhering to a company\u2019s communication guidelines, tone, and style.\n- Reference other GPTs , such as a data analsys GPT, and then ask for a draft/send of the consolidated analysis through email communication.\n\n## Application Information\n\n### Application Key Links\n\nCheck out these links from the application before you get started:\n- Application Website: https://mail.google.com/mail/u/0/#inbox\n- Application API Documentation: https://developers.google.com/gmail/api/guides\n\n### Application Prerequisites\n\nBefore you get started, make sure you\u2019ve a Google Cloud account and that the Gmail API is enabled:\n- Set up a Google Cloud project\n- Enable Gmail API from Google API Library\n- If application\u2019s  \u201cPublishing Status\u201d is \u201cTesting\u201d, ensure users are added to your application\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\nOnce you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 95a92665-2cfd-406f-b078-fc54f01692ba
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"95a92665-2cfd-406f-b078-fc54f01692ba\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"84721557-39f0-4887-93c9-cb0f5a6a2c4d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"edbe3e591534490808343928b34a5bbecba1534eeb7489ba630383da298453d1\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"fe2dcce8-44b9-4ebb-9d9e-083db0dfda29\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"22b1ead1c96e47155276a438d7665db6e13aa297d3bf0698a44b5520b704b4a4\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2245, \"end_char_idx\": 5424, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "```python\n**Context**\nAct as an email assistant designed to enhance user interaction with emails in various ways. This GPT can assist with productivity by summarizing emails/threads, identifying next steps/follow-ups, drafting or sending pre-written responses, and programmatically interacting with third-party tools (e.g., Notion to-dos, Slack channel summaries, data extraction for responses). This GPT has full scope access to the GMAIL OAuth 2.0 API, capable of reading, composing, sending, and permanently deleting emails from Gmail.\n\n**Instructions**\n- Always conclude an email by signing off with logged in user's name, unless otherwise stated.\n- Verify that the email data is correctly encoded in the required format (e.g., base64 for the message body).\n- Email Encoding Process: 1\\ Construct the email message in RFC 2822 format. 2\\ Base64 encode the email message. 3\\Send the encoded message using the API.\n- If not specified, sign all emails with the user name.\n- API Usage: After answering the user's question, do not call the Google API again until another question is asked.\n- All emails created, draft or sent, should be in plain text.\n- Ensure that the email format is clean and is formatted as if someone sent the email from their own inbox. Once a draft is created or email sent, display a message to the user confirming that the draft is ready or the email is sent.\n- Check that the \"to\" email address is valid and in the correct format. It should be in the format \"recipient@example.com\". \n- Only provide summaries of existing emails; do not fabricate email content.\n- Professionalism: Behave professionally, providing clear and concise responses.\n- Clarification: Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.\n- Privacy and Security: Respect user privacy and handle all data securely.\n\n```\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: Gmail Email API\n  version: 1.0.0\n  description: API to read, write, and send emails in a Gmail account.\nservers:\n  - url: https://gmail.googleapis.com\npaths:\n  /gmail/v1/users/{userId}/messages:\n    get:\n      summary: List All Emails\n      description: Lists all the emails in the user's mailbox.\n      operationId: listAllEmails\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n        - name: q\n          in: query\n          schema:\n            type: string\n          description: Query string to filter messages (optional).\n        - name: pageToken\n          in: query\n          schema:\n            type: string\n          description: Token to retrieve a specific page of results in the list.\n        - name: maxResults\n          in: query\n          schema:\n            type: integer\n          description: Maximum number of messages to return."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: fe2dcce8-44b9-4ebb-9d9e-083db0dfda29
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"fe2dcce8-44b9-4ebb-9d9e-083db0dfda29\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"95a92665-2cfd-406f-b078-fc54f01692ba\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"71976221a46a26f99a9f2e4ded6c72509e4dffccb6faa969bafeba8a940fbe60\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"c29b19b7-28dc-4c86-ba5c-ea70ddc5414d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"72b4dfadacf843e7dcde35de009645e362a2b87208f4d0c0ffe9c61210cdf72f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4362, \"end_char_idx\": 7386, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "```python\nopenapi: 3.1.0\ninfo:\n  title: Gmail Email API\n  version: 1.0.0\n  description: API to read, write, and send emails in a Gmail account.\nservers:\n  - url: https://gmail.googleapis.com\npaths:\n  /gmail/v1/users/{userId}/messages:\n    get:\n      summary: List All Emails\n      description: Lists all the emails in the user's mailbox.\n      operationId: listAllEmails\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n        - name: q\n          in: query\n          schema:\n            type: string\n          description: Query string to filter messages (optional).\n        - name: pageToken\n          in: query\n          schema:\n            type: string\n          description: Token to retrieve a specific page of results in the list.\n        - name: maxResults\n          in: query\n          schema:\n            type: integer\n          description: Maximum number of messages to return.\n      responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/MessageList'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/messages/send:\n    post:\n      summary: Send Email\n      description: Sends a new email.\n      operationId: sendEmail\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/Message'\n      responses:\n        '200':\n          description: Email sent successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Message'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/messages/{id}:\n    get:\n      summary: Read Email\n      description: Gets the full email content including headers and body.\n      operationId: readEmail\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n        - name: id\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The ID of the email to retrieve."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: c29b19b7-28dc-4c86-ba5c-ea70ddc5414d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"c29b19b7-28dc-4c86-ba5c-ea70ddc5414d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"fe2dcce8-44b9-4ebb-9d9e-083db0dfda29\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"a7e678160f23066144bf4f175d71cb36d81861d792210613d9a2e0a19d1ede69\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b7ffcbf6-8021-4d0e-948c-47d7bc8b345d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"39eb672ed8cd46e46fae866c265fa5d642f06f7f0f8946f2029ea718714b917f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5431, \"end_char_idx\": 9030, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/MessageList'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/messages/send:\n    post:\n      summary: Send Email\n      description: Sends a new email.\n      operationId: sendEmail\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/Message'\n      responses:\n        '200':\n          description: Email sent successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Message'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/messages/{id}:\n    get:\n      summary: Read Email\n      description: Gets the full email content including headers and body.\n      operationId: readEmail\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n        - name: id\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The ID of the email to retrieve.\n      responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/FullMessage'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/messages/{id}/metadata:\n    get:\n      summary: Get Email Metadata\n      description: Gets the metadata of an email, including subject line.\n      operationId: getEmailMetadata\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n        - name: id\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The ID of the email to retrieve metadata for.\n      responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/MessageMetadata'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/drafts:\n    post:\n      summary: Create Draft\n      description: Creates a new email draft."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: b7ffcbf6-8021-4d0e-948c-47d7bc8b345d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"b7ffcbf6-8021-4d0e-948c-47d7bc8b345d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"c29b19b7-28dc-4c86-ba5c-ea70ddc5414d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"449d75d938edb996103bbbca53cbee6818d1bf342ee28d93dc29d554b0aa48ff\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"bbb0b6fb-7d7f-4385-a9d8-035190f0ee4a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ba4f6997770027cc3c3a2bb5de42b4167878f121df076e68bd44b7d0a58d5114\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7180, \"end_char_idx\": 10491, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "Use \"me\" to indicate the authenticated user.\n        - name: id\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The ID of the email to retrieve.\n      responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/FullMessage'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/messages/{id}/metadata:\n    get:\n      summary: Get Email Metadata\n      description: Gets the metadata of an email, including subject line.\n      operationId: getEmailMetadata\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n        - name: id\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The ID of the email to retrieve metadata for.\n      responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/MessageMetadata'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n        '500':\n          description: Internal Server Error\n  /gmail/v1/users/{userId}/drafts:\n    post:\n      summary: Create Draft\n      description: Creates a new email draft.\n      operationId: createDraft\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/Draft'\n      responses:\n        '200':\n          description: Draft created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Draft'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '500':\n          description: Internal Server Error\ncomponents:\n  schemas:\n    MessageList:\n      type: object\n      properties:\n        messages:\n          type: array\n          items:\n            $ref: '#/components/schemas/Message'\n        nextPageToken:\n          type: string\n    Message:\n      type: object\n      properties:\n        id:\n          type: string\n        threadId:\n          type: string\n        labelIds:\n          type: array\n          items:\n            type: string\n        snippet:\n          type: string\n        raw:\n          type: string\n          format: byte\n          description: The entire email message in an RFC 2822 formatted and base64url encoded string."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: bbb0b6fb-7d7f-4385-a9d8-035190f0ee4a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"bbb0b6fb-7d7f-4385-a9d8-035190f0ee4a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b7ffcbf6-8021-4d0e-948c-47d7bc8b345d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"5f34c82f974b869f4f3ec54ff1d20f31befb5954081d44cca3fb02d303d713a2\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"75a6980b-7be7-411a-b0a3-6592cf96beb3\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"a00ef10ad8a5428dd35989ccc1bdcd60af44b62ac963aa0d103ceeba14ec60ca\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9037, \"end_char_idx\": 12907, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "operationId: createDraft\n      parameters:\n        - name: userId\n          in: path\n          required: true\n          schema:\n            type: string\n          description: The user's email address. Use \"me\" to indicate the authenticated user.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/Draft'\n      responses:\n        '200':\n          description: Draft created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Draft'\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n        '403':\n          description: Forbidden\n        '500':\n          description: Internal Server Error\ncomponents:\n  schemas:\n    MessageList:\n      type: object\n      properties:\n        messages:\n          type: array\n          items:\n            $ref: '#/components/schemas/Message'\n        nextPageToken:\n          type: string\n    Message:\n      type: object\n      properties:\n        id:\n          type: string\n        threadId:\n          type: string\n        labelIds:\n          type: array\n          items:\n            type: string\n        snippet:\n          type: string\n        raw:\n          type: string\n          format: byte\n          description: The entire email message in an RFC 2822 formatted and base64url encoded string.\n    FullMessage:\n      type: object\n      properties:\n        id:\n          type: string\n        threadId:\n          type: string\n        labelIds:\n          type: array\n          items:\n            type: string\n        snippet:\n          type: string\n        payload:\n          type: object\n          properties:\n            headers:\n              type: array\n              items:\n                type: object\n                properties:\n                  name:\n                    type: string\n                  value:\n                    type: string\n            parts:\n              type: array\n              items:\n                type: object\n                properties:\n                  mimeType:\n                    type: string\n                  body:\n                    type: object\n                    properties:\n                      data:\n                        type: string\n    MessageMetadata:\n      type: object\n      properties:\n        id:\n          type: string\n        threadId:\n          type: string\n        labelIds:\n          type: array\n          items:\n            type: string\n        snippet:\n          type: string\n        headers:\n          type: array\n          items:\n            type: object\n            properties:\n              name:\n                type: string\n              value:\n                type: string\n    EmailDraft:\n      type: object\n      properties:\n        to:\n          type: array\n          items:\n            type: string\n        cc:\n          type: array\n          items:\n            type: string\n        bcc:\n          type: array\n          items:\n            type: string\n        subject:\n          type: string\n        body:\n          type: object\n          properties:\n            mimeType:\n              type: string\n              enum: [text/plain, text/html]\n            content:\n              type: string\n    Draft:\n      type: object\n      properties:\n        id:\n          type: string\n        message:\n          $ref: '#/components/schemas/Message'\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n### Pre-Action Steps\n\nBefore you set up authentication in ChatGPT, please take the following steps in the application."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 75a6980b-7be7-411a-b0a3-6592cf96beb3
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb", "title": "GPT Action Library: Gmail", "tokens": 3067, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"75a6980b-7be7-411a-b0a3-6592cf96beb3\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"88000b1c-d489-4bae-8948-ea77c4c2deb5\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3f6fd0138f719e18514850cdd8ac671879438ffd1f1a66bb2df5ae6f982b893d\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bbb0b6fb-7d7f-4385-a9d8-035190f0ee4a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_gmail.ipynb\", \"title\": \"GPT Action Library: Gmail\", \"tokens\": 3067, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"e92ccd8814b87f6aa50d7eec12b34cf60f4e3846004f3340c4912559b3b10b2f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 12635, \"end_char_idx\": 14819, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "ref_doc_id": "88000b1c-d489-4bae-8948-ea77c4c2deb5", "chroma:document": "Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n### Pre-Action Steps\n\nBefore you set up authentication in ChatGPT, please take the following steps in the application.\n\n\n- Go to the Google Cloud Console\n- Navigate to API & Services > Credentials\n\n![gptactions_BigQuery_auth.png](../../../images/gptactions_Gmail_enableAPIs.png)\n\n![gptactions_BigQuery_auth.png](../../../images/gptactions_Gmail_gmailApiTile.png)\n\n- Create new OAuth credentials (or use an existing one)\n\n![gptactions_BigQuery_auth.png](../../../images/gptactions_Gmail_apikey.png)\n\n- Locate your OAuth Client ID & Client Secret and store both values securely (see screenshot below)\n\n![gptactions_BigQuery_auth.png](../../../images/gptactions_Gmail_clientidsecret.png)\n\n### In ChatGPT\n\nIn ChatGPT, click on \"Authentication\" and choose **\"OAuth\"**. Enter in the information below. \n\n- **Client ID**: use Client ID from steps above \n- **Client Secret**: use Client Secret from steps above\n- **Authorization URL**: https://accounts.google.com/o/oauth2/auth\n- **Token URL**: https://oauth2.googleapis.com/token \n- **Scope**: https://mail.google.com/\n- **Token**: Default (POST)\n\n### Post-Action Steps\n\nOnce you've set up authentication in ChatGPT, follow the steps below in the application to finalize the Action. \n\n- Copy the callback URL from the GPT Action\n- In the \u201cAuthorized redirect URIs\u201d (see screenshot above), add your callback URL \n\n\n### FAQ & Troubleshooting\n\n- *Callback URL Error:* If you get a callback URL error in ChatGPT, pay close attention to the screenshot above. You need to add the callback URL directly into GCP for the action to authenticate correctly\n- *Schema calls the wrong project or dataset:* If ChatGPT calls the wrong project or dataset, consider updating your instructions to make it more explicit either (a) which project / dataset should be called or (b) to require the user provide those exact details before it runs the query\n\n*Are there integrations that you\u2019d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we\u2019ll take a look.*"}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: c159c4f5-f720-4615-beb5-e8ac6945544b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"c159c4f5-f720-4615-beb5-e8ac6945544b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"45feced8-e22d-446b-9afc-8d7f2dbf0362\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"07d0ef381472c3aac902c12d8867a2bbcf9a254116916977f9b916c778251b20\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3560, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "# GPT Action Library (Middleware): Azure Function\n\n## Introduction\n\nThis page provides an instruction & guide for developers building middleware to connect a GPT Action to a specific application. Before you proceed, make sure to first familiarize yourself with the following information: \n- [Introduction to GPT Actions](https://platform.openai.com/docs/actions)\n- [Introduction to GPT Actions Library](https://platform.openai.com/docs/actions/actions-library)\n- [Example of Building a GPT Action from Scratch](https://platform.openai.com/docs/actions/getting-started)\n\nThis particular GPT Action provides an overview of how to build an **Azure Function**, MSFT's cloud-based function builder. This documentation helps a user set up an OAuth-protected Azure Function to connect to a GPT Action, and to a sample application. \n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to Azure Function. This can in a few ways:\n\n- 100k character limit in GPT Actions: users can use the middleware to pre-process the text response from an API. For example, you can use OpenAI\u2019s API in the middleware to summarize the text before sending it back to ChatGPT.\n- Typically for actions, users are relying on the SaaS API to return text. You can convert the response for the vendor API into easily digestible text, and it can handle different data types such as structured and unstructured data.\n- It can return files instead of just text. This can be useful to surface CSV files for Data Analysis, or bring back an PDF file and ChatGPT will treat it like an upload. \n\n\n**Example Use Cases**: \n- A user needs to look up files in Sharepoint, but needs a middleware app between ChatGPT and Sharepoint\n- A user has built several steps in a row in an Azure function, and needs to be able to kick off that process using ChatGPT\n\n## Application Information\n\n### Application Key Links\n\nCheck out these links from the application before you get started:\n- Application Website: https://learn.microsoft.com/en-us/azure/azure-functions/\n- Application API Documentation: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference/\n\n### Application Prerequisites\n\nBefore you get started, make sure you go through the following steps in your application environment:\n- Azure Portal with access to create Azure Function Apps and Azure Entra App Registrations\n\n## Application Setup\n\n### Installing the app\n\nYou can read more about languages and deployment options for Azure Functions on the left hand side of the documentation [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp).\u00a0\n\n#### Option 1: Use VSCode\n\nSee Microsoft\u2019s documentation [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs-code?tabs=node-v4,python-v2,isolated-process\\&pivots=programming-language-javascript) for how to deploy using VSCode. If you have familiarity with this approach, feel free to use it.\u00a0\n\n\n#### Option 2: Directly in Azure Portal\n\nSee the documentation [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-function-app-portal?pivots=programming-language-javascript) for how to deploy using the Azure portal. We\u2019ll walk through an example here step by step.\n\n\n##### Part 1: Create Function\n\n![](../../../images/create_function_app.png)\n\n1. Create an [Azure Function app](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp)."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 45feced8-e22d-446b-9afc-8d7f2dbf0362
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"45feced8-e22d-446b-9afc-8d7f2dbf0362\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"c159c4f5-f720-4615-beb5-e8ac6945544b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"339bafba2abdba218f8aca14465d4ad0c00b637accb04ff902030e6ba4e995b9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"0bee4ca7-996e-4ffe-aa57-c01d310983aa\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"a09cb77d51b804c5871ae8a0c0d7b2226feca22395a8c3dba5fdcb506a40a03c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3042, \"end_char_idx\": 6299, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "#### Option 2: Directly in Azure Portal\n\nSee the documentation [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-function-app-portal?pivots=programming-language-javascript) for how to deploy using the Azure portal. We\u2019ll walk through an example here step by step.\n\n\n##### Part 1: Create Function\n\n![](../../../images/create_function_app.png)\n\n1. Create an [Azure Function app](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp). I used the following settings but you can use anything you are comfortable with. Note that not every language / operating system allows for editing the functions in the console directly - the combination I chose below does. For my walkthrough, I left everything as default and made the selections below. The below settings work out of the box for the SharePoint Node.js solutions [here](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc) and [here](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text). \n\n   1. Basics\n\n      1. _Do you want to deploy code or container image?:_\u00a0 **Code**\n\n      2. _Runtime stack:_ **Node.js**\n\n      3. _Operating system:_ **Windows**\n\n   2. Networking\n\n      1. _Enable public access_: **on (need this on to connect to the GPT)**\n\n2. After completing the above, you\u2019ll land on the \u201cDeployments\u201d page. Once the deployment completes (which should only take a few minutes) click on **\u201cGo to Resource\u201d** to go back to the Function App\n\n  > You may get an error the first time you attempt this, click create again and it will likely work. \n\n##### Part 2: Set up Auth\n\n3. On the left-hand side menu of the Azure Function App, click on **Authentication** under the **Settings** menu.\u00a0\n\n   1. Add identity provider\n\n   2. Select **Microsoft** as identity provider.\u00a0\n\n   3. **Workforce** as tenant type\n\n   4. **Create a new application.** The instructions are fairly similar if you are using an existing application, but it is easier to create a new application as it will have the callback URLs and the API exposed automatically using \u201cEasy Auth\u201d. You can read more about that [**here**](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization).\n\n   5. Leave all the other settings on this page as the default, but feel free to change based on your internal guidelines.\n\n   6. On the **permissions** tab, click **Add Permission** and add **Files.Read.All** and **Sites.ReadAll**, then **Add.** This allows this application to read files which is important in order to use the Microsoft Graph Search API. If you are not using this for the SharePoint solution [here](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc) and [here](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text) you can skip this.\n\n4. Once it is created, **click on the enterprise application you just created** (so, leave the Function App page and land on the Enterprise Application that you just spun up)**.** We are now going to give it one more permission, to execute the Azure Function by impersonating the user logging into the application."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 0bee4ca7-996e-4ffe-aa57-c01d310983aa
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"0bee4ca7-996e-4ffe-aa57-c01d310983aa\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"45feced8-e22d-446b-9afc-8d7f2dbf0362\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"5581f3c67dc74cdb30051d4f58c51d8bebf05e8b012a7660489025ff26277f04\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"74d18964-4e41-4338-879c-347b4cf137fb\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"92bcf7b9e4ec0765c5598717fcb5aee4c88a568626eacf600dc111cf73299949\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4713, \"end_char_idx\": 7788, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "##### Part 2: Set up Auth\n\n3. On the left-hand side menu of the Azure Function App, click on **Authentication** under the **Settings** menu.\u00a0\n\n   1. Add identity provider\n\n   2. Select **Microsoft** as identity provider.\u00a0\n\n   3. **Workforce** as tenant type\n\n   4. **Create a new application.** The instructions are fairly similar if you are using an existing application, but it is easier to create a new application as it will have the callback URLs and the API exposed automatically using \u201cEasy Auth\u201d. You can read more about that [**here**](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization).\n\n   5. Leave all the other settings on this page as the default, but feel free to change based on your internal guidelines.\n\n   6. On the **permissions** tab, click **Add Permission** and add **Files.Read.All** and **Sites.ReadAll**, then **Add.** This allows this application to read files which is important in order to use the Microsoft Graph Search API. If you are not using this for the SharePoint solution [here](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc) and [here](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_text) you can skip this.\n\n4. Once it is created, **click on the enterprise application you just created** (so, leave the Function App page and land on the Enterprise Application that you just spun up)**.** We are now going to give it one more permission, to execute the Azure Function by impersonating the user logging into the application. See [here](https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad?tabs=workforce-tenant) for more details.\n\n   1. On the main page, click \u201c**View API Permissions\u201d**\n\n   2. Search for **Microsoft Azure App Service** in the **APIs my organization uses** and find **user\\_impersonation**\u00a0\n\n   3. Add it, then you\u2019ll need an Admin on Azure Portal to **Grant Admin Consent.**\n\n5) **Within that enterprise application**, Click on **\u201cExpose an API\u201d** on the left hand menu under **Manage,** then copy the **scope** that was created using the **Copy to Clipboard** button. The scope should look like \u201capi://\\<insert-uuid>/user\\_impersonation\u201d. **Save this for later as** `SCOPE`**.**\n\n6) Click on **\u201cAuthentication\u201d** on the left hand menu under **Manage**\n\n   1. Under the **Web** section, you\u2019ll notice one callback URI was added automatically. Add the Postman redirect URI (<https://oauth.pstmn.io/v1/callback>) for testing.\n\n7) On the left-hand side, go to **Overview**. Copy the **application (client) ID** and and the **directory (tenant) ID** and **save for later as** `CLIENT_ID` **and** `TENANT_ID`**.**\n\n##### Part 3: Set up Test Function\n\n8. Leave the page by going home and then back to your **Function App.**\n\n9. Click on **Create Function.** For this example, I\u2019m going to develop it in the portal, but you can also use VSCode or another IDE.\n\n   1. Choose **HTTP trigger**\n\n   2. For **Authorization Level,** you can choose any key type you want."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 74d18964-4e41-4338-879c-347b4cf137fb
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"74d18964-4e41-4338-879c-347b4cf137fb\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"0bee4ca7-996e-4ffe-aa57-c01d310983aa\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"2acba2fa6117a5d67bd2779763307ddc06ea515c7738e82fe0f7e2f2b40fa6e8\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"650e0375-b15b-4cb4-bd12-c65849f99f51\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c47f4d62c5ae50566c3f79e698651cf395dd143b6a33fa33ef126c73eaafa630\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6300, \"end_char_idx\": 9111, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "See [here](https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad?tabs=workforce-tenant) for more details.\n\n   1. On the main page, click \u201c**View API Permissions\u201d**\n\n   2. Search for **Microsoft Azure App Service** in the **APIs my organization uses** and find **user\\_impersonation**\u00a0\n\n   3. Add it, then you\u2019ll need an Admin on Azure Portal to **Grant Admin Consent.**\n\n5) **Within that enterprise application**, Click on **\u201cExpose an API\u201d** on the left hand menu under **Manage,** then copy the **scope** that was created using the **Copy to Clipboard** button. The scope should look like \u201capi://\\<insert-uuid>/user\\_impersonation\u201d. **Save this for later as** `SCOPE`**.**\n\n6) Click on **\u201cAuthentication\u201d** on the left hand menu under **Manage**\n\n   1. Under the **Web** section, you\u2019ll notice one callback URI was added automatically. Add the Postman redirect URI (<https://oauth.pstmn.io/v1/callback>) for testing.\n\n7) On the left-hand side, go to **Overview**. Copy the **application (client) ID** and and the **directory (tenant) ID** and **save for later as** `CLIENT_ID` **and** `TENANT_ID`**.**\n\n##### Part 3: Set up Test Function\n\n8. Leave the page by going home and then back to your **Function App.**\n\n9. Click on **Create Function.** For this example, I\u2019m going to develop it in the portal, but you can also use VSCode or another IDE.\n\n   1. Choose **HTTP trigger**\n\n   2. For **Authorization Level,** you can choose any key type you want.\n\n      1. Note this may error out the first time, but it is likely the Function did create, do a refresh of the page to check.\n\n10. Click on the function you just created (You may need to click refresh to see it). Click on **Get Function URL** and save it to test in Postman. You will also use this when creating the OpenAPI spec later when you put it into the GPT.\u00a0\n\n![](../../../images/get_function_url.png)\n\n11. Go back to the function app and click on **Configuration.** Show the value for the `MICROSOFT_PROVIDER_AUTHENTICATION_SECRET` variable, copy it (click advanced edit to copy it), and **save it for later.**\u00a0\u00a0\n\nAt this point, you should have a test function created, and you should have saved a **client id, tenant id, secret, scope, and function URL**. You are now ready to test out the authentication in Postman\n\n##### Part 4: Test Authentication in Postman\n\n12. Try to hit endpoint you created in Postman using those OAuth settings:\n\n    1. **Grant Type:** Authorization Code\n\n    2. **Auth URL**: https://login.microsoftonline.com/`TENANT_ID`/oauth2/v2.0/authorize\n\n    3. **Auth Token URL**: https://login.microsoftonline.com/`TENANT_ID`/oauth2/v2.0/token\n\n    4. **Client ID:** `CLIENT_ID` from step 7 above\n\n    5. **Client secret:** `MICROSOFT_PROVIDER_AUTHENTICATION_SECRET `from step 11 above\n\n    6."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 650e0375-b15b-4cb4-bd12-c65849f99f51
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"650e0375-b15b-4cb4-bd12-c65849f99f51\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"74d18964-4e41-4338-879c-347b4cf137fb\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"3fc3998977a27ccfb88ed75b9707f1b1e8f631f00ef7853c78b080a89f64d86f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"93b951f6-2de6-40e0-bd95-f2a490b77caa\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"6041308991761ca8874cb53a990c89a7d9034bb92959e71f02b3d170cf65225c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7688, \"end_char_idx\": 10648, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "1. Choose **HTTP trigger**\n\n   2. For **Authorization Level,** you can choose any key type you want.\n\n      1. Note this may error out the first time, but it is likely the Function did create, do a refresh of the page to check.\n\n10. Click on the function you just created (You may need to click refresh to see it). Click on **Get Function URL** and save it to test in Postman. You will also use this when creating the OpenAPI spec later when you put it into the GPT.\u00a0\n\n![](../../../images/get_function_url.png)\n\n11. Go back to the function app and click on **Configuration.** Show the value for the `MICROSOFT_PROVIDER_AUTHENTICATION_SECRET` variable, copy it (click advanced edit to copy it), and **save it for later.**\u00a0\u00a0\n\nAt this point, you should have a test function created, and you should have saved a **client id, tenant id, secret, scope, and function URL**. You are now ready to test out the authentication in Postman\n\n##### Part 4: Test Authentication in Postman\n\n12. Try to hit endpoint you created in Postman using those OAuth settings:\n\n    1. **Grant Type:** Authorization Code\n\n    2. **Auth URL**: https://login.microsoftonline.com/`TENANT_ID`/oauth2/v2.0/authorize\n\n    3. **Auth Token URL**: https://login.microsoftonline.com/`TENANT_ID`/oauth2/v2.0/token\n\n    4. **Client ID:** `CLIENT_ID` from step 7 above\n\n    5. **Client secret:** `MICROSOFT_PROVIDER_AUTHENTICATION_SECRET `from step 11 above\n\n    6. **Scope**: `SCOPE` from step 5 above\n\n    7. **Client credentials**: Send client credentials in body\n\n13. You will need to click **Get New Access Token**, and then hit the endpoint you saved in step 10 above. If it was successful, you should get this response: `\u201dThis HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.\u201d`\n\n##### Part 5: Set up your Application on an Azure Function\n\nThis should be done separately and is specific to your app. See the [Sharepoint Cookbook]((https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc)) for an example of that. \n\n##### Part 6: Set up ChatGPT\n\n14. Generate an OpenAPI spec for your endpoint.\u00a0\n\n15. Paste that into the Actions section of a GPT, and choose OAuth as the authentication type. Fill out the OAuth settings the same way you did for Postman above.\u00a0\n\n16. Once you save the action, you will see a callback URI at the bottom of the GPT configuration. Copy that URL, then go **back to your Function App in the Azure Portal**.\n\n17. Click on **Authentication** under **Settings**, then click on your Entra application.\n\n18. Once you are there, then click **Authentication** under the **Manage** section.\n\n19. Add a new Redirect URI under the **Web** section of that page, and paste in the Callback URI you got from step 16, then click Save.\u00a0\n\n20. Test out the GPT and it should work as expected.\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\n*This is application specific."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 93b951f6-2de6-40e0-bd95-f2a490b77caa
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"93b951f6-2de6-40e0-bd95-f2a490b77caa\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"650e0375-b15b-4cb4-bd12-c65849f99f51\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"40c88f4a1ccd71779d1b5d508a13ac619d362c20bafb9d2108f15d18031b6769\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4c55d1f2-47d8-41f3-8c63-77f2136c8c03\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"3874937e35ba6f2e76bd388e7efaf81022ee3dc004e4e10ded0f1060286d7de7\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9112, \"end_char_idx\": 11193, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "**Scope**: `SCOPE` from step 5 above\n\n    7. **Client credentials**: Send client credentials in body\n\n13. You will need to click **Get New Access Token**, and then hit the endpoint you saved in step 10 above. If it was successful, you should get this response: `\u201dThis HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.\u201d`\n\n##### Part 5: Set up your Application on an Azure Function\n\nThis should be done separately and is specific to your app. See the [Sharepoint Cookbook]((https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc)) for an example of that. \n\n##### Part 6: Set up ChatGPT\n\n14. Generate an OpenAPI spec for your endpoint.\u00a0\n\n15. Paste that into the Actions section of a GPT, and choose OAuth as the authentication type. Fill out the OAuth settings the same way you did for Postman above.\u00a0\n\n16. Once you save the action, you will see a callback URI at the bottom of the GPT configuration. Copy that URL, then go **back to your Function App in the Azure Portal**.\n\n17. Click on **Authentication** under **Settings**, then click on your Entra application.\n\n18. Once you are there, then click **Authentication** under the **Manage** section.\n\n19. Add a new Redirect URI under the **Web** section of that page, and paste in the Callback URI you got from step 16, then click Save.\u00a0\n\n20. Test out the GPT and it should work as expected.\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\n*This is application specific. See [Sharepoint Cookbook]((https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc)) for an example*\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\nBelow is an example of what connecting to this Middlware might look like. You'll need to insert your application's & function's information in this section."}


created_at: 2024-07-28 17:45:58
topic: persistent://default/default/308e7593-7e45-4080-bc68-ad4f88ce5b4b
id: 4c55d1f2-47d8-41f3-8c63-77f2136c8c03
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb", "title": "GPT Action Library (Middleware): Azure Function", "tokens": 2978, "retrieve_doc": true, "source": "OpenAI_Cookbooks", "_node_content": "{\"id_\": \"4c55d1f2-47d8-41f3-8c63-77f2136c8c03\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"d494d859-e343-467b-a3b5-513cc56ba16d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"30ac3d629ba14c38c975040baba3b1ba6cab07b83d6f8fa64698b1574861ca5a\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"93b951f6-2de6-40e0-bd95-f2a490b77caa\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_middleware_azure_function.ipynb\", \"title\": \"GPT Action Library (Middleware): Azure Function\", \"tokens\": 2978, \"retrieve_doc\": true, \"source\": \"OpenAI_Cookbooks\"}, \"hash\": \"5beb842f19f21a48aa9f8639103fbfc6caa8436627ea192cbddc90bdae398c3c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9634, \"end_char_idx\": 12713, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "ref_doc_id": "d494d859-e343-467b-a3b5-513cc56ba16d", "chroma:document": "See the [Sharepoint Cookbook]((https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc)) for an example of that. \n\n##### Part 6: Set up ChatGPT\n\n14. Generate an OpenAPI spec for your endpoint.\u00a0\n\n15. Paste that into the Actions section of a GPT, and choose OAuth as the authentication type. Fill out the OAuth settings the same way you did for Postman above.\u00a0\n\n16. Once you save the action, you will see a callback URI at the bottom of the GPT configuration. Copy that URL, then go **back to your Function App in the Azure Portal**.\n\n17. Click on **Authentication** under **Settings**, then click on your Entra application.\n\n18. Once you are there, then click **Authentication** under the **Manage** section.\n\n19. Add a new Redirect URI under the **Web** section of that page, and paste in the Callback URI you got from step 16, then click Save.\u00a0\n\n20. Test out the GPT and it should work as expected.\n\n## ChatGPT Steps\n\n### Custom GPT Instructions \n\n*This is application specific. See [Sharepoint Cookbook]((https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/gpt_action_sharepoint_doc)) for an example*\n\n### OpenAPI Schema \n\nOnce you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\nBelow is an example of what connecting to this Middlware might look like. You'll need to insert your application's & function's information in this section. \n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: {insert title}\n  description: {insert description}\n  version: 1.0.0\nservers:\n  - url: https://{your_function_app_name}.azurewebsites.net/api\n    description: {insert description}\npaths:\n  /{your_function_name}?code={enter your specific endpoint id here}:\n    post:\n      operationId: {insert operationID}\n      summary: {insert summary}\n      requestBody: \n{the rest of this is specific to your application}\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n\n### Pre-Action Steps\n\nBefore you set up authentication in ChatGPT, please take the following steps in the application.\n\n*Follow steps 2 & 4 above to setting up authentication*\n\n### In ChatGPT\n\nIn ChatGPT, click on \"Authentication\" and choose **\"OAuth\"**. Enter in the information below. \n\n- **Client ID**: *see step 12 above*\n- **Client Secret**: *ditto*\n- **Authorization URL**: *ditto*\n- **Token URL**: *ditto*\n- **Scope**: *ditto*\n- **Token**: *ditto*\n\n### Post-Action Steps\n\nOnce you've set up authentication in ChatGPT, follow the steps below in the application to finalize the Action. \n\n*See above for testing out this application*\n\n*Are there integrations that you\u2019d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we\u2019ll take a look.*"}


