# embeddings_queue

created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: bdb7c81d-2f39-4f12-83b6-cfd4d6edbfb6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"bdb7c81d-2f39-4f12-83b6-cfd4d6edbfb6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"49ddd7bc-c1d1-49f4-931c-0ec8e833ffd8\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"bed8e7562514244dcd97355e8100012f30c569f1abb05848d34f3367570760c5\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"1691e55c-c899-45e3-a55c-66c93306f162\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e7146340321845649d3b045caf59e98d38150892b0d9f6f0f95d8b51b08d50a2\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 17112, \"end_char_idx\": 20019, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```\n\nWe'll now use this helper function to process our OpenAI documentation. Feel free to update this to use your own data by changing the folder in `process_files` below.\n\nNote that this will process the documents in chosen folder concurrently, so this should take <30 seconds if using txt files, and slightly longer if using PDFs.\n\n\n```python\n## Customize the location below if you are using different data besides the OpenAI documentation. Note that if you are using a different dataset, you will need to update the categories list as well.\nfolder_name = \"../../../data/oai_docs\"\n\nfiles = [os.path.join(folder_name, f) for f in os.listdir(folder_name) if f.endswith('.txt') or f.endswith('.pdf')]\ndata = []\n\n# Process each file concurrently\nwith concurrent.futures.ThreadPoolExecutor() as executor:\n    futures = {executor.submit(process_file, file_path, idx, categories, embeddings_model): idx for idx, file_path in enumerate(files)}\n    for future in concurrent.futures.as_completed(futures):\n        try:\n            result = future.result()\n            data.extend(result)\n        except Exception as e:\n            print(f\"Error processing file: {str(e)}\")\n\n# Write the data to a CSV file\ncsv_file = os.path.join(\"..\", \"embedded_data.csv\")\nwith open(csv_file, 'w', newline='', encoding='utf-8') as csvfile:\n    fieldnames = [\"id\", \"vector_id\", \"title\", \"text\", \"title_vector\", \"content_vector\",\"category\"]\n    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)\n    writer.writeheader()\n    for row in data:\n        writer.writerow(row)\n        print(f\"Wrote row with id {row['id']} to CSV\")\n\n# Convert the CSV file to a Dataframe\narticle_df = pd.read_csv(\"../embedded_data.csv\")\n# Read vectors from strings back into a list using json.loads\narticle_df[\"title_vector\"] = article_df.title_vector.apply(json.loads)\narticle_df[\"content_vector\"] = article_df.content_vector.apply(json.loads)\narticle_df[\"vector_id\"] = article_df[\"vector_id\"].apply(str)\narticle_df[\"category\"] = article_df[\"category\"].apply(str)\narticle_df.head()\n\n```\n\nWe now have an `embedded_data.csv` file with six columns that we can upload to our vector database! \n\n# Create Azure AI Vector Search\n\n##  Create index\nWe'll define and create a search index using the `SearchIndexClient` from the Azure AI Search Python SDK. The index incorporates both vector search and hybrid search capabilities. For more details, visit Microsoft's documentation on how to [Create a Vector Index](https://learn.microsoft.com/azure/search/vector-search-how-to-create-index?.tabs=config-2023-11-01%2Crest-2023-11-01%2Cpush%2Cportal-check-index)\n\n\n```python\nindex_name = \"azure-ai-search-openai-cookbook-demo\"\n# index_name = \"<insert_name_for_index>\"\n\nindex_client = SearchIndexClient(\n    endpoint=search_service_endpoint, credential=AzureKeyCredential(search_service_api_key)\n)\n# Define the fields for the index. Update these based on your data."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 1691e55c-c899-45e3-a55c-66c93306f162
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"1691e55c-c899-45e3-a55c-66c93306f162\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bdb7c81d-2f39-4f12-83b6-cfd4d6edbfb6\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"3032ea66e4af260e1262a0e1b1a616ff310ac6644fa2177f863f1debe5b34949\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"420a9544-cfdb-44a0-a1c3-6d22a4677a31\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"09095bd7aa3b65d85450acf1978e92b20e1e3294808891f48d59b508d7cf2d89\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 19720, \"end_char_idx\": 23108, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\nindex_name = \"azure-ai-search-openai-cookbook-demo\"\n# index_name = \"<insert_name_for_index>\"\n\nindex_client = SearchIndexClient(\n    endpoint=search_service_endpoint, credential=AzureKeyCredential(search_service_api_key)\n)\n# Define the fields for the index. Update these based on your data.\n# Each field represents a column in the search index\nfields = [\n    SimpleField(name=\"id\", type=SearchFieldDataType.String),  # Simple string field for document ID\n    SimpleField(name=\"vector_id\", type=SearchFieldDataType.String, key=True),  # Key field for the index\n    # SimpleField(name=\"url\", type=SearchFieldDataType.String),  # URL field (commented out)\n    SearchableField(name=\"title\", type=SearchFieldDataType.String),  # Searchable field for document title\n    SearchableField(name=\"text\", type=SearchFieldDataType.String),  # Searchable field for document text\n    SearchField(\n        name=\"title_vector\",\n        type=SearchFieldDataType.Collection(SearchFieldDataType.Single),  # Collection of single values for title vector\n        vector_search_dimensions=1536,  # Number of dimensions in the vector\n        vector_search_profile_name=\"my-vector-config\",  # Profile name for vector search configuration\n    ),\n    SearchField(\n        name=\"content_vector\",\n        type=SearchFieldDataType.Collection(SearchFieldDataType.Single),  # Collection of single values for content vector\n        vector_search_dimensions=1536,  # Number of dimensions in the vector\n        vector_search_profile_name=\"my-vector-config\",  # Profile name for vector search configuration\n    ),\n    SearchableField(name=\"category\", type=SearchFieldDataType.String, filterable=True),  # Searchable field for document category\n]\n\n# This configuration defines the algorithm and parameters for vector search\nvector_search = VectorSearch(\n    algorithms=[\n        HnswAlgorithmConfiguration(\n            name=\"my-hnsw\",  # Name of the HNSW algorithm configuration\n            kind=VectorSearchAlgorithmKind.HNSW,  # Type of algorithm\n            parameters=HnswParameters(\n                m=4,  # Number of bi-directional links created for every new element\n                ef_construction=400,  # Size of the dynamic list for the nearest neighbors during construction\n                ef_search=500,  # Size of the dynamic list for the nearest neighbors during search\n                metric=VectorSearchAlgorithmMetric.COSINE,  # Distance metric used for the search\n            ),\n        )\n    ],\n    profiles=[\n        VectorSearchProfile(\n            name=\"my-vector-config\",  # Name of the vector search profile\n            algorithm_configuration_name=\"my-hnsw\",  # Reference to the algorithm configuration\n        )\n    ],\n)\n\n# Create the search index with the vector search configuration\n# This combines all the configurations into a single search index\nindex = SearchIndex(\n    name=index_name,  # Name of the index\n    fields=fields,  # Fields defined for the index\n    vector_search=vector_search  # Vector search configuration\n\n)\n\n# Create or update the index\n# This sends the index definition to the Azure Search service\nresult = index_client.create_index(index)\nprint(f\"{result.name} created\")  # Output the name of the created index\n```\n\n## Upload Data\n\nNow we'll upload the articles from above that we've stored in `embedded_data.csv` from a pandas DataFrame to an Azure AI Search index."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 420a9544-cfdb-44a0-a1c3-6d22a4677a31
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"420a9544-cfdb-44a0-a1c3-6d22a4677a31\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"1691e55c-c899-45e3-a55c-66c93306f162\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d0959856d8e889ffea7877ca07c26b36dba43a2cb0cf0fe5b24953bc45f21b0c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d02ba7b0-4f52-4319-8ddb-6c33c5553439\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e139fca35c98549565441e2770a6762598fb370601f11d77955b961d92712860\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 23109, \"end_char_idx\": 25723, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "For a detailed guide on data import strategies and best practices, refer to  [Data Import in Azure AI Search](https://learn.microsoft.com/azure/search/search-what-is-data-import).\n\n\n\n```python\n# Convert the 'id' and 'vector_id' columns to string so one of them can serve as our key field\narticle_df[\"id\"] = article_df[\"id\"].astype(str)\narticle_df[\"vector_id\"] = article_df[\"vector_id\"].astype(str)\n\n# Convert the DataFrame to a list of dictionaries\ndocuments = article_df.to_dict(orient=\"records\")\n\n# Log the number of documents to be uploaded\nprint(f\"Number of documents to upload: {len(documents)}\")\n\n# Create a SearchIndexingBufferedSender\nbatch_client = SearchIndexingBufferedSender(\n    search_service_endpoint, index_name, AzureKeyCredential(search_service_api_key)\n)\n# Get the first document to check its schema\nfirst_document = documents[0]\n\n# Get the index schema\nindex_schema = index_client.get_index(index_name)\n\n# Get the field names from the index schema\nindex_fields = {field.name: field.type for field in index_schema.fields}\n\n# Check each field in the first document\nfor field, value in first_document.items():\n    if field not in index_fields:\n        print(f\"Field '{field}' is not in the index schema.\")\n\n# Check for any fields in the index schema that are not in the documents\nfor field in index_fields:\n    if field not in first_document:\n        print(f\"Field '{field}' is in the index schema but not in the documents.\")\n\ntry:\n    if documents:\n        # Add upload actions for all documents in a single call\n        upload_result = batch_client.upload_documents(documents=documents)\n\n        # Check if the upload was successful\n        # Manually flush to send any remaining documents in the buffer\n        batch_client.flush()\n        \n        print(f\"Uploaded {len(documents)} documents in total\")\n    else:\n        print(\"No documents to upload.\")\nexcept HttpResponseError as e:\n    print(f\"An error occurred: {e}\")\n    raise  # Re-raise the exception to ensure it errors out\nfinally:\n    # Clean up resources\n    batch_client.close()\n```\n\n## Test search\nNow that the data is uploaded, we'll test both vector similarity search and hybrid search locally below to make sure it is working as expected.\n\nYou can test both a pure vector search and hybrid search. Pure vector search passes in `None` to the `search_text` below and will only search on vector similarity. Hybrid search will combines the capabilities of traditional keyword-based search by passing in the query text `query` to the `search_text` with vector-based similarity search to provide more relevant and contextual results."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: d02ba7b0-4f52-4319-8ddb-6c33c5553439
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"d02ba7b0-4f52-4319-8ddb-6c33c5553439\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"420a9544-cfdb-44a0-a1c3-6d22a4677a31\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"70f6a25494fed03c0bbe225a2111886e8113816649c32418fc925a6da3941cbc\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"efe36a83-0bfd-4ecf-992e-df048fd22a3f\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"bb4beb9b584c369cccb62e2d23a84ebf72500450ed5c571d1a03c4f1ad43c0aa\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 25727, \"end_char_idx\": 27870, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\nquery = \"What model should I use to embed?\"\n# Note: we'll have the GPT choose the category automatically once we put it in ChatGPT\ncategory =\"models\"\n\nsearch_client = SearchClient(search_service_endpoint, index_name, AzureKeyCredential(search_service_api_key))\nvector_query = VectorizedQuery(vector=generate_embeddings(query, embeddings_model), k_nearest_neighbors=3, fields=\"content_vector\")\n  \nresults = search_client.search(  \n    search_text=None, # Pass in None if you want to use pure vector search, and `query` if you want to use hybrid search\n    vector_queries= [vector_query], \n    select=[\"title\", \"text\"],\n    filter=f\"category eq '{category}'\" \n)\n\nfor result in results:  \n    print(result)\n\n```\n\n## Create Azure Function\n\nAzure Functions are an easy way to build an API on top of our new AI search. Our code (see the `function_app.py` file in this folder, or linked [here](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/function_app.py)) does the following:\n\n1. Takes in an input of the user's query, search index endpoint, the index name, the k_nearest_neighbors*, the search column to use (either content_vector or title_vector), and whether it should use a hybrid query\n2. Takes the user's query and embeds it.\n3. Conducts a vector search and retrieves relevant text chunks.\n4. Returns those relevant text chunks as the response body. \n\n*In the context of vector search, k_nearest_neighbors specifies the number of \"closest\" vectors (in terms of cosine similarity) that the search should return. For example, if k_nearest_neighbors is set to 3, the search will return the 3 vectors in the index that are most similar to the query vector.\n\n> Note that this Azure Function _does not have any authentication_. However, you can set authentication on it following docs [here](https://learn.microsoft.com/en-us/azure/azure-functions/security-concepts?tabs=v4)\n\n### Create storage account\n\nWe can create a new storage account using the code below, but feel free to skip that block and modify the subsequent steps to use an existing storage account. This may take up to 30 seconds."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: efe36a83-0bfd-4ecf-992e-df048fd22a3f
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"efe36a83-0bfd-4ecf-992e-df048fd22a3f\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d02ba7b0-4f52-4319-8ddb-6c33c5553439\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d86410606f7e1d5391dc53d600bf49fcf18adccd138880158388d080885773b1\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"f797702a-ac4d-4ee6-8139-5978cbfe9ec3\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"d39ef8b1882dbf951f971da693677e563d83c5a644cd2f797b5123549bf259f9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 27873, \"end_char_idx\": 29766, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\n## Update below with a different name\nstorage_account_name = \"<enter-storage-account-name>\"\n\n## Use below SKU or any other SKU as per your requirement\nsku = \"Standard_LRS\"\nresource_client = ResourceManagementClient(credential, subscription_id)\nstorage_client = StorageManagementClient(credential, subscription_id)\n\n# Create resource group if it doesn't exist\nrg_result = resource_client.resource_groups.create_or_update(resource_group, {\"location\": region})\n\n# Create storage account\nstorage_async_operation = storage_client.storage_accounts.begin_create(\n    resource_group,\n    storage_account_name,\n    {\n        \"sku\": {\"name\": sku},\n        \"kind\": \"StorageV2\",\n        \"location\": region,\n    },\n)\nstorage_account = storage_async_operation.result()\n\nprint(f\"Storage account {storage_account.name} created\")\n\n```\n\n### Create Function App\nThis Function App is where the python code will execute once it is triggered via a GPT Action. To read more about Function Apps, see the docs [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp). \n\nTo deploy Function Apps, we'll need to use the Azure CLI and Azure Functions Core Tools. \n\n> The below will attempt to install it and run it based on your platform type in your virtual environment, but if that does not work, read the Azure documentation to figure out how to install [Azure Function Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-python?tabs=linux,bash,azure-cli,browser) and [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli). After doing that, run the below `subprocess.run` commands in your terminal after navigating to this folder.\n\nFirst we'll make sure we have the relevant tools in the environment in order to run the Azure commands necessary. This may take a few minutes to install."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: f797702a-ac4d-4ee6-8139-5978cbfe9ec3
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"f797702a-ac4d-4ee6-8139-5978cbfe9ec3\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"efe36a83-0bfd-4ecf-992e-df048fd22a3f\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2a7551b5bb2b30a73d32f32c5c6e3e95e50a59fda34880384bb2873607203643\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"7b38cd56-291b-4e84-a23f-fabcac4e8b61\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"cce1f9e13ec7f459778f6b35924847e19ac9e435703b7c3a2f1992ce004177f4\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 27873, \"end_char_idx\": 32120, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\n## Update below with a different name\nstorage_account_name = \"<enter-storage-account-name>\"\n\n## Use below SKU or any other SKU as per your requirement\nsku = \"Standard_LRS\"\nresource_client = ResourceManagementClient(credential, subscription_id)\nstorage_client = StorageManagementClient(credential, subscription_id)\n\n# Create resource group if it doesn't exist\nrg_result = resource_client.resource_groups.create_or_update(resource_group, {\"location\": region})\n\n# Create storage account\nstorage_async_operation = storage_client.storage_accounts.begin_create(\n    resource_group,\n    storage_account_name,\n    {\n        \"sku\": {\"name\": sku},\n        \"kind\": \"StorageV2\",\n        \"location\": region,\n    },\n)\nstorage_account = storage_async_operation.result()\n\nprint(f\"Storage account {storage_account.name} created\")\n\n```\n\n### Create Function App\nThis Function App is where the python code will execute once it is triggered via a GPT Action. To read more about Function Apps, see the docs [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp). \n\nTo deploy Function Apps, we'll need to use the Azure CLI and Azure Functions Core Tools. \n\n> The below will attempt to install it and run it based on your platform type in your virtual environment, but if that does not work, read the Azure documentation to figure out how to install [Azure Function Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-python?tabs=linux,bash,azure-cli,browser) and [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli). After doing that, run the below `subprocess.run` commands in your terminal after navigating to this folder.\n\nFirst we'll make sure we have the relevant tools in the environment in order to run the Azure commands necessary. This may take a few minutes to install.\n\n\n```python\nos_type = platform.system()\n\nif os_type == \"Windows\":\n    # Install Azure Functions Core Tools on Windows\n    subprocess.run([\"npm\", \"install\", \"-g\", \"azure-functions-core-tools@3\", \"--unsafe-perm\", \"true\"], check=True)\n    # Install Azure CLI on Windows\n    subprocess.run([\"powershell\", \"-Command\", \"Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\\\\AzureCLI.msi; Start-Process msiexec.exe -ArgumentList '/I AzureCLI.msi /quiet' -Wait\"], check=True)\nelif os_type == \"Darwin\":  # MacOS\n    # Install Azure Functions Core Tools on MacOS\n    if platform.machine() == 'arm64':\n        # For M1 Macs\n        subprocess.run([\"arch\", \"-arm64\", \"brew\", \"install\", \"azure-functions-core-tools@3\"], check=True)\n    else:\n        # For Intel Macs\n        subprocess.run([\"brew\", \"install\", \"azure-functions-core-tools@3\"], check=True)\n    # Install Azure CLI on MacOS\n    subprocess.run([\"brew\", \"update\"], check=True)\n    subprocess.run([\"brew\", \"install\", \"azure-cli\"], check=True)\nelif os_type == \"Linux\":\n    # Install Azure Functions Core Tools on Linux\n    subprocess.run([\"curl\", \"https://packages.microsoft.com/keys/microsoft.asc\", \"|\", \"gpg\", \"--dearmor\", \">\", \"microsoft.gpg\"], check=True, shell=True)\n    subprocess.run([\"sudo\", \"mv\", \"microsoft.gpg\", \"/etc/apt/trusted.gpg.d/microsoft.gpg\"], check=True)\n    subprocess.run([\"sudo\", \"sh\", \"-c\", \"'echo \\\"deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main\\\" > /etc/apt/sources.list.d/dotnetdev.list'\"], check=True, shell=True)\n    subprocess.run([\"sudo\", \"apt-get\", \"update\"], check=True)\n    subprocess.run([\"sudo\", \"apt-get\", \"install\", \"azure-functions-core-tools-3\"], check=True)\n    # Install Azure CLI on Linux\n    subprocess.run([\"curl\", \"-sL\", \"https://aka.ms/InstallAzureCLIDeb\", \"|\", \"sudo\", \"bash\"], check=True, shell=True)\nelse:\n    # Raise an error if the operating system is not supported\n    raise OSError(\"Unsupported operating system\")\n\n# Verify the installation of Azure Functions Core Tools\nsubprocess.run([\"func\", \"--version\"], check=True)\n# Verify the installation of Azure CLI\nsubprocess.run([\"az\", \"--version\"], check=True)\n\nsubprocess.run([\n    \"az\", \"login\"\n], check=True)\n```\n\nNow, we need to create a `local.settings.json` file with our key environment variables for Azure"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 7b38cd56-291b-4e84-a23f-fabcac4e8b61
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"7b38cd56-291b-4e84-a23f-fabcac4e8b61\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"f797702a-ac4d-4ee6-8139-5978cbfe9ec3\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"12aa7973ee8daa149e24b7add66fe72a0cf5e20987326182ee43cddf2239c85f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"28c74989-887e-4440-bc5b-3868540e963d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"da02124675a40c469a6698bb71a29fd692b97174b81741ce23c1003646e01ee6\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 32123, \"end_char_idx\": 34773, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\nlocal_settings_content = f\"\"\"\n{{\n  \"IsEncrypted\": false,\n  \"Values\": {{\n    \"AzureWebJobsStorage\": \"UseDevelopmentStorage=true\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"python\",\n    \"OPENAI_API_KEY\": \"{openai_api_key}\",\n    \"EMBEDDINGS_MODEL\": \"{embeddings_model}\",\n    \"SEARCH_SERVICE_API_KEY\": \"{search_service_api_key}\",\n  }}\n}}\n\"\"\"\n\nwith open(\"local.settings.json\", \"w\") as file:\n    file.write(local_settings_content)\n```\n\nCheck the `local.settings.json` file and make sure that the environment variables match what you expect. \n\nNow, give your app a name below, and you are ready to create your Function App and then publish your function. \n\n\n```python\n# Replace this with your own values. This name will appear in the URL of the API call https://<app_name>.azurewebsites.net\napp_name = \"<app-name>\"\n\nsubprocess.run([\n    \"az\", \"functionapp\", \"create\",\n    \"--resource-group\", resource_group,\n    \"--consumption-plan-location\", region,\n    \"--runtime\", \"python\",\n    \"--name\", app_name,\n    \"--storage-account\", storage_account_name,\n    \"--os-type\", \"Linux\",\n], check=True)\n```\n\nOnce we've created the Function App, we now want to add the configuration variables to the function app to use in the function. Specifically, we need the `OPENAI_API_KEY`, the `SEARCH_SERVICE_API_KEY`, and the `EMBEDDINGS_MODEL` as these are all used in the `function_app.py` code.\n\n\n```python\n# Collect the relevant environment variables \nenv_vars = {\n    \"OPENAI_API_KEY\": openai_api_key,\n    \"SEARCH_SERVICE_API_KEY\": search_service_api_key,\n    \"EMBEDDINGS_MODEL\": embeddings_model\n}\n\n# Create the settings argument for the az functionapp create command\nsettings_args = []\nfor key, value in env_vars.items():\n    settings_args.append(f\"{key}={value}\")\n\nsubprocess.run([\n    \"az\", \"functionapp\", \"config\", \"appsettings\", \"set\",\n    \"--name\", app_name,\n    \"--resource-group\", resource_group,\n    \"--settings\", *settings_args\n], check=True)\n```\n\nWe are now ready to publish your function code `function_app.py` to the Azure Function. This may take up to 10 minutes to deploy. Once this is finished, we now have an API endpoint using an Azure Function on top of Azure AI Search.\n\n\n```python\nsubprocess.run([\n    \"func\", \"azure\", \"functionapp\", \"publish\", app_name\n], check=True)\n```\n\n## Input in a Custom GPT in ChatGPT\nNow that we have an Azure Function that queries this Vector Search Index, let's put it as a GPT Action!\n\nSee documentation [here](https://openai.com/index/introducing-gpts/) on GPTs and [here](https://platform.openai.com/docs/actions) on GPT Actions. Use the below as the instructions for the GPT and as the OpenAPI spec for the GPT Action."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 28c74989-887e-4440-bc5b-3868540e963d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"28c74989-887e-4440-bc5b-3868540e963d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7b38cd56-291b-4e84-a23f-fabcac4e8b61\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"5d97d29d4cbddc89f4cb9ad10573cac28991b67d652be83ac6e7b83276c16f49\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"424c9079-ff1a-4d7d-9c1f-66293410d333\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1570acc15216e7b75854b9beb12a95b149e9e28ab8f40783769998a68aae6620\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 33496, \"end_char_idx\": 35386, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\n# Collect the relevant environment variables \nenv_vars = {\n    \"OPENAI_API_KEY\": openai_api_key,\n    \"SEARCH_SERVICE_API_KEY\": search_service_api_key,\n    \"EMBEDDINGS_MODEL\": embeddings_model\n}\n\n# Create the settings argument for the az functionapp create command\nsettings_args = []\nfor key, value in env_vars.items():\n    settings_args.append(f\"{key}={value}\")\n\nsubprocess.run([\n    \"az\", \"functionapp\", \"config\", \"appsettings\", \"set\",\n    \"--name\", app_name,\n    \"--resource-group\", resource_group,\n    \"--settings\", *settings_args\n], check=True)\n```\n\nWe are now ready to publish your function code `function_app.py` to the Azure Function. This may take up to 10 minutes to deploy. Once this is finished, we now have an API endpoint using an Azure Function on top of Azure AI Search.\n\n\n```python\nsubprocess.run([\n    \"func\", \"azure\", \"functionapp\", \"publish\", app_name\n], check=True)\n```\n\n## Input in a Custom GPT in ChatGPT\nNow that we have an Azure Function that queries this Vector Search Index, let's put it as a GPT Action!\n\nSee documentation [here](https://openai.com/index/introducing-gpts/) on GPTs and [here](https://platform.openai.com/docs/actions) on GPT Actions. Use the below as the instructions for the GPT and as the OpenAPI spec for the GPT Action.\n\n\n### Create OpenAPI Spec\nBelow is a sample OpenAPI spec. When we run the block below, a functional spec should be copied to the clipboard to paste in the GPT Action.\n\nNote that this does not have any authentication by default, but you can set up Azure Functions with OAuth by following the pattern in [this cookbook](https://cookbook.openai.com/examples/chatgpt/sharepoint_azure_function/using_azure_functions_and_microsoft_graph_to_query_sharepoint) in the Authentication section or looking at the documentation [here](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization)."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 424c9079-ff1a-4d7d-9c1f-66293410d333
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"424c9079-ff1a-4d7d-9c1f-66293410d333\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"28c74989-887e-4440-bc5b-3868540e963d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"884cdf5dfeb82e8ba89fa1415d20f698abcaaa5058e7dc3582210ce9670bb031\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"f872e515-41f0-4d57-8d8c-ff20bed2d4a5\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"656140e72a3e6217c4006e5160f1f47f0387be5d092554f2077a7aeeb402c574\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 34294, \"end_char_idx\": 38289, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\nsubprocess.run([\n    \"func\", \"azure\", \"functionapp\", \"publish\", app_name\n], check=True)\n```\n\n## Input in a Custom GPT in ChatGPT\nNow that we have an Azure Function that queries this Vector Search Index, let's put it as a GPT Action!\n\nSee documentation [here](https://openai.com/index/introducing-gpts/) on GPTs and [here](https://platform.openai.com/docs/actions) on GPT Actions. Use the below as the instructions for the GPT and as the OpenAPI spec for the GPT Action.\n\n\n### Create OpenAPI Spec\nBelow is a sample OpenAPI spec. When we run the block below, a functional spec should be copied to the clipboard to paste in the GPT Action.\n\nNote that this does not have any authentication by default, but you can set up Azure Functions with OAuth by following the pattern in [this cookbook](https://cookbook.openai.com/examples/chatgpt/sharepoint_azure_function/using_azure_functions_and_microsoft_graph_to_query_sharepoint) in the Authentication section or looking at the documentation [here](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization).\n\n\n```python\n\nspec = f\"\"\"\nopenapi: 3.1.0\ninfo:\n  title: Vector Similarity Search API\n  description: API for performing vector similarity search.\n  version: 1.0.0\nservers:\n  - url: https://{app_name}.azurewebsites.net/api\n    description: Main (production) server\npaths:\n  /vector_similarity_search:\n    post:\n      operationId: vectorSimilaritySearch\n      summary: Perform a vector similarity search.\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                search_service_endpoint:\n                  type: string\n                  description: The endpoint of the search service.\n                index_name:\n                  type: string\n                  description: The name of the search index.\n                query:\n                  type: string\n                  description: The search query.\n                k_nearest_neighbors:\n                  type: integer\n                  description: The number of nearest neighbors to return.\n                search_column:\n                  type: string\n                  description: The name of the search column.\n                use_hybrid_query:\n                  type: boolean\n                  description: Whether to use a hybrid query.\n                category:\n                  type: string\n                  description: category to filter.\n              required:\n                - search_service_endpoint\n                - index_name\n                - query\n                - k_nearest_neighbors\n                - search_column\n                - use_hybrid_query\n      responses:\n        '200':\n          description: A successful response with the search results.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  results:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        id:\n                          type: string\n                          description: The identifier of the result item.\n                        score:\n                          type: number\n                          description: The similarity score of the result item.\n                        content:\n                          type: object\n                          description: The content of the result item.\n        '400':\n          description: Bad request due to missing or invalid parameters.\n        '500':\n          description: Internal server error.\n\"\"\"\npyperclip.copy(spec)\nprint(\"OpenAPI spec copied to clipboard\")\nprint(spec)\n```\n\n### Create GPT Instructions\n\nFeel free to modify instructions as you see fit. Check out our docs [here](https://platform.openai.com/docs/guides/prompt-engineering) for some tips on prompt engineering."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: f872e515-41f0-4d57-8d8c-ff20bed2d4a5
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb", "title": "Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT", "tokens": 8713, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"f872e515-41f0-4d57-8d8c-ff20bed2d4a5\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"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\": \"c7f5fa63-a6d8-42f0-be9f-6da64870c366\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2ac92a14208add6de440c8322277d55e8ca59151af9a73c7605b06cb2aa6327b\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"424c9079-ff1a-4d7d-9c1f-66293410d333\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/rag-quickstart/azure/Azure_AI_Search_with_Azure_Functions_and_GPT_Actions_in_ChatGPT.ipynb\", \"title\": \"Azure AI Search as a vector database + Azure Functions for GPT integration in ChatGPT\", \"tokens\": 8713, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"1464437bc8f3e4ef1505af4e433c5c6597097b1c42ffb64fa6c87588f266835a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 38292, \"end_char_idx\": 39960, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "ref_doc_id": "c7f5fa63-a6d8-42f0-be9f-6da64870c366", "chroma:document": "```python\ninstructions = f'''\nYou are an OAI docs assistant. You have an action in your knowledge base where you can make a POST request to search for information. The POST request should always include: {{\n    \"search_service_endpoint\": \"{search_service_endpoint}\",\n    \"index_name\": {index_name},\n    \"query\": \"<user_query>\",\n    \"k_nearest_neighbors\": 1,\n    \"search_column\": \"content_vector\",\n    \"use_hybrid_query\": true,\n    \"category\": \"<category>\"\n}}. Only the query and category change based on the user's request. Your goal is to assist users by performing searches using this POST request and providing them with relevant information based on the query.\n\nYou must only include knowledge you get from your action in your response.\nThe category must be from the following list: {categories}, which you should determine based on the user's query. If you cannot determine, then do not include the category in the POST request.\n'''\npyperclip.copy(instructions)\nprint(\"GPT Instructions copied to clipboard\")\nprint(instructions)\n```\n\nWe now have a GPT that queries a vector database! \n\n# Recap\nWe've now successfully integrated Azure AI Search with GPT Actions in ChatGPT by doing the following:\n1. embedded them using OpenAI's embeddings, while adding some additional metadata using gpt-4o.\n2. uploaded that data to Azure AI Search.\n3. created an endpoint to query it using Azure Functions.\n4. incorporated it into a Custom GPT. \n\nOur GPT can now retrieve information to help answer user queries, making it much more accurate and customized to our data. Here's the GPT in action:\n\n# ![azure-rag-quickstart-gpt.png](../../../../images/azure-rag-quickstart-gpt.png)"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 3fc96b92-edcc-40e4-82c1-4b92c2a5006b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"3fc96b92-edcc-40e4-82c1-4b92c2a5006b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5c3789c6-501a-4057-b10f-4b0b41ef4ff9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"d92159f1fd1c7fd540d2a233c74b4ebe8dfc72e9c790502457153290acef14f9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2662, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "# Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\n\n\n\n## Overview\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\n\n## How it Works\n\nThere are two solutions below, with code for each in the repository.\u00a0\n\nThe first solution **Solution 1** 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, treated the same way as if you uploaded the file directly to the conversation. This solution can handle more types of files than the other solution below, but does have size volume limitations (see docs [here](https://platform.openai.com/docs/actions/sending-files))\n\nThe second solution **Solution 2** pre-processes the file within the Azure Function. The Azure Function returns text, instead of the base64 encoded file. Due to the pre-processing and the conversion to text, this solution is best used for large, unstructured documents, and for when you want to analyze more than the amount of files supported in the first solution (see documentation [here](https://platform.openai.com/docs/actions/sending-files)).\n\n\n### Solution 1: Returning the file to GPT using the [Returning Files](https://platform.openai.com/docs/actions/sending-files) pattern\n\n![](../../../images/solution_1.gif)\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\n![](../../../images/solution_1_architecture.png)\n\n\n### Solution 2: Converting the file to text in the Azure Function\n\n\n![](../../../images/solution_2.gif)"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 5c3789c6-501a-4057-b10f-4b0b41ef4ff9
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"5c3789c6-501a-4057-b10f-4b0b41ef4ff9\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"3fc96b92-edcc-40e4-82c1-4b92c2a5006b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"1e002a58db811701eefc14ed6dd81e84505b4b9d7edc5b8621126a5e6ad5ab31\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"a4423122-4570-44c4-9064-7a25333ebeaa\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"16da118ca5df00633330efd515c170b36a862e194322564dbb63f6bebec31e94\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1850, \"end_char_idx\": 3649, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "### Solution 1: Returning the file to GPT using the [Returning Files](https://platform.openai.com/docs/actions/sending-files) pattern\n\n![](../../../images/solution_1.gif)\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\n![](../../../images/solution_1_architecture.png)\n\n\n### Solution 2: Converting the file to text in the Azure Function\n\n\n![](../../../images/solution_2.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.\n\n2. For each file that is found, convert it to a consistent readable format and retrieve all the text.\n\n3. Use GPT 3.5-turbo (gpt-3.5-turbo-0125) to extract the relevant text from the files based on the initial user\u2019s question. Note the pricing of GPT 3.5 turbo [here](https://openai.com/pricing#language-models) - since we are dealing with small token chunks, the cost of this step is nominal.\u00a0\u00a0\n\n4. Returns that data to ChatGPT. The GPT then uses that information to respond to the user's initial question.\n\nAs you can see from the below architecture diagram, the first three steps are the same as Solution 1. The main difference is that this solution converts the file to text instead of a base64 string, and then summarizes that text using GPT 3.5 Turbo.\n\n\n![](../../../images/solution_2_architecture.png)"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: a4423122-4570-44c4-9064-7a25333ebeaa
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"a4423122-4570-44c4-9064-7a25333ebeaa\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5c3789c6-501a-4057-b10f-4b0b41ef4ff9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"e668c0c2bd50b087d4d6df0b58cb6753cb444bd8a3c9d228ceaff87c4443a374\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"fff7b787-f77d-494e-a8a2-678ab70de892\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"3bbd4e827c05984ebbc5515eb87a59d2433d2793d2beb9ac38446c4c68b0c329\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2508, \"end_char_idx\": 5776, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "![](../../../images/solution_1_architecture.png)\n\n\n### Solution 2: Converting the file to text in the Azure Function\n\n\n![](../../../images/solution_2.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.\n\n2. For each file that is found, convert it to a consistent readable format and retrieve all the text.\n\n3. Use GPT 3.5-turbo (gpt-3.5-turbo-0125) to extract the relevant text from the files based on the initial user\u2019s question. Note the pricing of GPT 3.5 turbo [here](https://openai.com/pricing#language-models) - since we are dealing with small token chunks, the cost of this step is nominal.\u00a0\u00a0\n\n4. Returns that data to ChatGPT. The GPT then uses that information to respond to the user's initial question.\n\nAs you can see from the below architecture diagram, the first three steps are the same as Solution 1. The main difference is that this solution converts the file to text instead of a base64 string, and then summarizes that text using GPT 3.5 Turbo.\n\n\n![](../../../images/solution_2_architecture.png)\n\n\n### Why is this necessary instead of interacting with the Microsoft API directly?\n\n- Following the guide [here](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. So, we need have two options, corresponding to the two solutions above:\n\n  - **Solution 1: restructure the response for compatibility:**\u00a0\n\n    1. We 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  - **Solution 2: extract the text from the files directly:**\n\n    1. loop through the returned files and download the files using the [Download File endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) or [Convert File endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http)\n\n    2. convert that Binary stream to human readable text using [pdf-parse](https://www.npmjs.com/package/pdf-parse)\n\n    3. Then, we can optimize further by summarizing using gpt-3.5-turbo in the function to help with the 100,000 character limit we impose on Actions today.\u00a0\n\n\n## Prerequisites\n\n- Azure Portal with access to create Azure Function Apps and Azure Entra App Registrations\n\n- Postman (and knowledge of APIs and OAuth)\n\n- _Solution 2 Only:_ An OpenAI API Key from platform.openai.com\n\n\n## Solution 1 + Solution 2 Installation Instructions\n\nThe below are the instructions for setting up the Azure Function with Authentication. Please make sure to follow these steps before implementing the code. \n\n> These installation instructions apply to both Solution 1 and Solution 2. We encourage setting both solutions up as separate functions within the same Function App to test which works best for you, as once you set up one function, it takes only a few minutes to set up another function in that same function app."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: fff7b787-f77d-494e-a8a2-678ab70de892
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"fff7b787-f77d-494e-a8a2-678ab70de892\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"a4423122-4570-44c4-9064-7a25333ebeaa\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"7716109ce1fb491321135a810a28239f001a9ff49a2f6cc399d4ad82b55441f4\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b92843be-d1a5-4ced-a981-86261c059eaf\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"71ccef29f47fb8ba5b9d2066fc28bd7013953d4e5ed671526fa00bfc0e96e3f6\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5031, \"end_char_idx\": 7862, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "## Prerequisites\n\n- Azure Portal with access to create Azure Function Apps and Azure Entra App Registrations\n\n- Postman (and knowledge of APIs and OAuth)\n\n- _Solution 2 Only:_ An OpenAI API Key from platform.openai.com\n\n\n## Solution 1 + Solution 2 Installation Instructions\n\nThe below are the instructions for setting up the Azure Function with Authentication. Please make sure to follow these steps before implementing the code. \n\n> These installation instructions apply to both Solution 1 and Solution 2. We encourage setting both solutions up as separate functions within the same Function App to test which works best for you, as once you set up one function, it takes only a few minutes to set up another function in that same function app.\n\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\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> Note: you can use Part 1 - Part 4 below to set up any Azure Function App with Entra Authentication\n\n\n##### Part 1: Create Function\n\n\n![](../../../images/create_function_app.png)\n\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\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: b92843be-d1a5-4ced-a981-86261c059eaf
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"b92843be-d1a5-4ced-a981-86261c059eaf\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"fff7b787-f77d-494e-a8a2-678ab70de892\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"df8a98ae81c37de4d1d33fbf0ee0962efc7f05808eb80889440b8cd727aecb86\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"63b700d1-bbdc-44b1-b820-6d50f97c6dd4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e0d2712dbc56c9c372c202f365e757622269b5d94db053d911f13a8132b38e31\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6372, \"end_char_idx\": 10316, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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> Note: you can use Part 1 - Part 4 below to set up any Azure Function App with Entra Authentication\n\n\n##### Part 1: Create Function\n\n\n![](../../../images/create_function_app.png)\n\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\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\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.\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`**.**"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 63b700d1-bbdc-44b1-b820-6d50f97c6dd4
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"63b700d1-bbdc-44b1-b820-6d50f97c6dd4\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b92843be-d1a5-4ced-a981-86261c059eaf\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"2a001a9a346f822207466ef64f2a1c4b780c29437d5c2736ceb01e5c2de8945f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5a68a9b9-914f-4b84-a8e4-6199c1e3b086\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"9b820fab1b9917b0146cbd3e8a290c12184ea4af4c62d4c10932c66f19f8e5e8\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10319, \"end_char_idx\": 12971, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "##### 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\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\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/](about:blank)`TENANT_ID`[/oauth2/v2.0/authorize](about:blank)\n\n    3. **Auth Token URL**: [https://login.microsoftonline.com/`TENANT_ID`/oauth2/v2.0/token](about:blank)\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\n##### Part 5: Add in Function Code\n\nNow that you have an authenticated Azure Function, we can update the function to search SharePoint / O365\n\n\n14. 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) for Solution 1 and [this file](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_two_preprocessing.js) for Solution 2.  Save the function."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 5a68a9b9-914f-4b84-a8e4-6199c1e3b086
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"5a68a9b9-914f-4b84-a8e4-6199c1e3b086\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"63b700d1-bbdc-44b1-b820-6d50f97c6dd4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"b5e797bec402d7a45b829a188ada7a65276540f99e37904b73be2430915f6826\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"282168ce-d4ab-4d33-b19a-d3493c0f8505\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7ab420b16a47b82ab049250898583c5bc8401310a2430cc8b7e899ca8619e537\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 11496, \"end_char_idx\": 14361, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "##### 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/](about:blank)`TENANT_ID`[/oauth2/v2.0/authorize](about:blank)\n\n    3. **Auth Token URL**: [https://login.microsoftonline.com/`TENANT_ID`/oauth2/v2.0/token](about:blank)\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\n##### Part 5: Add in Function Code\n\nNow that you have an authenticated Azure Function, we can update the function to search SharePoint / O365\n\n\n14. 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) for Solution 1 and [this file](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_two_preprocessing.js) for Solution 2.  Save the function.\u00a0\n\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\n15. 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\n    3. _Solution 2 only:_\n\n       1. `OPENAI_API_KEY:` spin up an OpenAI API key on platform.openai.com.\n\n16. 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\n       3. _Solution 2 only:_\n\n          1. `npm install pdf-parse`\n\n          2. `npm install openai`\n\n17. 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     *Solution 1*:\n     ```json\n    {\n        \"searchTerm\": \"<choose a search term>\"\n    }\n    ```\n    *Solution 2*: \n    ```json\n    {\n        \"query\": \"<choose a question>\",\n        \"searchTerm\": \"<choose a search term>\"\n    }\n    ```\n18. If you get a response, you are ready to set this up with a Custom GPT!"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 282168ce-d4ab-4d33-b19a-d3493c0f8505
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"282168ce-d4ab-4d33-b19a-d3493c0f8505\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5a68a9b9-914f-4b84-a8e4-6199c1e3b086\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"07a11b33de0b525d4402ad3daf93ebd50c20d540f0cde96de7e57159ed38cc8c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"9914a7a7-0bf0-4b0a-8a35-ad6d9aad5d4a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"10348bb134bcf4ba4429bcc99563c05ef9681541e341bed5291c233eaf562e6a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 12975, \"end_char_idx\": 16131, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "> **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\n15. 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\n    3. _Solution 2 only:_\n\n       1. `OPENAI_API_KEY:` spin up an OpenAI API key on platform.openai.com.\n\n16. 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\n       3. _Solution 2 only:_\n\n          1. `npm install pdf-parse`\n\n          2. `npm install openai`\n\n17. 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     *Solution 1*:\n     ```json\n    {\n        \"searchTerm\": \"<choose a search term>\"\n    }\n    ```\n    *Solution 2*: \n    ```json\n    {\n        \"query\": \"<choose a question>\",\n        \"searchTerm\": \"<choose a search term>\"\n    }\n    ```\n18. If you get a response, you are ready to set this up with a Custom GPT!\n\n\n##### Part 6: Setting it up in a Custom GPT\n\n19. Generate an OpenAPI spec for your endpoint.\u00a0\n\n20. 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\n21. 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\n22. Click on **Authentication** under **Settings**, then click on your Entra application.\n\n23. Once you are there, then click **Authentication** under the **Manage** section.\n\n24. Add a new Redirect URI under the **Web** section of that page, and paste in the Callback URI you got from step 20, then click Save.\u00a0\n\n25. Customize the prompt to use this action. You can see a sample prompt in the Sample GPT Instructions in this document, which is customized to try three times to find an answer by changing the searchTerm.\u00a0\n\n26. Test out the GPT and it should work as expected.\n\n\n## Solution 1 Detailed Walkthrough: Returning the File to GPT using the [Returning Files](https://platform.openai.com/docs/actions/sending-files) Pattern\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). If you are interested in Solution 2 instead, you can jump [here](#solution-2-converting-the-file-to-text-in-the-azure-function-1). \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)."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 9914a7a7-0bf0-4b0a-8a35-ad6d9aad5d4a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"9914a7a7-0bf0-4b0a-8a35-ad6d9aad5d4a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"282168ce-d4ab-4d33-b19a-d3493c0f8505\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"86f3dda9acd5072aa0bad1bef81477082b9c586d3b83cfddd490bc2a669caacb\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"9a894db9-1dc3-4d29-92c7-5271fb9e727b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7c463bcf130770fb3ec03be51a77c0c55d51607aaf65f6f016f151477c6f8220\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 15375, \"end_char_idx\": 18123, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "## Solution 1 Detailed Walkthrough: Returning the File to GPT using the [Returning Files](https://platform.openai.com/docs/actions/sending-files) Pattern\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). If you are interested in Solution 2 instead, you can jump [here](#solution-2-converting-the-file-to-text-in-the-azure-function-1). \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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 9a894db9-1dc3-4d29-92c7-5271fb9e727b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"9a894db9-1dc3-4d29-92c7-5271fb9e727b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"9914a7a7-0bf0-4b0a-8a35-ad6d9aad5d4a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"e3a38b43bcaf3ecc673b312addfff882445c16555a79e83e39607f1ed301d947\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"2b4602db-ca31-4cee-b304-766c9c3962a6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7db814d396dcc8e6ee55df676c6bb3bd6db91b0492137bfde266e988f624d8bb\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 16816, \"end_char_idx\": 20015, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "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.\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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 2b4602db-ca31-4cee-b304-766c9c3962a6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"2b4602db-ca31-4cee-b304-766c9c3962a6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"9a894db9-1dc3-4d29-92c7-5271fb9e727b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"e4704f7f1723f856d7653ce4c4deaaa12a4a2315c619ad4e27e0bad82bf1e156\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d569737d-fdb4-4a54-9c98-f5cb6290baa9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ef6c3b8a6b4665a0d472a2b7133e174a5ed33000c03d484aa182a46bbb94ae8d\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 19420, \"end_char_idx\": 21757, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: d569737d-fdb4-4a54-9c98-f5cb6290baa9
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"d569737d-fdb4-4a54-9c98-f5cb6290baa9\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"2b4602db-ca31-4cee-b304-766c9c3962a6\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"68cfe30c5b02e9cb43278fa6370fa054e049176d772e460a08a3a40ec3961a8b\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"a0285308-7dae-41c3-8d73-48a89e094360\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"0f067d4e1f335db5a83b7310db87dfc1010700e2f7c636c90907f9f21b6297ba\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 19883, \"end_char_idx\": 24905, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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### Sample GPT Instructions"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: a0285308-7dae-41c3-8d73-48a89e094360
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"a0285308-7dae-41c3-8d73-48a89e094360\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d569737d-fdb4-4a54-9c98-f5cb6290baa9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"3de81f97f5f75f6c6c2417a90043b975a8268ef686de912d2d6eb6532ae9c6e4\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b1cb9390-59ad-4bda-84da-3c117be5e3d4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"3e313ed78309cf1f662323f8bad2f4af993c8e2888d637aa73e3c998248f2f1e\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 24908, \"end_char_idx\": 28638, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "```text\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### Sample OpenAPI Spec\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 [here](#part-3-set-up-test-function)\n\n```yaml\nopenapi: 3.0.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## Solution 2 Detailed Walkthrough: Converting the file to text in the Azure Function"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: b1cb9390-59ad-4bda-84da-3c117be5e3d4
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"b1cb9390-59ad-4bda-84da-3c117be5e3d4\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"a0285308-7dae-41c3-8d73-48a89e094360\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"1524a96ca4844be7a27043b10408efdaa983ceb0ad13216377e5ffb75139912c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4b8d5dbc-e722-46f1-8a3b-59a668baac4b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c930271d7bfe294e892e48097475080244411c50ddecec5aedf3c7f907dd14fc\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 28641, \"end_char_idx\": 31076, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "The below walks through setup instructions and walkthrough unique to this solution of pre-processing the files and extracting summaries in the Azure Function. You can find the entire code [here](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_two_preprocessing.js).\n\n### Code Walkthrough\n\n#### Implementing the Authentication\u00a0\n\nThis solution follows the same authentication steps as solution 1 above - see [Initializing the Microsoft Graph Client](#initializing-the-microsoft-graph-client) and [Obtaining an On-Behalf-Of (OBO) Token](#obtaining-an-on-behalf-of-obo-token) sections.\n\n\n#### Retrieving Content from O365 / SharePoint Items\n\nThis function fetches the content of drive items, handling different file types and converting files to PDF when necessary for text extraction. This uses the [download endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) for PDFs and the [convert endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http) for other supported file types.\n```javascript\nconst getDriveItemContent = async (client, driveId, itemId, name) => {\n    try {\n        const fileType = path.extname(name).toLowerCase();\n        // the below files types are the ones that are able to be converted to PDF to extract the text. See https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http\n        const allowedFileTypes = ['.pdf', '.doc', '.docx', '.odp', '.ods', '.odt', '.pot', '.potm', '.potx', '.pps', '.ppsx', '.ppsxm', '.ppt', '.pptm', '.pptx', '.rtf'];\n        // filePath changes based on file type, adding ?format=pdf to convert non-pdf types to pdf for text extraction, so all files in allowedFileTypes above are converted to pdf\n        const filePath = `/drives/${driveId}/items/${itemId}/content` + ((fileType === '.pdf' || fileType === '.txt' || fileType === '.csv') ? '' : '?format=pdf');\n        if (allowedFileTypes.includes(fileType)) {\n            response = await client.api(filePath).getStream();\n            // The below takes the chunks in response and combines\n            let chunks = [];\n            for await (let chunk of response) {\n                chunks.push(chunk);\n            }\n            let buffer = Buffer.concat(chunks);\n            // the below extracts the text from the PDF."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 4b8d5dbc-e722-46f1-8a3b-59a668baac4b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"4b8d5dbc-e722-46f1-8a3b-59a668baac4b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b1cb9390-59ad-4bda-84da-3c117be5e3d4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"dac7a9fcb26bf941db013afe3bd2df44615a0fb7e628fa8fa558a544135bac38\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"fa4b487e-97d9-4431-9db3-85c7ca09ea38\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"70b3611d472007836ddaef22121ee5c2bb33e28aefd027a18e24ef014a537771\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 29479, \"end_char_idx\": 32708, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "This uses the [download endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) for PDFs and the [convert endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http) for other supported file types.\n```javascript\nconst getDriveItemContent = async (client, driveId, itemId, name) => {\n    try {\n        const fileType = path.extname(name).toLowerCase();\n        // the below files types are the ones that are able to be converted to PDF to extract the text. See https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http\n        const allowedFileTypes = ['.pdf', '.doc', '.docx', '.odp', '.ods', '.odt', '.pot', '.potm', '.potx', '.pps', '.ppsx', '.ppsxm', '.ppt', '.pptm', '.pptx', '.rtf'];\n        // filePath changes based on file type, adding ?format=pdf to convert non-pdf types to pdf for text extraction, so all files in allowedFileTypes above are converted to pdf\n        const filePath = `/drives/${driveId}/items/${itemId}/content` + ((fileType === '.pdf' || fileType === '.txt' || fileType === '.csv') ? '' : '?format=pdf');\n        if (allowedFileTypes.includes(fileType)) {\n            response = await client.api(filePath).getStream();\n            // The below takes the chunks in response and combines\n            let chunks = [];\n            for await (let chunk of response) {\n                chunks.push(chunk);\n            }\n            let buffer = Buffer.concat(chunks);\n            // the below extracts the text from the PDF.\n            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 3.5-Turbo 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-3.5-turbo due to speed to prevent timeouts."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: fa4b487e-97d9-4431-9db3-85c7ca09ea38
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"fa4b487e-97d9-4431-9db3-85c7ca09ea38\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"4b8d5dbc-e722-46f1-8a3b-59a668baac4b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"1a7068eb61c47047e4f602de908ee989262a8367529e65314fb4e385c288b432\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"04ac698a-da5e-403e-9959-136a60d37380\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1d6b2c634281e3f181c15f8121224082806161ebb54580e3a5037c3e3aa42a9d\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 31089, \"end_char_idx\": 34540, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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 3.5-Turbo 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-3.5-turbo due to speed to prevent timeouts. You can tweak this prompt as needed\n            model: \"gpt-3.5-turbo-0125\",\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 04ac698a-da5e-403e-9959-136a60d37380
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"04ac698a-da5e-403e-9959-136a60d37380\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"fa4b487e-97d9-4431-9db3-85c7ca09ea38\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d1c8651a554abaa2f97a2c83f4627037d0284bd96ed3e0b05610cbda3d7a0f11\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"53c48573-1cf5-4402-a522-9104ba34cb8d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1ec5993c3d924ff612b5843853f3c98473f9d6e47dbeb66f96bc834a05f6074b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 32709, \"end_char_idx\": 35645, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "You can tweak this prompt as needed\n            model: \"gpt-3.5-turbo-0125\",\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.\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 53c48573-1cf5-4402-a522-9104ba34cb8d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"53c48573-1cf5-4402-a522-9104ba34cb8d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"04ac698a-da5e-403e-9959-136a60d37380\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"b5079bff4a7a0b43b637d17f78f339e561a7ed611ea754f45fb221828be9e8ed\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"14c36d3f-c376-466f-9822-65e979747d10\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"24bec4220dea7df050b359bc68d7a764141a262a901653298336f35bcad8be06\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 34079, \"end_char_idx\": 36720, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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- 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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 14c36d3f-c376-466f-9822-65e979747d10
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"14c36d3f-c376-466f-9822-65e979747d10\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"53c48573-1cf5-4402-a522-9104ba34cb8d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"694acc373cfb8f00cbd3e3414c9a5d011bba3119e472a44cf0a72d6bca2971a9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"f07618e2-39b0-4535-bc31-de9f3028653e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"5cb7e353546898a1873ca8d7202e402f50833c9dc4bde2184e3aed9f4adc7ec8\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 34808, \"end_char_idx\": 40012, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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-3.5-turbo\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-3.5-turbo\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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: f07618e2-39b0-4535-bc31-de9f3028653e
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"f07618e2-39b0-4535-bc31-de9f3028653e\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"14c36d3f-c376-466f-9822-65e979747d10\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"c81d3148b669ac70121acbfbe50ab31463f1455dcbb8e04c6ac8f418c53e410a\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"173c676a-aa7c-4af1-9896-d088ef23cdaa\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"fa2758e04d5dbbf9b995263a270260bb5890be6d5e19ab8de300798e9a919c83\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 40025, \"end_char_idx\": 41624, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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-3.5 turbo for longer context. 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### Sample GPT Instructions"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 173c676a-aa7c-4af1-9896-d088ef23cdaa
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"173c676a-aa7c-4af1-9896-d088ef23cdaa\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"f07618e2-39b0-4535-bc31-de9f3028653e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"66bb30566f81846659d5973df1b9557f41dde3ab603bda2859412a8b881807f3\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"41ff3c50-6ec9-493f-92c9-67763c8ba6a3\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"dfc699f9a3059359172b101f665f4cef13ab09f8bc1c1156bc67918c7630d3ea\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 40025, \"end_char_idx\": 45157, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "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-3.5 turbo for longer context. 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### Sample GPT Instructions\n\n\n```\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### Sample OpenAPI Spec\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 [here](#part-3-set-up-test-function)\n\n```yaml\nopenapi: 3.0.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```"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 41ff3c50-6ec9-493f-92c9-67763c8ba6a3
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb", "title": "Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT", "tokens": 10420, "retrieve_doc": false, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"41ff3c50-6ec9-493f-92c9-67763c8ba6a3\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"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\": \"c1ced959-8350-4855-8267-c4815b5f6ced\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"d431d2d02d5e396a3583077d51586bcf0ed0124b6aab36016c9a3724b8cce8a0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"173c676a-aa7c-4af1-9896-d088ef23cdaa\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/Using_Azure_Functions_and_Microsoft_Graph_to_Query_SharePoint.ipynb\", \"title\": \"Using Azure Functions with OAuth and Microsoft Graph API to Search O365 / SharePoint from ChatGPT\", \"tokens\": 10420, \"retrieve_doc\": false, \"source\": \"openai_cookbooks\"}, \"hash\": \"c46b8971850392be01b0537e770ddcbacc372cfcc0b1349216e8a4fe2ff2bc4f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 45160, \"end_char_idx\": 47618, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "ref_doc_id": "c1ced959-8350-4855-8267-c4815b5f6ced", "chroma:document": "## FAQ\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  - _Solution 1:_\u00a0\n\n    1. 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  - _Solution 2:_\u00a0\n\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: bbc282fd-7f13-4f5d-a9b7-ff0843146cfe
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"bbc282fd-7f13-4f5d-a9b7-ff0843146cfe\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b27e2178-400f-4342-8417-1467649c1109\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"0af3ef85d43c953425c5f88c0d904093ac9e66e7d87b09e19958a36d9f38552f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3604, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "# GPT Action Library: Outlook\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 Outlook, Microsoft's web service for emailing and calendar events. This action assumes a user\u2019s context and allows them to send and retrieve emails and calendar events from Outlook.\n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to Outlook\n\n**Example Use Cases**: \n- A user can look up all of their meetings for the day and have ChatGPT summarize the day\n- A user can email a ChatGPT output to someone directly\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://portal.azure.com/\n- Application API Documentation: https://learn.microsoft.com/en-us/graph/api/overview?view=graph-rest-1.0\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 to [Set up an App Registration in Azure](https://portal.azure.com/?feature.tokencaching=true&feature.internalgraphapiversion=true#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)\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 specialized GPT designed to manage emails and calendar events through API connections to Microsoft Outlook. This GPT can create, read, send, and alter emails and calendar events based on user instructions. It ensures efficient handling of communication and scheduling needs by leveraging Microsoft Graph API for seamless integration with Outlook services.\n\n**Instructions**:\n- When asked to perform a task, use the available actions via the microsoft.graph.com API.\n- You should behave professionally and provide clear, concise responses.\n- Offer assistance with tasks such as drafting emails, scheduling meetings, organising calendar events, and retrieving email or event details.\n- Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.\n- Always conclude an email by signing off with logged in user's name which can be retrieved via the User.Read endpoint\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: Microsoft Graph API Integration\n  version: 1.0.0\nservers:\n  - url: https://graph.microsoft.com/v1.0\ncomponents:\n  securitySchemes:\n    OAuth2:\n      type: oauth2\n      flows:\n        clientCredentials:\n          tokenUrl: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token\n          scopes:\n            https://graph.microsoft.com/User."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: b27e2178-400f-4342-8417-1467649c1109
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"b27e2178-400f-4342-8417-1467649c1109\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bbc282fd-7f13-4f5d-a9b7-ff0843146cfe\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"908f00127a44d1ce8c2c257b1511ca29bee5d47da6ad028898a68d6f8ae44b84\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"7e82fe1e-3c61-4f95-bc89-6369107b93d9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"a88754e261410dfdeebf1e0d3c5bab16ee62cf4ebd2809a431b927b6145fdb5d\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2024, \"end_char_idx\": 4534, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "```python\n**Context**: you are specialized GPT designed to manage emails and calendar events through API connections to Microsoft Outlook. This GPT can create, read, send, and alter emails and calendar events based on user instructions. It ensures efficient handling of communication and scheduling needs by leveraging Microsoft Graph API for seamless integration with Outlook services.\n\n**Instructions**:\n- When asked to perform a task, use the available actions via the microsoft.graph.com API.\n- You should behave professionally and provide clear, concise responses.\n- Offer assistance with tasks such as drafting emails, scheduling meetings, organising calendar events, and retrieving email or event details.\n- Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.\n- Always conclude an email by signing off with logged in user's name which can be retrieved via the User.Read endpoint\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: Microsoft Graph API Integration\n  version: 1.0.0\nservers:\n  - url: https://graph.microsoft.com/v1.0\ncomponents:\n  securitySchemes:\n    OAuth2:\n      type: oauth2\n      flows:\n        clientCredentials:\n          tokenUrl: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token\n          scopes:\n            https://graph.microsoft.com/User.Read: Access current user profile\n            https://graph.microsoft.com/Mail.Read: Read user mail\n            https://graph.microsoft.com/Mail.Send: Send mail\n            https://graph.microsoft.com/Calendars.ReadWrite: Read and write user calendars\n  schemas:\n    UserProfile:\n      type: object\n      properties:\n        id:\n          type: string\n        displayName:\n          type: string\n        mail:\n          type: string\n    UserMessage:\n      type: object\n      properties:\n        id:\n          type: string\n        subject:\n          type: string\n        bodyPreview:\n          type: string\n    CalendarEvent:\n      type: object\n      properties:\n        id:\n          type: string\n        subject:\n          type: string\n        start:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n        end:\n          type: object"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 7e82fe1e-3c61-4f95-bc89-6369107b93d9
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"7e82fe1e-3c61-4f95-bc89-6369107b93d9\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b27e2178-400f-4342-8417-1467649c1109\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"1325fc72f7219959a7a02e53caae7d2fb15d2db3df734008491120615fb07df0\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"fde4e3c5-7cea-4e03-94c1-a84b6b00a626\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"11076a725ee66c26f8fb1cd5e98c84079fb48252ad9256a14bae6cfa5100f870\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3730, \"end_char_idx\": 5166, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "microsoft.com/Mail.Send: Send mail\n            https://graph.microsoft.com/Calendars.ReadWrite: Read and write user calendars\n  schemas:\n    UserProfile:\n      type: object\n      properties:\n        id:\n          type: string\n        displayName:\n          type: string\n        mail:\n          type: string\n    UserMessage:\n      type: object\n      properties:\n        id:\n          type: string\n        subject:\n          type: string\n        bodyPreview:\n          type: string\n    CalendarEvent:\n      type: object\n      properties:\n        id:\n          type: string\n        subject:\n          type: string\n        start:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n        end:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n    NewEvent:\n      type: object\n      properties:\n        subject:\n          type: string\n        start:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n        end:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n        attendees:\n          type: array\n          items:\n            type: object\n            properties:"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: fde4e3c5-7cea-4e03-94c1-a84b6b00a626
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"fde4e3c5-7cea-4e03-94c1-a84b6b00a626\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7e82fe1e-3c61-4f95-bc89-6369107b93d9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"4ffcd90a806a0e496bc34af295b9e31ff7fcd0ee4d499855f7b074f9799d63b9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"3487bf4d-a64b-4a2f-bf37-496d621f1d3d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ec5eb6d57c2e44b50b4d6a3d852f5e134fa50613aa06fc593afd63a222f4a273\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4492, \"end_char_idx\": 5775, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "string\n        end:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n    NewEvent:\n      type: object\n      properties:\n        subject:\n          type: string\n        start:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n        end:\n          type: object\n          properties:\n            dateTime:\n              type: string\n            timeZone:\n              type: string\n        attendees:\n          type: array\n          items:\n            type: object\n            properties:\n              emailAddress:\n                type: object\n                properties:\n                  address:\n                    type: string\n                  name:\n                    type: string\n    SendMailRequest:\n      type: object\n      properties:\n        message:\n          type: object\n          properties:\n            subject:\n              type: string\n            body:\n              type: object\n              properties:\n                contentType:\n                  type: string\n                content:\n                  type: string\n            toRecipients:\n              type: array"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 3487bf4d-a64b-4a2f-bf37-496d621f1d3d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"3487bf4d-a64b-4a2f-bf37-496d621f1d3d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"fde4e3c5-7cea-4e03-94c1-a84b6b00a626\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"63abfe447bd0709c44b1a8fab525c4b21f66ef3a6e3bf2f29970fa28596793b8\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"bd961126-b0d1-4181-810f-5164d51047e6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"3bb256693656c9d0de236b7de5dfe1d3a85fd5a2b859e026c5e7b99414cb576b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5130, \"end_char_idx\": 6534, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "type: object\n            properties:\n              emailAddress:\n                type: object\n                properties:\n                  address:\n                    type: string\n                  name:\n                    type: string\n    SendMailRequest:\n      type: object\n      properties:\n        message:\n          type: object\n          properties:\n            subject:\n              type: string\n            body:\n              type: object\n              properties:\n                contentType:\n                  type: string\n                content:\n                  type: string\n            toRecipients:\n              type: array\n              items:\n                type: object\n                properties:\n                  emailAddress:\n                    type: object\n                    properties:\n                      address:\n                        type: string\nsecurity:\n  - OAuth2: []\npaths:\n  /me:\n    get:\n      operationId: getUserProfile\n      summary: Get the authenticated user's profile\n      security:\n        - OAuth2: []\n      responses:\n        '200':\n          description: A user profile\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/UserProfile'\n  /me/messages:\n    get:\n      operationId: getUserMessages\n      summary: Get the authenticated user's messages\n      security:\n        - OAuth2:"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: bd961126-b0d1-4181-810f-5164d51047e6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"bd961126-b0d1-4181-810f-5164d51047e6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"3487bf4d-a64b-4a2f-bf37-496d621f1d3d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"629ec1c7d99a7b5c9f4c89cb7b2af8dba1d9f51b9db6a8e92af6f3983ad67780\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"9ce5954a-0635-40f9-95b3-0571c49ce9cc\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"10a9861089ebdfc4086d69071ae552f9975e509b588c12c6de4816f6a271e1e1\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5736, \"end_char_idx\": 7245, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "toRecipients:\n              type: array\n              items:\n                type: object\n                properties:\n                  emailAddress:\n                    type: object\n                    properties:\n                      address:\n                        type: string\nsecurity:\n  - OAuth2: []\npaths:\n  /me:\n    get:\n      operationId: getUserProfile\n      summary: Get the authenticated user's profile\n      security:\n        - OAuth2: []\n      responses:\n        '200':\n          description: A user profile\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/UserProfile'\n  /me/messages:\n    get:\n      operationId: getUserMessages\n      summary: Get the authenticated user's messages\n      security:\n        - OAuth2: []\n      parameters:\n        - name: $top\n          in: query\n          required: false\n          schema:\n            type: integer\n            default: 10\n            description: Number of messages to return\n        - name: $filter\n          in: query\n          required: false\n          schema:\n            type: string\n            description: OData filter query to narrow results\n        - name: $orderby\n          in: query\n          required: false\n          schema:\n            type: string\n            description: OData order by query to sort results\n      responses:\n        '200':\n          description: A list of user messages\n          content:\n            application/json:\n              schema:"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 9ce5954a-0635-40f9-95b3-0571c49ce9cc
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"9ce5954a-0635-40f9-95b3-0571c49ce9cc\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bd961126-b0d1-4181-810f-5164d51047e6\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"f2ece9b2e2ae8207fb122c311c7e79d65ba6e1359e644fca15533636ed1ce129\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e6cf5701-1322-4f3d-918e-770f001ea048\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"fea013b2de01f8239303e85fdb2ebdeeb803cde8818ac0da3908c6954e398624\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6454, \"end_char_idx\": 8076, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "summary: Get the authenticated user's messages\n      security:\n        - OAuth2: []\n      parameters:\n        - name: $top\n          in: query\n          required: false\n          schema:\n            type: integer\n            default: 10\n            description: Number of messages to return\n        - name: $filter\n          in: query\n          required: false\n          schema:\n            type: string\n            description: OData filter query to narrow results\n        - name: $orderby\n          in: query\n          required: false\n          schema:\n            type: string\n            description: OData order by query to sort results\n      responses:\n        '200':\n          description: A list of user messages\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/UserMessage'\n  /me/sendMail:\n    post:\n      operationId: sendUserMail\n      summary: Send an email as the authenticated user\n      security:\n        - OAuth2: []\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/SendMailRequest'\n      responses:\n        '202':\n          description: Accepted\n  /me/events:\n    get:\n      operationId: getUserCalendarEvents\n      summary: Get the authenticated user's calendar events\n      security:\n        - OAuth2: []\n      responses:\n        '200':\n          description: A list of calendar events\n          content:\n            application/json:\n              schema:\n                type: array"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: e6cf5701-1322-4f3d-918e-770f001ea048
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"e6cf5701-1322-4f3d-918e-770f001ea048\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"9ce5954a-0635-40f9-95b3-0571c49ce9cc\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"1eb5d04e62b8287afe66f76a19fa69be80e5dfeeccc95587169e6fa3a89074c5\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"53085604-27a8-4e8c-ab33-d9fe3b0fc1a4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"fc68a576eff8fe3c447087dbb81d80f4c89ce63bf637114280983ce6aeca83eb\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7238, \"end_char_idx\": 8930, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/UserMessage'\n  /me/sendMail:\n    post:\n      operationId: sendUserMail\n      summary: Send an email as the authenticated user\n      security:\n        - OAuth2: []\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/SendMailRequest'\n      responses:\n        '202':\n          description: Accepted\n  /me/events:\n    get:\n      operationId: getUserCalendarEvents\n      summary: Get the authenticated user's calendar events\n      security:\n        - OAuth2: []\n      responses:\n        '200':\n          description: A list of calendar events\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/CalendarEvent'\n    post:\n      operationId: createUserCalendarEvent\n      summary: Create a new calendar event for the authenticated user\n      security:\n        - OAuth2: []\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/NewEvent'\n      responses:\n        '201':\n          description: Created\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/CalendarEvent'\n\n\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with Outlook. 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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 53085604-27a8-4e8c-ab33-d9fe3b0fc1a4
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"53085604-27a8-4e8c-ab33-d9fe3b0fc1a4\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e6cf5701-1322-4f3d-918e-770f001ea048\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7cf44e6ceb5be8d921ccb098a704e98ecfca7b26aadefb5a8d5560e8d08c3cf3\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"60ea83b3-edaf-4edc-9dcd-28cbecc4701d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b00cc2d556a1706e52baf0e1b65b0b906fbb0eda7faab1f339728938fb52b7d6\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7939, \"end_char_idx\": 10608, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "description: A list of calendar events\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/CalendarEvent'\n    post:\n      operationId: createUserCalendarEvent\n      summary: Create a new calendar event for the authenticated user\n      security:\n        - OAuth2: []\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/NewEvent'\n      responses:\n        '201':\n          description: Created\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/CalendarEvent'\n\n\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with Outlook. 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### Azure Steps\n\n1. <b>App Registration</b>: The first step is to register a new App registration in the [Azure Portal](portal.azure.com) which will be used to integrate OAuth between our application and Azure Active Directory/Entra ID. Simply provide the application with a relevant name, leaving the Redirect URI blank for now as we will return to this, and save.\n\n![gptactions_outlook_registerapplication.png](../../../images/gptactions_outlook_registerapplication.png)\n\n2. <b>Certificate & Secrets</b>: We next need to generate a client secret to provide secure communication between the GPT and Azure. Within the App registration, navigate to <b>Certificate & secrets</b> in the sidebar\n\n![gptactions_outlook_secrets.png](../../../images/gptactions_outlook_secrets.png)\n\nClick New client secret and create a new client secret with desired name and expiry date. Clicking save will provide us a Secret to use in our GPT creation. Make sure to save the **Value** field as it\u2019ll only be visible at creation, and we will need it later!\n\n![gptactions_outlook_secretvalue.png](../../../images/gptactions_outlook_secretvalue.png)\n\n3. <b>API Permissions</b>: The next step is to provide the integration with the scope it needs to perform our specific required actions. \nWithin the App registration, navigate to <b>Manage > API permissions</b> in the sidebar. \n\n![gptactions_outlook_permissions.png](../../../images/gptactions_outlook_permissions.png)\n\nClick <b>Add a permission</b> and <b>Microsoft graph > Delegated Permissions</b> as options in the opened side menu. Use the search bar to add the following permissions:\n- Calendars.ReadWrite\n- Mail.Read\n- Mail.Send\n- User.Read"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 60ea83b3-edaf-4edc-9dcd-28cbecc4701d
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"60ea83b3-edaf-4edc-9dcd-28cbecc4701d\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"53085604-27a8-4e8c-ab33-d9fe3b0fc1a4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"4d0931cecfb6fd0e6250841148330b187cb276037ded38e28f64a53e5b2eab3d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"33c343c2-4cad-4d72-91b5-1aa390aa3c35\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"6f0574bd37adb7d85332c3f6b956dc41096de5c7cbda9aed30296218fa0c41eb\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8933, \"end_char_idx\": 11981, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "### Azure Steps\n\n1. <b>App Registration</b>: The first step is to register a new App registration in the [Azure Portal](portal.azure.com) which will be used to integrate OAuth between our application and Azure Active Directory/Entra ID. Simply provide the application with a relevant name, leaving the Redirect URI blank for now as we will return to this, and save.\n\n![gptactions_outlook_registerapplication.png](../../../images/gptactions_outlook_registerapplication.png)\n\n2. <b>Certificate & Secrets</b>: We next need to generate a client secret to provide secure communication between the GPT and Azure. Within the App registration, navigate to <b>Certificate & secrets</b> in the sidebar\n\n![gptactions_outlook_secrets.png](../../../images/gptactions_outlook_secrets.png)\n\nClick New client secret and create a new client secret with desired name and expiry date. Clicking save will provide us a Secret to use in our GPT creation. Make sure to save the **Value** field as it\u2019ll only be visible at creation, and we will need it later!\n\n![gptactions_outlook_secretvalue.png](../../../images/gptactions_outlook_secretvalue.png)\n\n3. <b>API Permissions</b>: The next step is to provide the integration with the scope it needs to perform our specific required actions. \nWithin the App registration, navigate to <b>Manage > API permissions</b> in the sidebar. \n\n![gptactions_outlook_permissions.png](../../../images/gptactions_outlook_permissions.png)\n\nClick <b>Add a permission</b> and <b>Microsoft graph > Delegated Permissions</b> as options in the opened side menu. Use the search bar to add the following permissions:\n- Calendars.ReadWrite\n- Mail.Read\n- Mail.Send\n- User.Read\n\n\n![gptactions_outlook_permissionadd.png](../../../images/gptactions_outlook_permissionadd.png)\n\n### In ChatGPT\n\nIn ChatGPT, click on \"Authentication\" and choose **\"OAuth\"**. Enter in the information below. \n\n- **Client ID**: The value listed on the Azure Registered App\u2019s Overview page under **Application (client) ID**\n- **Client Secret**: the secret **Value** saved from step 2 of **Azure Steps**\n\nFor the following two inputs, replace <Tenant_ID> with the value listed on the Registered App\u2019s Overview page under **Directory (tenant) ID**\n\n- **Authorization URL**: https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/authorize\n- **Token URL**: https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/token\n- **Scope**: https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/Mail.Read https://graph.microsoft.com/Calendars.ReadWrite \n- **Token Exchange Method**: Default (POST Request)\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\n![gptactions_outlook_callback.png](../../../images/gptactions_outlook_callback.png)\n\n- In the Azure app, navigate to the **Manage > Authentication** tab, click **Add a platform**, select **Web** and add your callback URL under **Redirect URI**"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 33c343c2-4cad-4d72-91b5-1aa390aa3c35
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb", "title": "GPT Action Library: Outlook", "tokens": 2589, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"33c343c2-4cad-4d72-91b5-1aa390aa3c35\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"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\": \"2fa1e5a0-99a3-4337-ad11-6d03d24fcd84\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"48e0564ce23c788b9fbae87b41633a7d05f223c1a1ffb3a8c302dcf9045613c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"60ea83b3-edaf-4edc-9dcd-28cbecc4701d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb\", \"title\": \"GPT Action Library: Outlook\", \"tokens\": 2589, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"695ec312dddf3a8bf48d1fe26779979e6dacf6214c90a28157062f1253f8852a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10611, \"end_char_idx\": 12549, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "ref_doc_id": "2fa1e5a0-99a3-4337-ad11-6d03d24fcd84", "chroma:document": "![gptactions_outlook_permissionadd.png](../../../images/gptactions_outlook_permissionadd.png)\n\n### In ChatGPT\n\nIn ChatGPT, click on \"Authentication\" and choose **\"OAuth\"**. Enter in the information below. \n\n- **Client ID**: The value listed on the Azure Registered App\u2019s Overview page under **Application (client) ID**\n- **Client Secret**: the secret **Value** saved from step 2 of **Azure Steps**\n\nFor the following two inputs, replace <Tenant_ID> with the value listed on the Registered App\u2019s Overview page under **Directory (tenant) ID**\n\n- **Authorization URL**: https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/authorize\n- **Token URL**: https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/token\n- **Scope**: https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/Mail.Read https://graph.microsoft.com/Calendars.ReadWrite \n- **Token Exchange Method**: Default (POST Request)\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\n![gptactions_outlook_callback.png](../../../images/gptactions_outlook_callback.png)\n\n- In the Azure app, navigate to the **Manage > Authentication** tab, click **Add a platform**, select **Web** and add your callback URL under **Redirect URI**\n\n\n![gptactions_outlook_redirectconfig.png](../../../images/gptactions_outlook_redirectconfig.png)\n![gptactions_outlook_redirectinput.png](../../../images/gptactions_outlook_redirectinput.png)\n\n### FAQ & Troubleshooting\n\n- **Callback URL Error**: If you get a callback URL error in ChatGPT, double check the Callback URL value as it can occasionally change depending on any alterations made to the authentication\n\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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 7cd11cbb-4652-45e5-895b-c193e7e79077
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb", "title": "GPT Action Library: Getting Started (Weather.gov)", "tokens": 1288, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"7cd11cbb-4652-45e5-895b-c193e7e79077\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb\", \"title\": \"GPT Action Library: Getting Started (Weather.gov)\", \"tokens\": 1288, \"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\": \"7cf45fdd-caee-4389-9738-9043cb51c767\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb\", \"title\": \"GPT Action Library: Getting Started (Weather.gov)\", \"tokens\": 1288, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"f459f15977189f279196070cda878cc0a04a947125ae342a483161544d9649e3\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"c520ae41-a071-4450-b550-b9345fb7ec7b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ffe96ad6abf53e8a41fccf2319a8cb2f8d7ba72917a8db7976cf78034d1a7f66\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3049, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "7cf45fdd-caee-4389-9738-9043cb51c767", "doc_id": "7cf45fdd-caee-4389-9738-9043cb51c767", "ref_doc_id": "7cf45fdd-caee-4389-9738-9043cb51c767", "chroma:document": "# GPT Action Library: Getting Started (Weather.gov)\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 a **Weather.gov** weather forecast. This Action takes a user\u2019s question about a location, converts the lat-long into a weather forecast office (WFO), x, and y coordinates, then converts those 3 values into a weather forecast.\n\nNote: When setting up the GPT Action, for authentication, leave it with \"None\". This is a public API and does not require any Authentication\n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to forecast the weather\n\n**Example Use Cases**: \n- Users can plan out their day based on weather patterns\n- Users can quickly visualize (including graphs) what the weather is forecasted to look like\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.weather.gov/  \n- Application API Documentation: https://www.weather.gov/documentation/services-web-api  \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**: A user needs information related to a weather forecast of a specific location.\n\n**Instructions**:\n1. The user will provide a lat-long point or a general location or landmark (e.g. New York City, the White House). If the user does not provide one, ask for the relevant location\n2. If the user provides a general location or landmark, convert that into a lat-long coordinate. If required, browse the web to look up the lat-long point. \n3. Run the \"getPointData\" API action and retrieve back the gridId, gridX, and gridY parameters.\n4. Apply those variables as the office, gridX, and gridY variables in the \"getGridpointForecast\" API action to retrieve back a forecast\n5. Use that forecast to answer the user's question \n\n**Additional Notes**: \n- Assume the user uses US weather units (e.g. Farenheit) unless otherwise specified\n- If the user says \"Let's get started\" or \"What do I do?\", explain the purpose of this Custom GPT\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: c520ae41-a071-4450-b550-b9345fb7ec7b
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb", "title": "GPT Action Library: Getting Started (Weather.gov)", "tokens": 1288, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"c520ae41-a071-4450-b550-b9345fb7ec7b\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb\", \"title\": \"GPT Action Library: Getting Started (Weather.gov)\", \"tokens\": 1288, \"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\": \"7cf45fdd-caee-4389-9738-9043cb51c767\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb\", \"title\": \"GPT Action Library: Getting Started (Weather.gov)\", \"tokens\": 1288, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"f459f15977189f279196070cda878cc0a04a947125ae342a483161544d9649e3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7cd11cbb-4652-45e5-895b-c193e7e79077\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started.ipynb\", \"title\": \"GPT Action Library: Getting Started (Weather.gov)\", \"tokens\": 1288, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"abd82f2bca2a2f5e54b92ad55d24d28aa99ae3497abe90bd38fa1d859872af32\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1848, \"end_char_idx\": 6839, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "7cf45fdd-caee-4389-9738-9043cb51c767", "doc_id": "7cf45fdd-caee-4389-9738-9043cb51c767", "ref_doc_id": "7cf45fdd-caee-4389-9738-9043cb51c767", "chroma:document": "```python\n**Context**: A user needs information related to a weather forecast of a specific location.\n\n**Instructions**:\n1. The user will provide a lat-long point or a general location or landmark (e.g. New York City, the White House). If the user does not provide one, ask for the relevant location\n2. If the user provides a general location or landmark, convert that into a lat-long coordinate. If required, browse the web to look up the lat-long point. \n3. Run the \"getPointData\" API action and retrieve back the gridId, gridX, and gridY parameters.\n4. Apply those variables as the office, gridX, and gridY variables in the \"getGridpointForecast\" API action to retrieve back a forecast\n5. Use that forecast to answer the user's question \n\n**Additional Notes**: \n- Assume the user uses US weather units (e.g. Farenheit) unless otherwise specified\n- If the user says \"Let's get started\" or \"What do I do?\", explain the purpose of this Custom GPT\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: NWS Weather API\n  description: Access to weather data including forecasts, alerts, and observations.\n  version: 1.0.0\nservers:\n  - url: https://api.weather.gov\n    description: Main API Server\npaths:\n  /points/{latitude},{longitude}:\n    get:\n      operationId: getPointData\n      summary: Get forecast grid endpoints for a specific location\n      parameters:\n        - name: latitude\n          in: path\n          required: true\n          schema:\n            type: number\n            format: float\n          description: Latitude of the point\n        - name: longitude\n          in: path\n          required: true\n          schema:\n            type: number\n            format: float\n          description: Longitude of the point\n      responses:\n        '200':\n          description: Successfully retrieved grid endpoints\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  properties:\n                    type: object\n                    properties:\n                      forecast:\n                        type: string\n                        format: uri\n                      forecastHourly:\n                        type: string\n                        format: uri\n                      forecastGridData:\n                        type: string\n                        format: uri\n\n  /gridpoints/{office}/{gridX},{gridY}/forecast:\n    get:\n      operationId: getGridpointForecast\n      summary: Get forecast for a given grid point\n      parameters:\n        - name: office\n          in: path\n          required: true\n          schema:\n            type: string\n          description: Weather Forecast Office ID\n        - name: gridX\n          in: path\n          required: true\n          schema:\n            type: integer\n          description: X coordinate of the grid\n        - name: gridY\n          in: path\n          required: true\n          schema:\n            type: integer\n          description: Y coordinate of the grid\n      responses:\n        '200':\n          description: Successfully retrieved gridpoint forecast\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  properties:\n                    type: object\n                    properties:\n                      periods:\n                        type: array\n                        items:\n                          type: object\n                          properties:\n                            number:\n                              type: integer\n                            name:\n                              type: string\n                            startTime:\n                              type: string\n                              format: date-time\n                            endTime:\n                              type: string\n                              format: date-time\n                            temperature:\n                              type: integer\n                            temperatureUnit:\n                              type: string\n                            windSpeed:\n                              type: string\n                            windDirection:\n                              type: string\n                            icon:\n                              type: string\n                              format: uri\n                            shortForecast:\n                              type: string\n                            detailedForecast:\n                              type: string\n```\n\n### FAQ & Troubleshooting\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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 61c05134-ff37-41e8-8697-e08fa873ff1a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"61c05134-ff37-41e8-8697-e08fa873ff1a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"420273e2-a04b-4473-ab66-f8e8164c15f5\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f84f3c05cd5b0eb2ecfc74a1c716eaff44d9149ef0bd403513917be8c0838d5b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3510, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "# GPT Action Library: Jira\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 Jira, Atlassian's tool for project and ticket management. This action assumes a user\u2019s context and allows them to read and write to issues in a given project.\n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to Jira Cloud\n\n**Example Use Cases**: \n- A user can load up recent issues for a particular project and use ChatGPT to provide solutions\n- A user can create and alter issues and sub-tasks and assign to specific users by instructing 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://<YOUR_SUBDOMAIN>.atlassian.net/jira\n- Application API Documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/\n- Application OAuth 2.0 Documentation: https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/\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 to create an application in the [Atlassian Cloud Developer Console](https://developer.atlassian.com/console/myapps/)\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 specialized GPT designed to create and edit issues through API connections to Jira Cloud. This GPT can create, read, and edit project issues based on user instructions.\n\n**Instructions**:\n- When asked to perform a task, use the available actions via the api.atlassian.com API.\n- When asked to create an issue, use the user's input to synthesize a summary and description and file the issue in JIRA.\n- When asked to create a subtask, assume the project key and parent issue key of the currently discussed issue. Clarify with if this context is not available.\n- When asked to assign an issue or task to the user, first use jql to query the current user's profile and use this account as the assignee. \n- Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.\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*NOTE: Replace the placeholder <CLOUD_ID> in url with your cloud environment's unique ID. You can find this value by visiting https://<YOUR_SUBDOMAIN>.atlassian.net/_edge/tenant_info*\n\n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: Jira API\n  description: API for interacting with Jira issues and sub-tasks.\n  version: 1."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 420273e2-a04b-4473-ab66-f8e8164c15f5
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"420273e2-a04b-4473-ab66-f8e8164c15f5\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"61c05134-ff37-41e8-8697-e08fa873ff1a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"d4da34def4deeeb59c92c214d417092299aea1fd916d13bfdaa3ec0c4f98e02e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e04d8b63-6122-48fb-a1cf-4838e4d49a94\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"256c0fe0720a7e19929186ad76f084edeceea8b002d3dcc20350735ef1c26d02\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2106, \"end_char_idx\": 4516, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "```python\n**Context**: you are specialized GPT designed to create and edit issues through API connections to Jira Cloud. This GPT can create, read, and edit project issues based on user instructions.\n\n**Instructions**:\n- When asked to perform a task, use the available actions via the api.atlassian.com API.\n- When asked to create an issue, use the user's input to synthesize a summary and description and file the issue in JIRA.\n- When asked to create a subtask, assume the project key and parent issue key of the currently discussed issue. Clarify with if this context is not available.\n- When asked to assign an issue or task to the user, first use jql to query the current user's profile and use this account as the assignee. \n- Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.\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*NOTE: Replace the placeholder <CLOUD_ID> in url with your cloud environment's unique ID. You can find this value by visiting https://<YOUR_SUBDOMAIN>.atlassian.net/_edge/tenant_info*\n\n\n\n```python\nopenapi: 3.1.0\ninfo:\n  title: Jira API\n  description: API for interacting with Jira issues and sub-tasks.\n  version: 1.0.0\nservers:\n  - url: https://api.atlassian.com/ex/jira/<CLOUD_ID>/rest/api/3\n    description: Jira Cloud API\ncomponents:\n  securitySchemes:\n    OAuth2:\n      type: oauth2\n      flows:\n        authorizationCode:\n          authorizationUrl: https://auth.atlassian.com/authorize\n          tokenUrl: https://auth.atlassian.com/oauth/token\n          scopes:\n            read:jira-user: Read Jira user information\n            read:jira-work: Read Jira work data\n            write:jira-work: Write Jira work data\n  schemas:\n    Issue:\n      type: object\n      properties:\n        id:\n          type: string\n        key:\n          type: string\n        fields:\n          type: object\n          properties:\n            summary:\n              type: string\n            description:\n              type: string\n            issuetype:\n              type: object\n              properties:\n                name:\n                  type: string\npaths:\n  /search:\n    get:\n      operationId: getIssues\n      summary: Retrieve"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: e04d8b63-6122-48fb-a1cf-4838e4d49a94
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"e04d8b63-6122-48fb-a1cf-4838e4d49a94\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"420273e2-a04b-4473-ab66-f8e8164c15f5\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"4a7f49bc9376206279d704759ae6a94fad2aa6495c5fa1670f8cd25e8e275564\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6248de8d-d83f-4f10-b51f-7b2b6bd2e649\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e4bac58a24076e64abf75044742ab4426b1ea66aadd4621edfe5240dfe6d530f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3763, \"end_char_idx\": 5176, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "atlassian.com/authorize\n          tokenUrl: https://auth.atlassian.com/oauth/token\n          scopes:\n            read:jira-user: Read Jira user information\n            read:jira-work: Read Jira work data\n            write:jira-work: Write Jira work data\n  schemas:\n    Issue:\n      type: object\n      properties:\n        id:\n          type: string\n        key:\n          type: string\n        fields:\n          type: object\n          properties:\n            summary:\n              type: string\n            description:\n              type: string\n            issuetype:\n              type: object\n              properties:\n                name:\n                  type: string\npaths:\n  /search:\n    get:\n      operationId: getIssues\n      summary: Retrieve a list of issues\n      parameters:\n        - name: jql\n          in: query\n          required: false\n          schema:\n            type: string\n        - name: startAt\n          in: query\n          required: false\n          schema:\n            type: integer\n        - name: maxResults\n          in: query\n          required: false\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: A list of issues\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  issues:\n                    type: array\n                    items:"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 6248de8d-d83f-4f10-b51f-7b2b6bd2e649
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"6248de8d-d83f-4f10-b51f-7b2b6bd2e649\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e04d8b63-6122-48fb-a1cf-4838e4d49a94\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7104dc9036832dcb14331e9c50e6292d137afaa478b298246ef3b2048fab6158\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"c16728f2-6d4a-40f9-95d0-9d5493597d82\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"151871c3b9401bc6ec8a47576cba59004d3d5ffaa9e0e093091c5bebea8b4d9c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4499, \"end_char_idx\": 5793, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "summary: Retrieve a list of issues\n      parameters:\n        - name: jql\n          in: query\n          required: false\n          schema:\n            type: string\n        - name: startAt\n          in: query\n          required: false\n          schema:\n            type: integer\n        - name: maxResults\n          in: query\n          required: false\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: A list of issues\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  issues:\n                    type: array\n                    items:\n                      $ref: '#/components/schemas/Issue'\n  /issue:\n    post:\n      operationId: createIssue\n      summary: Create a new issue\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                fields:\n                  type: object\n                  properties:\n                    project:\n                      type: object\n                      properties:\n                        key:\n                          type: string\n                    summary:\n                      type: string"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: c16728f2-6d4a-40f9-95d0-9d5493597d82
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"c16728f2-6d4a-40f9-95d0-9d5493597d82\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6248de8d-d83f-4f10-b51f-7b2b6bd2e649\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"0a6aea6e23466d35c78bcfefad530180a4f42077ed143851287d014bb8bad57c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"3a436278-30f9-40d4-9b2f-52730163d291\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"313ded860fb0dcf4f66f2a3aa772a2ff59d59fe6f11032202f48b712ca3ca999\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5170, \"end_char_idx\": 6471, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "items:\n                      $ref: '#/components/schemas/Issue'\n  /issue:\n    post:\n      operationId: createIssue\n      summary: Create a new issue\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                fields:\n                  type: object\n                  properties:\n                    project:\n                      type: object\n                      properties:\n                        key:\n                          type: string\n                    summary:\n                      type: string\n                    description:\n                      type: string\n                    issuetype:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n      responses:\n        '201':\n          description: Issue created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Issue'\n  /issue/{issueIdOrKey}:\n    get:\n      operationId: getIssue\n      summary: Retrieve a specific issue\n      parameters:\n        - name: issueIdOrKey\n          in: path\n          required: true\n          schema:\n            type: string"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 3a436278-30f9-40d4-9b2f-52730163d291
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"3a436278-30f9-40d4-9b2f-52730163d291\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"c16728f2-6d4a-40f9-95d0-9d5493597d82\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"f9734143f51f1359af78104dc4949b8fbc4b62ceb0ed7e738452c2356c46a400\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6c9a14b9-5a20-41dd-82ba-6230df60391a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"360b6039faa8b4a030aa991a1a8229258f24978599a6837ef4d7ca7a403f66aa\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5781, \"end_char_idx\": 7150, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "type: string\n                    description:\n                      type: string\n                    issuetype:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n      responses:\n        '201':\n          description: Issue created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Issue'\n  /issue/{issueIdOrKey}:\n    get:\n      operationId: getIssue\n      summary: Retrieve a specific issue\n      parameters:\n        - name: issueIdOrKey\n          in: path\n          required: true\n          schema:\n            type: string\n      responses:\n        '200':\n          description: Issue details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Issue'\n    put:\n      operationId: updateIssue\n      summary: Update an existing issue\n      parameters:\n        - name: issueIdOrKey\n          in: path\n          required: true\n          schema:\n            type: string\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                fields:\n                  type: object\n                  properties:\n                    summary:"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 6c9a14b9-5a20-41dd-82ba-6230df60391a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"6c9a14b9-5a20-41dd-82ba-6230df60391a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"3a436278-30f9-40d4-9b2f-52730163d291\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"8cb210e70fa4e011e51ccfd6e52674aad1ad113ad2389bef084e69df37177d51\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"0e4a2459-f384-4332-8eb7-7cf035a51e9a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"bbbcb1dfc0d624c3bff8350d0d97d8183c07cd4d0f1137027058a8ed68269962\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6414, \"end_char_idx\": 7787, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "required: true\n          schema:\n            type: string\n      responses:\n        '200':\n          description: Issue details\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Issue'\n    put:\n      operationId: updateIssue\n      summary: Update an existing issue\n      parameters:\n        - name: issueIdOrKey\n          in: path\n          required: true\n          schema:\n            type: string\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                fields:\n                  type: object\n                  properties:\n                    summary:\n                      type: string\n                    description:\n                      type: string\n                    issuetype:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n      responses:\n        '204':\n          description: Issue updated successfully\n  /issue:\n    post:\n      operationId: createSubTask\n      summary: Create a sub-task for an issue\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                fields:"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 0e4a2459-f384-4332-8eb7-7cf035a51e9a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"0e4a2459-f384-4332-8eb7-7cf035a51e9a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6c9a14b9-5a20-41dd-82ba-6230df60391a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"474e5d1d035d9f9bfec9e1970b780a75cabaec86864cbd4d4b02f17a699e9a45\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6ad88812-a4bf-44ec-99d1-45ed09c3f9b1\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ff12320ceaedadbb5ff405402bc7184654589653f8b1daf2a9daf65158a97b1c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7110, \"end_char_idx\": 8311, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "properties:\n                    summary:\n                      type: string\n                    description:\n                      type: string\n                    issuetype:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n      responses:\n        '204':\n          description: Issue updated successfully\n  /issue:\n    post:\n      operationId: createSubTask\n      summary: Create a sub-task for an issue\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                fields:\n                  type: object\n                  properties:\n                    project:\n                      type: object\n                      properties:\n                        key:\n                          type: string\n                    parent:\n                      type: object\n                      properties:\n                        key:\n                          type: string\n                    summary:\n                      type: string\n                    description:\n                      type: string"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 6ad88812-a4bf-44ec-99d1-45ed09c3f9b1
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"6ad88812-a4bf-44ec-99d1-45ed09c3f9b1\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"0e4a2459-f384-4332-8eb7-7cf035a51e9a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"9ba02561ad8753f7509af83f68eb959633e0f5abeac0dca2f185e7409c26117f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"03d913a8-ea77-41ef-a253-924139aac838\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"cd08dd486b477938ee05a45589584ffaa8255f7be0d4fd5d6ea7a44f5ae3e46f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7780, \"end_char_idx\": 9033, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "fields:\n                  type: object\n                  properties:\n                    project:\n                      type: object\n                      properties:\n                        key:\n                          type: string\n                    parent:\n                      type: object\n                      properties:\n                        key:\n                          type: string\n                    summary:\n                      type: string\n                    description:\n                      type: string\n                    issuetype:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n      responses:\n        '201':\n          description: Sub-task created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Issue'\nsecurity:\n  - OAuth2:\n      - read:jira-user\n      - read:jira-work\n      - write:jira-work\n\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with Jira. 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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 03d913a8-ea77-41ef-a253-924139aac838
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"03d913a8-ea77-41ef-a253-924139aac838\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6ad88812-a4bf-44ec-99d1-45ed09c3f9b1\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"2d5b14a3cc3dc79c2731b90d55eca64bdc0bbd222b6f32cff8af2524acc0e550\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"de89aa29-64c2-46fd-92b2-09099ec8efb6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1dd28ecbc0ce2746a665d2ea15ff876b21628481865fc9bbbd70992836597213\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8200, \"end_char_idx\": 11733, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "summary:\n                      type: string\n                    description:\n                      type: string\n                    issuetype:\n                      type: object\n                      properties:\n                        name:\n                          type: string\n      responses:\n        '201':\n          description: Sub-task created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Issue'\nsecurity:\n  - OAuth2:\n      - read:jira-user\n      - read:jira-work\n      - write:jira-work\n\n```\n\n## Authentication Instructions\n\nBelow are instructions on setting up authentication with Jira. 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### Jira Steps\n\n1. <b>Create an Application</b>: The first step is to create a new application in Jira for the integration with ChatGPT. This can be done by visiting the [Atlassian Developer Console](https://developer.atlassian.com/console/myapps/), Clicking **Create** and selecting **OAuth 2.0 Integration**. \n\n![gptactions_jira_devconsole.png](../../../images/gptactions_jira_devconsole.png)\n\nFrom here, simply enter the name of your integration and click **Create**.\n\n![gptactions_jira_newapplication.png](../../../images/gptactions_jira_newapplication.png)\n\n2. <b>Define Permissions</b>: Next we need to provide the required permissions to our application. Within the new application, open the **Permissions** menu from the sidebar, locate **Jira API** and click **Add** and then **Configure**.\n\n![gptactions_jira_permissions.png](../../../images/gptactions_jira_permissions.png)\n\nRequired permissions will vary depending on the intended functionality of the GPT. In this scenario we wish to read and write to Jira issues, so select the following scopes under **Jira platform REST API** by clicking **Edit Scopes**:\n\n- read:jira-work\n- write:jira-work\n- read:jira-user\n\nOnce selected, click **Save**\n\n![gptactions_jira_scopes.png](../../../images/gptactions_jira_scopes.png)\n\n3. <b>Application Client ID/Secret</b>: The next step is to locate the **Client ID** and **Secret** for enabling secure authentication between ChatGPT and Jira. We can find these values by clicking on **Settings** in the sidebar and scrolling down to **Authentication Details**. \n\n      Keep this page open as we will require these values in the next stage of configuration!\n\n![gptactions_jira_clientsecret.png](../../../images/gptactions_jira_clientsecret.png)\n\n### In ChatGPT\n\nIn ChatGPT, click on \"Authentication\" and choose **\"OAuth\"**. Enter in the information below. \n\n- **Client ID**: The **Client ID** from **Step 3** of Jira Configuration\n- **Client Secret**: The **Secret** from **Step 3** of Jira Configuration\n- **Authorization URL**: https://auth.atlassian.com/authorize\n- **Token URL**: https://auth.atlassian.com/oauth/token\n- **Scope**: read:jira-work write:jira-work read:jira-user \n- **Token Exchange Method**: Default (POST Request)\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\n![gptactions_jira_redirect.png](../../../images/gptactions_jira_redirect.png)\n\n- In your application in the Atlassian Developer Console, navigate to the **Authorization** sidebar tab, next to **OAuth 2.0 (3L0)** click **Configure**, and add your callback URL under **Callback URL**"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: de89aa29-64c2-46fd-92b2-09099ec8efb6
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb", "title": "GPT Action Library: Jira", "tokens": 2501, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"de89aa29-64c2-46fd-92b2-09099ec8efb6\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"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\": \"50906200-92ae-4e6e-afed-75f6ace940dd\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"775d7ba07a46c31be0612f9aa40d47b002c9ca310ce2d6df7eb6b159360ae2b7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"03d913a8-ea77-41ef-a253-924139aac838\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_jira.ipynb\", \"title\": \"GPT Action Library: Jira\", \"tokens\": 2501, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"42eeb48795d15942d1d511ca1679cbe74c9759988a87bbb2d5eec12d8297153b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 11736, \"end_char_idx\": 12189, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "ref_doc_id": "50906200-92ae-4e6e-afed-75f6ace940dd", "chroma:document": "![gptactions_jira_callback.png](../../../images/gptactions_jira_callback.png)\n\n### FAQ & Troubleshooting\n\n- **Callback URL Error**: If you get a callback URL error in ChatGPT, double check the Callback URL value as it can occasionally change depending on any alterations made to the authentication\n\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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 125c69f2-d094-404b-a9e3-ba2905c5c85a
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb", "title": "## Introduction", "tokens": 2113, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"125c69f2-d094-404b-a9e3-ba2905c5c85a\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"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\": \"87b13565-bac0-47a0-a5b2-abd8e35ea696\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7615bccb53b0b8b53d08bf4d35b23e642825f51df7c3465919e831b4539b4cca\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"85ec3c81-66bd-4a36-9a8d-b0e2528d3452\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"6d727e0097d3179e46edfe001d231c68c7e28db448924f6912ee0cf5ddf62a3a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3592, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "ref_doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "chroma:document": "## 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/introduction)\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 Salesforce, specifically, Salesforce Service Cloud. This schema detailed in this Action allows the user to pull case data and update cases directly from ChatGPT. The setup process to create Actions for other Salesforce Cloud solutions uses the same Connected App and authentication setup, but will require a different API schema.\n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to Salesforce\n\n**Example Use Cases**: \n- Reduce average response time to customers\n- Reduce time to troubleshoot cases or issues\n- Ensure more consistent brand voice in reponse to customers when combined with knowledge and instructions in the GPT\n\n## Application Information\n\n### Application Key Links\n\nCheck out these links from the application before you get started:\n- [Create Lightning Apps in Salesforce](https://help.salesforce.com/s/articleView?id=sf.apps_lightning_create.htm&type=5)\n- [OAuth Tokens and Scopes](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_tokens_scopes.htm&type=5)\n- [Salesforce API Docs](https://developer.salesforce.com/docs/apis)\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 permissions to create an App in Salesforce\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**Context**: Your purpose is to pull information from Service Cloud, and push updates to cases. A user is going to ask you a question and ask you to make updates.\n\n**Instructions**:\n1. When a user asks you to help them solve a case in Service Cloud, ask for the case number and pull the details for the case into the conversation using the getCaseDetailsFromNumber action.\n2. If the user asks you to update the case details, use the action updateCaseStatus.\n\n**Example**: \nUser: Help me solve case 00001104 in Service Cloud.\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: Salesforce Service Cloud Case Update API\n  description: API for updating the status of Service Cloud tickets (cases) in Salesforce.\n  version: 1.0.3\nservers:\n  - url: https://your_instance.my.salesforce.com\n    description: Base URL for your Salesforce instance (replace 'your_instance' with your actual Salesforce domain)\npaths:\n  /services/data/v60.0/sobjects/Case/{CaseId}:\n    patch:\n      operationId: updateCaseStatus\n      summary: Updates the status of a Service Cloud case\n      description: Updates the status of a Service Cloud ticket based on the case ID number."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 85ec3c81-66bd-4a36-9a8d-b0e2528d3452
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb", "title": "## Introduction", "tokens": 2113, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"85ec3c81-66bd-4a36-9a8d-b0e2528d3452\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"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\": \"87b13565-bac0-47a0-a5b2-abd8e35ea696\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7615bccb53b0b8b53d08bf4d35b23e642825f51df7c3465919e831b4539b4cca\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"125c69f2-d094-404b-a9e3-ba2905c5c85a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"04fc5f43e31bf7e2347a926dfe542cf71a89b527862dc3df3e591e82a2d1cdc0\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"614be502-3ee4-49d9-acd6-1d032908ded4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"fa11e092abecc66a7fbe08fb2c40f745e67f11002fceb4e33a2d0be6ca358195\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2978, \"end_char_idx\": 6949, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "ref_doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "chroma:document": "```python\nopenapi: 3.1.0\ninfo:\n  title: Salesforce Service Cloud Case Update API\n  description: API for updating the status of Service Cloud tickets (cases) in Salesforce.\n  version: 1.0.3\nservers:\n  - url: https://your_instance.my.salesforce.com\n    description: Base URL for your Salesforce instance (replace 'your_instance' with your actual Salesforce domain)\npaths:\n  /services/data/v60.0/sobjects/Case/{CaseId}:\n    patch:\n      operationId: updateCaseStatus\n      summary: Updates the status of a Service Cloud case\n      description: Updates the status of a Service Cloud ticket based on the case ID number.\n      parameters:\n        - name: CaseId\n          in: path\n          required: true\n          description: The ID of the case to update.\n          schema:\n            type: string\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                Status:\n                  type: string\n                  description: The new status of the case.\n      responses:\n        '204':\n          description: Successfully updated the case status\n        '400':\n          description: Bad request - invalid input or case ID not found\n        '401':\n          description: Unauthorized - authentication required\n        '404':\n          description: Not Found - case ID does not exist\n    delete:\n      operationId: deleteCase\n      summary: Deletes a Service Cloud case\n      description: Deletes a Service Cloud ticket based on the case ID number.\n      parameters:\n        - name: CaseId\n          in: path\n          required: true\n          description: The ID of the case to delete.\n          schema:\n            type: string\n      responses:\n        '204':\n          description: Successfully deleted the case\n        '400':\n          description: Bad request - invalid case ID\n        '401':\n          description: Unauthorized - authentication required\n        '404':\n          description: Not Found - case ID does not exist\n  /services/data/v60.0/query:\n    get:\n      operationId: getCaseDetailsFromNumber\n      summary: Retrieves case details using a case number\n      description: Retrieves the details of a Service Cloud case associated with a given case number.\n      parameters:\n        - name: q\n          in: query\n          required: true\n          description: SOQL query string to find the Case details based on Case Number.\n          schema:\n            type: string\n            example: \"SELECT Id, CaseNumber, Status, Subject, Description FROM Case WHERE CaseNumber = '123456'\"\n      responses:\n        '200':\n          description: Successfully retrieved the case details\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  totalSize:\n                    type: integer\n                  done:\n                    type: boolean\n                  records:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        Id:\n                          type: string\n                        CaseNumber:\n                          type: string\n                        Status:\n                          type: string\n                        Subject:\n                          type: string\n                        Description:\n                          type: string\n        '400':\n          description: Bad request - invalid query\n        '401':\n          description: Unauthorized - authentication required\n        '404':\n          description: Not Found - case number does not exist\n\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 614be502-3ee4-49d9-acd6-1d032908ded4
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb", "title": "## Introduction", "tokens": 2113, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"614be502-3ee4-49d9-acd6-1d032908ded4\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"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\": \"87b13565-bac0-47a0-a5b2-abd8e35ea696\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7615bccb53b0b8b53d08bf4d35b23e642825f51df7c3465919e831b4539b4cca\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"85ec3c81-66bd-4a36-9a8d-b0e2528d3452\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"ecbbd4248b0aa4625933b1fbd85f656e04fca2a75e896cca6ba9f749f7d17673\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d6276329-910a-475a-9ddc-e6708a806c1e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"0c72ef83736e2424a8eaa8246e4a5c0698cf738d2d57c8a0562720f4def819f4\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4690, \"end_char_idx\": 8279, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "ref_doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "chroma:document": "schema:\n            type: string\n      responses:\n        '204':\n          description: Successfully deleted the case\n        '400':\n          description: Bad request - invalid case ID\n        '401':\n          description: Unauthorized - authentication required\n        '404':\n          description: Not Found - case ID does not exist\n  /services/data/v60.0/query:\n    get:\n      operationId: getCaseDetailsFromNumber\n      summary: Retrieves case details using a case number\n      description: Retrieves the details of a Service Cloud case associated with a given case number.\n      parameters:\n        - name: q\n          in: query\n          required: true\n          description: SOQL query string to find the Case details based on Case Number.\n          schema:\n            type: string\n            example: \"SELECT Id, CaseNumber, Status, Subject, Description FROM Case WHERE CaseNumber = '123456'\"\n      responses:\n        '200':\n          description: Successfully retrieved the case details\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  totalSize:\n                    type: integer\n                  done:\n                    type: boolean\n                  records:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        Id:\n                          type: string\n                        CaseNumber:\n                          type: string\n                        Status:\n                          type: string\n                        Subject:\n                          type: string\n                        Description:\n                          type: string\n        '400':\n          description: Bad request - invalid query\n        '401':\n          description: Unauthorized - authentication required\n        '404':\n          description: Not Found - case number does not exist\n\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\nBefore you set up authentication in ChatGPT, please take the following steps in the application.\n1. Navigate to Salesforce Setup\n\n![gptactions_salesforce.png](../../../images/gpt_actions_salesforce_setup.png)\n\n2. Search for \u201cApp Manager\u201d\n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_manager.png)\n\n3. Click \u201cNew Connected App\u201d\n4. Enter a Connected App Name\n5. Enter contact email (your email)\n6. Check the box to enable OAuth settings\n7. Insert a callback URL (use a placeholder like https://chat.openai.com/aip//oauth/callback for now, you\u2019ll update this later when you create the Action in ChatGPT) \n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_oauth2.png)\n\n8. Select \u201cSelected OAuth Scopes\u201d and grant the appropriate permissions. Scope these based on your internal security policies. \n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_scope.png)\n\n9. Ensure the following boxes are checked:\n- Enable Client Credentials Flow\n- Enable Authorization Code and Credentials FLow\n- Enable Token Exchange Flow\n10. Ensure the following box is unchecked: \n- Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: d6276329-910a-475a-9ddc-e6708a806c1e
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb", "title": "## Introduction", "tokens": 2113, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"d6276329-910a-475a-9ddc-e6708a806c1e\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"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\": \"87b13565-bac0-47a0-a5b2-abd8e35ea696\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7615bccb53b0b8b53d08bf4d35b23e642825f51df7c3465919e831b4539b4cca\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"614be502-3ee4-49d9-acd6-1d032908ded4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"211c918448ecf8066509d5e0b257576781a20ce0e32d38387943c656b93fbaa0\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b82e4d37-8904-401e-944f-5c0e1b0a4985\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"8d9f81bf49d278243ffde964c91b080c4f4505e6b675d2321daca8e46ebf0c2a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6797, \"end_char_idx\": 9697, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "ref_doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "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\nBefore you set up authentication in ChatGPT, please take the following steps in the application.\n1. Navigate to Salesforce Setup\n\n![gptactions_salesforce.png](../../../images/gpt_actions_salesforce_setup.png)\n\n2. Search for \u201cApp Manager\u201d\n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_manager.png)\n\n3. Click \u201cNew Connected App\u201d\n4. Enter a Connected App Name\n5. Enter contact email (your email)\n6. Check the box to enable OAuth settings\n7. Insert a callback URL (use a placeholder like https://chat.openai.com/aip//oauth/callback for now, you\u2019ll update this later when you create the Action in ChatGPT) \n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_oauth2.png)\n\n8. Select \u201cSelected OAuth Scopes\u201d and grant the appropriate permissions. Scope these based on your internal security policies. \n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_scope.png)\n\n9. Ensure the following boxes are checked:\n- Enable Client Credentials Flow\n- Enable Authorization Code and Credentials FLow\n- Enable Token Exchange Flow\n10. Ensure the following box is unchecked: \n- Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows\n\n\n![gptactions_salesforce.png](../../../images/gpt_actions_salesforce_settings_condensed.png) \n\n11. Save your New Connected App\n12. Under \u201cConsumer Key and Secret\u201d click \u201cManage Consumer Details\u201d. Verify your access using the code emailed to your account, and then copy the key and secret. \n- Salesforce Consumer Key = ChatGPT Client ID\n- Salesforce Consumer Secret = ChatGPT Client Secret\n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_credentials.png)\n\n13. Return to App page\n14. Click \u201cManage\u201d \n15. Click \u201cEdit Policies\u201d\n16. Under OAuth Policies, check the \u201cEnable Token Exchange Flow\u201d box\n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_token.png)\n\n17. Click save!\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://[inserturlhere].my.salesforce.com/services/oauth2/authorize\n- **Token URL**: https://[inserturlhere].my.salesforce.com/services/oauth2/token \n- **Scope**: full\n- **Token**: Default (POST)\n\n### Post-Action Steps\n\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- Navigate back to your Connected App in Salesforce, and add your callback URL."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: b82e4d37-8904-401e-944f-5c0e1b0a4985
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb", "title": "## Introduction", "tokens": 2113, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"b82e4d37-8904-401e-944f-5c0e1b0a4985\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"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\": \"87b13565-bac0-47a0-a5b2-abd8e35ea696\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"7615bccb53b0b8b53d08bf4d35b23e642825f51df7c3465919e831b4539b4cca\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d6276329-910a-475a-9ddc-e6708a806c1e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_salesforce.ipynb\", \"title\": \"## Introduction\", \"tokens\": 2113, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"973698ef04e8e8731954fcf37e5faf1fadd9d2ba1a4dc82608331fbcfff286ff\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8282, \"end_char_idx\": 10226, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "ref_doc_id": "87b13565-bac0-47a0-a5b2-abd8e35ea696", "chroma:document": "![gptactions_salesforce.png](../../../images/gpt_actions_salesforce_settings_condensed.png) \n\n11. Save your New Connected App\n12. Under \u201cConsumer Key and Secret\u201d click \u201cManage Consumer Details\u201d. Verify your access using the code emailed to your account, and then copy the key and secret. \n- Salesforce Consumer Key = ChatGPT Client ID\n- Salesforce Consumer Secret = ChatGPT Client Secret\n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_credentials.png)\n\n13. Return to App page\n14. Click \u201cManage\u201d \n15. Click \u201cEdit Policies\u201d\n16. Under OAuth Policies, check the \u201cEnable Token Exchange Flow\u201d box\n\n\n![gptactions_salesforce.png](../../../images//gpt_actions_salesforce_token.png)\n\n17. Click save!\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://[inserturlhere].my.salesforce.com/services/oauth2/authorize\n- **Token URL**: https://[inserturlhere].my.salesforce.com/services/oauth2/token \n- **Scope**: full\n- **Token**: Default (POST)\n\n### Post-Action Steps\n\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- Navigate back to your Connected App in Salesforce, and 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 Salesforce for the action to authenticate correctly\n- *Internal Server Error:* Ensure all the correct boxes are checked and/or unchecked in the OAuth settings for your connected app. \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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: bf513762-10c4-4a67-92f0-c856f577947e
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb", "title": "GPT Action Library: BigQuery", "tokens": 1723, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"bf513762-10c4-4a67-92f0-c856f577947e\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"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\": \"e0691b61-89b0-467d-a432-985f868ed3d2\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"ed45a0f1647c97f111c8618c6a0c4fce5713e6ba2371ff0c2df00c234fd0e339\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"addd4ad9-85c6-4fb3-baa4-e6e72f85b2b3\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"57911b57e3a2a95bd3e2d1746922a69f772e67627146884ac697912cd7aaac92\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2280, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "ref_doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "chroma:document": "# GPT Action Library: BigQuery\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 particular GPT Action provides an overview of how to connect to **Google BigQuery**, Google Cloud's Analytical Data Warehouse. This Action takes a user\u2019s question, scans the relevant tables to gather the data schema, then writes a SQL query to answer the user\u2019s question. \n\nNote: these instructions return back a functioning SQL statement, rather than the result itself. Currently middleware is required to return back a CSV file \u2013 we\u2019ll be posting instructions on an example of that soon\n\n### Value + Example Business Use Cases\n\n**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to BigQuery's DWH. \n\n**Example Use Cases**: \n- Data scientists can connect to tables and run data analyses using ChatGPT's Data Analysis\n- Citizen data users can ask basic questions of their transactional data\n- Users gain more visibility into their data & potential anomalies\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://cloud.google.com/bigquery \n- Application API Documentation: https://cloud.google.com/bigquery/docs/reference/rest \n\n### Application Prerequisites\n\nBefore you get started, make sure you go through the following steps in your application environment:\n- Set up a GCP project \n- Set up a BQ dataset in that GCP project\n- Ensure that the user authenticating into BigQuery via ChatGPT has access to that BQ dataset \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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: addd4ad9-85c6-4fb3-baa4-e6e72f85b2b3
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb", "title": "GPT Action Library: BigQuery", "tokens": 1723, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"addd4ad9-85c6-4fb3-baa4-e6e72f85b2b3\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"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\": \"e0691b61-89b0-467d-a432-985f868ed3d2\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"ed45a0f1647c97f111c8618c6a0c4fce5713e6ba2371ff0c2df00c234fd0e339\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bf513762-10c4-4a67-92f0-c856f577947e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"e0db81bb050afe9b25289b1eff0298355c09105e8a8c00ac84271500b357ca1e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8973f788-b46c-4d92-8dc7-88b1048e6ed9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"803397d4bd6a825097902ea1d58578550f1f72b850da83566193f2bc56907def\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2283, \"end_char_idx\": 6323, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "ref_doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "chroma:document": "```python\n**Context**: You are an expert at writing BigQuery SQL queries. A user is going to ask you a question. \n\n**Instructions**:\n1. No matter the user's question, start by running `runQuery` operation using this query: \"SELECT column_name, table_name, data_type, description FROM `{project}.{dataset}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS`\" \n-- Assume project = \"<insert your default project here>\", dataset = \"<insert your default dataset here>\", unless the user provides different values \n-- Remember to include useLegacySql:false in the json output\n2. Convert the user's question into a SQL statement that leverages the step above and run the `runQuery` operation on that SQL statement to confirm the query works. Add a limit of 100 rows\n3. Now remove the limit of 100 rows and return back the query for the user to see\n\n**Additional Notes**: If the user says \"Let's get started\", explain that the user can provide a project or dataset, along with a question they want answered. If the user has no ideas, suggest that we have a sample flights dataset they can query - ask if they want you to query that\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: BigQuery API\n  description: API for querying a BigQuery table.\n  version: 1.0.0\nservers:\n  - url: https://bigquery.googleapis.com/bigquery/v2\n    description: Google BigQuery API server\npaths:\n  /projects/{projectId}/queries:\n    post:\n      operationId: runQuery\n      summary: Executes a query on a specified BigQuery table.\n      description: Submits a query to BigQuery and returns the results.\n      x-openai-isConsequential: false\n      parameters:\n        - name: projectId\n          in: path\n          required: true\n          description: The ID of the Google Cloud project.\n          schema:\n            type: string\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 SQL query string.\n                useLegacySql:\n                  type: boolean\n                  description: Whether to use legacy SQL.\n                  default: false\n      responses:\n        '200':\n          description: Successful query execution.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  kind:\n                    type: string\n                    example: \"bigquery#queryResponse\"\n                  schema:\n                    type: object\n                    description: The schema of the results.\n                  jobReference:\n                    type: object\n                    properties:\n                      projectId:\n                        type: string\n                      jobId:\n                        type: string\n                  rows:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        f:\n                          type: array\n                          items:\n                            type: object\n                            properties:\n                              v:\n                                type: string\n                  totalRows:\n                    type: string\n                    description: Total number of rows in the query result.\n                  pageToken:\n                    type: string\n                    description: Token for pagination of query results.\n        '400':\n          description: Bad request. The request was invalid.\n        '401':\n          description: Unauthorized. Authentication is required.\n        '403':\n          description: Forbidden. The request is not allowed."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 8973f788-b46c-4d92-8dc7-88b1048e6ed9
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb", "title": "GPT Action Library: BigQuery", "tokens": 1723, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"8973f788-b46c-4d92-8dc7-88b1048e6ed9\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"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\": \"e0691b61-89b0-467d-a432-985f868ed3d2\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"ed45a0f1647c97f111c8618c6a0c4fce5713e6ba2371ff0c2df00c234fd0e339\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"addd4ad9-85c6-4fb3-baa4-e6e72f85b2b3\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"c3ebef95ab7e0416c54dd16432efedbb16b30019284e013fbbdc0ea85f5ad717\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"2597efd4-223e-448f-9038-d75417431654\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b32152074618f769857856817faa2a03968f0050468e7d9bae585a11eb01e4a9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4023, \"end_char_idx\": 7912, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "ref_doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "chroma:document": "description: Submits a query to BigQuery and returns the results.\n      x-openai-isConsequential: false\n      parameters:\n        - name: projectId\n          in: path\n          required: true\n          description: The ID of the Google Cloud project.\n          schema:\n            type: string\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 SQL query string.\n                useLegacySql:\n                  type: boolean\n                  description: Whether to use legacy SQL.\n                  default: false\n      responses:\n        '200':\n          description: Successful query execution.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  kind:\n                    type: string\n                    example: \"bigquery#queryResponse\"\n                  schema:\n                    type: object\n                    description: The schema of the results.\n                  jobReference:\n                    type: object\n                    properties:\n                      projectId:\n                        type: string\n                      jobId:\n                        type: string\n                  rows:\n                    type: array\n                    items:\n                      type: object\n                      properties:\n                        f:\n                          type: array\n                          items:\n                            type: object\n                            properties:\n                              v:\n                                type: string\n                  totalRows:\n                    type: string\n                    description: Total number of rows in the query result.\n                  pageToken:\n                    type: string\n                    description: Token for pagination of query results.\n        '400':\n          description: Bad request. The request was invalid.\n        '401':\n          description: Unauthorized. Authentication is required.\n        '403':\n          description: Forbidden. The request is not allowed.\n        '404':\n          description: Not found. The specified resource was not found.\n        '500':\n          description: Internal server error. An error occurred while processing the request.\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- Go to the Google Cloud Console\n- Navigate to API & Services > Credentials\n- Create new OAuth credentials (or use an existing one)\n- Locate your OAuth Client ID & Client Secret and store both values securely (see screenshot below)\n\n![gptactions_BigQuery_auth.png](../../../images/gptactions_BigQuery_auth.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://www.googleapis.com/auth/bigquery \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"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 2597efd4-223e-448f-9038-d75417431654
encoding: FLOAT32
metadata:
{"url": "https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb", "title": "GPT Action Library: BigQuery", "tokens": 1723, "retrieve_doc": true, "source": "openai_cookbooks", "_node_content": "{\"id_\": \"2597efd4-223e-448f-9038-d75417431654\", \"embedding\": null, \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"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\": \"e0691b61-89b0-467d-a432-985f868ed3d2\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"ed45a0f1647c97f111c8618c6a0c4fce5713e6ba2371ff0c2df00c234fd0e339\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8973f788-b46c-4d92-8dc7-88b1048e6ed9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/gpt_actions_library/gpt_action_bigquery.ipynb\", \"title\": \"GPT Action Library: BigQuery\", \"tokens\": 1723, \"retrieve_doc\": true, \"source\": \"openai_cookbooks\"}, \"hash\": \"3e2e059eabacca52c6ffcc74b2a83f016ede016f0a5909573acec3ec9e774b62\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6099, \"end_char_idx\": 8589, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "ref_doc_id": "e0691b61-89b0-467d-a432-985f868ed3d2", "chroma:document": "'400':\n          description: Bad request. The request was invalid.\n        '401':\n          description: Unauthorized. Authentication is required.\n        '403':\n          description: Forbidden. The request is not allowed.\n        '404':\n          description: Not found. The specified resource was not found.\n        '500':\n          description: Internal server error. An error occurred while processing the request.\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- Go to the Google Cloud Console\n- Navigate to API & Services > Credentials\n- Create new OAuth credentials (or use an existing one)\n- Locate your OAuth Client ID & Client Secret and store both values securely (see screenshot below)\n\n![gptactions_BigQuery_auth.png](../../../images/gptactions_BigQuery_auth.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://www.googleapis.com/auth/bigquery \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 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 7626b6d6-afde-4e3e-9d4d-40aaa6965045
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_\": \"7626b6d6-afde-4e3e-9d4d-40aaa6965045\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"1cbd4af3-cd1c-4638-8aa3-b74987d80e24\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7bb958fe707b46f22189caef0ec89c6a3ab67e5ab5f03e57ad8fae234cef3724\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2929, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "# GPT Action Library: Sharepoint (Return as Document)\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 pre-processes the file within the Azure Function. The Azure Function returns text, instead of the base64 encoded file. Due to the pre-processing and the conversion to text, this solution is best used for large, unstructured documents, and for when you want to analyze more than the amount of files supported in the first solution (see documentation [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_2.gif)\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.\n\n2. For each file that is found, convert it to a consistent readable format and retrieve all the text.\n\n3. Use GPT 4o mini (gpt-4o-mini) to extract the relevant text from the files based on the initial user\u2019s question. Note the pricing of GPT 4o mini [here](https://openai.com/pricing#language-models) - since we are dealing with small token chunks, the cost of this step is nominal.\u00a0\u00a0\n\n4. Returns that data to ChatGPT. The GPT then uses that information to respond to the user's initial question.\n\nAs you can see from the below architecture diagram, the first three steps are the same as Solution 1. The main difference is that this solution converts the file to text instead of a base64 string, and then summarizes that text using GPT 4o mini.\n\n!"}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 1cbd4af3-cd1c-4638-8aa3-b74987d80e24
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_\": \"1cbd4af3-cd1c-4638-8aa3-b74987d80e24\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7626b6d6-afde-4e3e-9d4d-40aaa6965045\", \"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\": \"14c3794cead7ea6ec6630ada39d8b4b2b9e43d48cb0a2ecd6087f1f66f3d015b\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"be934723-0ec7-4673-83ff-92451214ae89\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e58c907949189810b92519fe61b8a36ebadba4594ca9c1df30131bd4c6fa42b9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1194, \"end_char_idx\": 4587, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "This solution pre-processes the file within the Azure Function. The Azure Function returns text, instead of the base64 encoded file. Due to the pre-processing and the conversion to text, this solution is best used for large, unstructured documents, and for when you want to analyze more than the amount of files supported in the first solution (see documentation [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_2.gif)\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.\n\n2. For each file that is found, convert it to a consistent readable format and retrieve all the text.\n\n3. Use GPT 4o mini (gpt-4o-mini) to extract the relevant text from the files based on the initial user\u2019s question. Note the pricing of GPT 4o mini [here](https://openai.com/pricing#language-models) - since we are dealing with small token chunks, the cost of this step is nominal.\u00a0\u00a0\n\n4. Returns that data to ChatGPT. The GPT then uses that information to respond to the user's initial question.\n\nAs you can see from the below architecture diagram, the first three steps are the same as Solution 1. The main difference is that this solution converts the file to text instead of a base64 string, and then summarizes that text using GPT 4o mini.\n\n![](../../../images/solution_2_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- An OpenAI API Key from platform.openai.com\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\nSteps: \n\n1. loop through the returned files and download the files using the [Download File endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) or [Convert File endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http)\n\n2. convert that Binary stream to human readable text using [pdf-parse](https://www.npmjs.com/package/pdf-parse)\n\n3. Then, we can optimize further by summarizing using gpt-4o-mini in the function to help with the 100,000 character limit we impose on Actions today."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: be934723-0ec7-4673-83ff-92451214ae89
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_\": \"be934723-0ec7-4673-83ff-92451214ae89\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"1cbd4af3-cd1c-4638-8aa3-b74987d80e24\", \"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\": \"0c879e29adca2b1a83d482d2ac059bacc5e4caa529e75cbf46072e2e8997b31f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"a03f9fc4-2f20-4fae-ad79-2afba4d7f987\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"664c4573cc56757082575373837db4382ba9d8d061753e0ab2064e9593bb637d\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2782, \"end_char_idx\": 5992, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "The main difference is that this solution converts the file to text instead of a base64 string, and then summarizes that text using GPT 4o mini.\n\n![](../../../images/solution_2_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- An OpenAI API Key from platform.openai.com\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\nSteps: \n\n1. loop through the returned files and download the files using the [Download File endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) or [Convert File endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http)\n\n2. convert that Binary stream to human readable text using [pdf-parse](https://www.npmjs.com/package/pdf-parse)\n\n3. Then, we can optimize further by summarizing using gpt-4o-mini in the function to help with the 100,000 character limit we impose on Actions today.\u00a0\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_two_preprocessing.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\n    3. `OPENAI_API_KEY:` spin up an OpenAI API key on platform.openai.com.\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\n       3. `npm install pdf-parse`\n\n       4. `npm install openai`\n\n5."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: a03f9fc4-2f20-4fae-ad79-2afba4d7f987
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_\": \"a03f9fc4-2f20-4fae-ad79-2afba4d7f987\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"be934723-0ec7-4673-83ff-92451214ae89\", \"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\": \"050e1d673ce7b25850e2e69ce3e1d7cf12da5eb9ab9b88fa54e84e27618b7933\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b8654be6-47f1-4352-b6c0-01d9eaad8813\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"24580a9bf86d8b884db30bef5d03680d97a7845dd90a0063c3d72ae3ee4a3f70\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4440, \"end_char_idx\": 7527, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "Then, we can optimize further by summarizing using gpt-4o-mini in the function to help with the 100,000 character limit we impose on Actions today.\u00a0\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_two_preprocessing.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\n    3. `OPENAI_API_KEY:` spin up an OpenAI API key on platform.openai.com.\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\n       3. `npm install pdf-parse`\n\n       4. `npm install openai`\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        \"query\": \"<choose a question>\",\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!\n\n\n## Detailed Walkthrough\n\nThe below walks through setup instructions and walkthrough unique to this solution of pre-processing the files and extracting summaries in the Azure Function. You can find the entire code [here](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_two_preprocessing.js).\n\n### Code Walkthrough\n\n#### Implementing the Authentication\u00a0\n\nBelow we have a few helper functions that we\u2019ll use in the function.\n\n#### Initializing the Microsoft Graph Client\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\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."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: b8654be6-47f1-4352-b6c0-01d9eaad8813
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_\": \"b8654be6-47f1-4352-b6c0-01d9eaad8813\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"a03f9fc4-2f20-4fae-ad79-2afba4d7f987\", \"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\": \"4babf8e634f928505356691659b5bf519e459c504694fd5a4d29bd2ef378ac3c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"05dfd3c7-d57f-4f0c-acd9-c4c61230d0d9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"4558c52194f55355a17c72861a1550e773c6f7d4569fedcf77e09f384432e7af\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5790, \"end_char_idx\": 9024, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "Install the following packages in console\n\n       1. `npm install @microsoft/microsoft-graph-client`\n\n       2. `npm install axios`\n\n       3. `npm install pdf-parse`\n\n       4. `npm install openai`\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        \"query\": \"<choose a question>\",\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!\n\n\n## Detailed Walkthrough\n\nThe below walks through setup instructions and walkthrough unique to this solution of pre-processing the files and extracting summaries in the Azure Function. You can find the entire code [here](https://github.com/openai/openai-cookbook/blob/main/examples/chatgpt/sharepoint_azure_function/solution_two_preprocessing.js).\n\n### Code Walkthrough\n\n#### Implementing the Authentication\u00a0\n\nBelow we have a few helper functions that we\u2019ll use in the function.\n\n#### Initializing the Microsoft Graph Client\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\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    const { TENANT_ID, CLIENT_ID, MICROSOFT_PROVIDER_AUTHENTICATION_SECRET } = process.env;\n    const params = {\n        client_id: CLIENT_ID,\n        client_secret: MICROSOFT_PROVIDER_AUTHENTICATION_SECRET,\n        grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n        assertion: userAccessToken,\n        requested_token_use: 'on_behalf_of',\n        scope: 'https://graph.microsoft.com/.default'\n    };\n\n    const url = `https\\://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token`;\n    try {\n        const response = await axios.post(url, qs.stringify(params), {\n            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }\n        });\n        return response.data.access\\_token;\n    } catch (error) {\n        console.error('Error obtaining OBO token:', error.response?.data || error.message);\n        throw error;\n    }\n}\n```\n\n#### Retrieving Content from O365 / SharePoint Items\n\nThis function fetches the content of drive items, handling different file types and converting files to PDF when necessary for text extraction. This uses the [download endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) for PDFs and the [convert endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http) for other supported file types."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 05dfd3c7-d57f-4f0c-acd9-c4c61230d0d9
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_\": \"05dfd3c7-d57f-4f0c-acd9-c4c61230d0d9\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b8654be6-47f1-4352-b6c0-01d9eaad8813\", \"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\": \"a520e2ec5690520ee22c9ab87728614f1be97fc5d4b8ba9ee52f61d779ce69ba\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"1aca25d5-6be4-42aa-8845-06e2d6429ec6\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"175562afa5784a2cc5d7c82a2e3d79f20333f8838a43b191ce93900a64365172\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 7412, \"end_char_idx\": 10317, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "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    const { TENANT_ID, CLIENT_ID, MICROSOFT_PROVIDER_AUTHENTICATION_SECRET } = process.env;\n    const params = {\n        client_id: CLIENT_ID,\n        client_secret: MICROSOFT_PROVIDER_AUTHENTICATION_SECRET,\n        grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n        assertion: userAccessToken,\n        requested_token_use: 'on_behalf_of',\n        scope: 'https://graph.microsoft.com/.default'\n    };\n\n    const url = `https\\://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token`;\n    try {\n        const response = await axios.post(url, qs.stringify(params), {\n            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }\n        });\n        return response.data.access\\_token;\n    } catch (error) {\n        console.error('Error obtaining OBO token:', error.response?.data || error.message);\n        throw error;\n    }\n}\n```\n\n#### Retrieving Content from O365 / SharePoint Items\n\nThis function fetches the content of drive items, handling different file types and converting files to PDF when necessary for text extraction. This uses the [download endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) for PDFs and the [convert endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http) for other supported file types.\n```javascript\nconst getDriveItemContent = async (client, driveId, itemId, name) => {\n    try {\n        const fileType = path.extname(name).toLowerCase();\n        // the below files types are the ones that are able to be converted to PDF to extract the text. See https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http\n        const allowedFileTypes = ['.pdf', '.doc', '.docx', '.odp', '.ods', '.odt', '.pot', '.potm', '.potx', '.pps', '.ppsx', '.ppsxm', '.ppt', '.pptm', '.pptx', '.rtf'];\n        // filePath changes based on file type, adding ?format=pdf to convert non-pdf types to pdf for text extraction, so all files in allowedFileTypes above are converted to pdf\n        const filePath = `/drives/${driveId}/items/${itemId}/content` + ((fileType === '.pdf' || fileType === '.txt' || fileType === '.csv') ? '' : '?format=pdf');\n        if (allowedFileTypes.includes(fileType)) {\n            response = await client.api(filePath).getStream();\n            // The below takes the chunks in response and combines\n            let chunks = [];\n            for await (let chunk of response) {\n                chunks.push(chunk);\n            }\n            let buffer = Buffer.concat(chunks);\n            // the below extracts the text from the PDF."}


created_at: 2024-07-28 18:59:25
topic: persistent://default/default/4bfc3c11-fb71-4cc9-8c12-01ed076a0e01
id: 1aca25d5-6be4-42aa-8845-06e2d6429ec6
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_\": \"1aca25d5-6be4-42aa-8845-06e2d6429ec6\", \"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\": \"90a10d9a-7b83-4834-9f7e-c9b314865ef0\", \"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\": \"1bf0762cbb08ce257d5016a28e56e66eaa081414347c80627b84e7aece8463d0\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"05dfd3c7-d57f-4f0c-acd9-c4c61230d0d9\", \"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\": \"49132c560b4a98c197aa4c85b86720e60d369c6bc800ad48809c20db3a2974c4\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"234ea0b1-25ca-4fe1-9c4c-8ff1a179b682\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b17f18c930c6ac111ed1b4cb1b5f54b60bae6a5e2373b9728f56c8ba43af4bfd\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8720, \"end_char_idx\": 11945, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "ref_doc_id": "90a10d9a-7b83-4834-9f7e-c9b314865ef0", "chroma:document": "This uses the [download endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0\\&tabs=http) for PDFs and the [convert endpoint](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0\\&tabs=http) for other supported file types.\n```javascript\nconst getDriveItemContent = async (client, driveId, itemId, name) => {\n    try {\n        const fileType = path.extname(name).toLowerCase();\n        // the below files types are the ones that are able to be converted to PDF to extract the text. See https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http\n        const allowedFileTypes = ['.pdf', '.doc', '.docx', '.odp', '.ods', '.odt', '.pot', '.potm', '.potx', '.pps', '.ppsx', '.ppsxm', '.ppt', '.pptm', '.pptx', '.rtf'];\n        // filePath changes based on file type, adding ?format=pdf to convert non-pdf types to pdf for text extraction, so all files in allowedFileTypes above are converted to pdf\n        const filePath = `/drives/${driveId}/items/${itemId}/content` + ((fileType === '.pdf' || fileType === '.txt' || fileType === '.csv') ? '' : '?format=pdf');\n        if (allowedFileTypes.includes(fileType)) {\n            response = await client.api(filePath).getStream();\n            // The below takes the chunks in response and combines\n            let chunks = [];\n            for await (let chunk of response) {\n                chunks.push(chunk);\n            }\n            let buffer = Buffer.concat(chunks);\n            // the below extracts the text from the PDF.\n            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."}


