Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create devcontainer.json #1313

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "my-project-devcontainer",
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers-contrib/features/ts-node:1": {},
"ghcr.io/devcontainers-contrib/features/bash-command:1": {},
"ghcr.io/devcontainers-contrib/features/jshint:2": {},
"ghcr.io/devcontainers-contrib/features/json-server:1": {},
"ghcr.io/devcontainers-contrib/features/localtunnel-npm:1": {},
"ghcr.io/devcontainers-contrib/features/live-server:1": {},
"ghcr.io/devcontainers-contrib/features/jest:2": {},
"ghcr.io/devcontainers/features/java:1": {},
"ghcr.io/devcontainers-contrib/features/npm-package:1": {},
"ghcr.io/devcontainers-contrib/features/mypy:2": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/hspaans/devcontainer-features/pymarkdownlnt:1": {},
"ghcr.io/devcontainers-contrib/features/ripgrep:1": {},
"ghcr.io/devcontainers-contrib/features/qrcode:2": {}
}
}
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions",
"ms-python.python"
]
}
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 9091
},
"preLaunchTask": "func: host start"
}
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"azureFunctions.deploySubpath": "examples/chatgpt/rag-quickstart/azure",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectSubpath": "examples/chatgpt/rag-quickstart/azure"
}
33 changes: 33 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"label": "func: host start",
"command": "host start",
"problemMatcher": "$func-python-watch",
"isBackground": true,
"dependsOn": "pip install (functions)",
"options": {
"cwd": "${workspaceFolder}/examples/chatgpt/rag-quickstart/azure"
}
},
{
"label": "pip install (functions)",
"type": "shell",
"osx": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
},
"windows": {
"command": "${config:azureFunctions.pythonVenv}/Scripts/python -m pip install -r requirements.txt"
},
"linux": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
},
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/examples/chatgpt/rag-quickstart/azure"
}
}
]
}
Binary file added examples/ECPD.zip
Binary file not shown.
Binary file added examples/ECPD/2.pdf
Binary file not shown.
Binary file not shown.
Binary file added examples/ECPD/Anixter (US) July-24.pdf
Binary file not shown.
Binary file added examples/ECPD/Patrick Distribution.pdf
Binary file not shown.
232 changes: 232 additions & 0 deletions examples/MyNotes.ipynb

Large diffs are not rendered by default.

1,601 changes: 50 additions & 1,551 deletions examples/Parse_PDF_docs_for_RAG.ipynb

Large diffs are not rendered by default.

79 changes: 68 additions & 11 deletions examples/azure/functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,53 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: openai<2.0.0,>=1.0.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (1.37.1)\n",
"Requirement already satisfied: anyio<5,>=3.5.0 in /home/codespace/.local/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (4.4.0)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /home/codespace/.local/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (0.27.0)\n",
"Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (2.8.2)\n",
"Requirement already satisfied: sniffio in /home/codespace/.local/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (1.3.1)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (4.66.4)\n",
"Requirement already satisfied: typing-extensions<5,>=4.7 in /home/codespace/.local/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0) (4.12.2)\n",
"Requirement already satisfied: idna>=2.8 in /home/codespace/.local/lib/python3.10/site-packages (from anyio<5,>=3.5.0->openai<2.0.0,>=1.0.0) (3.7)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /home/codespace/.local/lib/python3.10/site-packages (from anyio<5,>=3.5.0->openai<2.0.0,>=1.0.0) (1.2.1)\n",
"Requirement already satisfied: certifi in /home/codespace/.local/lib/python3.10/site-packages (from httpx<1,>=0.23.0->openai<2.0.0,>=1.0.0) (2024.7.4)\n",
"Requirement already satisfied: httpcore==1.* in /home/codespace/.local/lib/python3.10/site-packages (from httpx<1,>=0.23.0->openai<2.0.0,>=1.0.0) (1.0.5)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /home/codespace/.local/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai<2.0.0,>=1.0.0) (0.14.0)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->openai<2.0.0,>=1.0.0) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.20.1 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->openai<2.0.0,>=1.0.0) (2.20.1)\n",
"Requirement already satisfied: python-dotenv in /usr/local/python/3.10.13/lib/python3.10/site-packages (1.0.1)\n"
]
}
],
"source": [
"! pip install \"openai>=1.0.0,<2.0.0\"\n",
"! pip install python-dotenv"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"import openai\n",
Expand All @@ -58,11 +92,11 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"use_azure_active_directory = False # Set this flag to True if you are using Azure Active Directory"
"use_azure_active_directory = True # Set this flag to True if you are using Azure Active Directory"
]
},
{
Expand All @@ -76,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -103,16 +137,39 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: azure-identity>=1.15.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (1.17.1)\n",
"Requirement already satisfied: azure-core>=1.23.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from azure-identity>=1.15.0) (1.30.2)\n",
"Requirement already satisfied: cryptography>=2.5 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from azure-identity>=1.15.0) (43.0.0)\n",
"Requirement already satisfied: msal>=1.24.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from azure-identity>=1.15.0) (1.30.0)\n",
"Requirement already satisfied: msal-extensions>=0.3.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from azure-identity>=1.15.0) (1.2.0)\n",
"Requirement already satisfied: typing-extensions>=4.0.0 in /home/codespace/.local/lib/python3.10/site-packages (from azure-identity>=1.15.0) (4.12.2)\n",
"Requirement already satisfied: requests>=2.21.0 in /home/codespace/.local/lib/python3.10/site-packages (from azure-core>=1.23.0->azure-identity>=1.15.0) (2.32.3)\n",
"Requirement already satisfied: six>=1.11.0 in /home/codespace/.local/lib/python3.10/site-packages (from azure-core>=1.23.0->azure-identity>=1.15.0) (1.16.0)\n",
"Requirement already satisfied: cffi>=1.12 in /home/codespace/.local/lib/python3.10/site-packages (from cryptography>=2.5->azure-identity>=1.15.0) (1.16.0)\n",
"Requirement already satisfied: PyJWT<3,>=1.0.0 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from PyJWT[crypto]<3,>=1.0.0->msal>=1.24.0->azure-identity>=1.15.0) (2.8.0)\n",
"Requirement already satisfied: portalocker<3,>=1.4 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from msal-extensions>=0.3.0->azure-identity>=1.15.0) (2.10.1)\n",
"Requirement already satisfied: pycparser in /home/codespace/.local/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=2.5->azure-identity>=1.15.0) (2.22)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /home/codespace/.local/lib/python3.10/site-packages (from requests>=2.21.0->azure-core>=1.23.0->azure-identity>=1.15.0) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /home/codespace/.local/lib/python3.10/site-packages (from requests>=2.21.0->azure-core>=1.23.0->azure-identity>=1.15.0) (3.7)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/python/3.10.13/lib/python3.10/site-packages (from requests>=2.21.0->azure-core>=1.23.0->azure-identity>=1.15.0) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/codespace/.local/lib/python3.10/site-packages (from requests>=2.21.0->azure-core>=1.23.0->azure-identity>=1.15.0) (2024.7.4)\n"
]
}
],
"source": [
"! pip install \"azure-identity>=1.15.0\""
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -336,7 +393,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
"version": "3.10.13"
},
"vscode": {
"interpreter": {
Expand Down
2 changes: 2 additions & 0 deletions examples/chatgpt/rag-quickstart/azure/.funcignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@


.venv
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
},
"outputs": [],
"source": [
"!pip install llama-index pypdf"
"%pip install llama-index pypdf"
]
},
{
Expand Down
113 changes: 113 additions & 0 deletions examples/third_party/snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
* This script samples automation of multi-step tasks that can be tedious to manually perform on all tables and
* worksheets.
*
* This sample appends sample data and applies formatting and border edits to all tables in the worksheet,
* then freezes the first row and column.
*
* There needs to be an existing table for this script to run.
*/
function main(workbook: ExcelScript.Workbook) {
const currentSheet = workbook.getActiveWorksheet();

// Get the tables.
let tables = currentSheet.getTables();

// Sample data to append.
let data = [
["value1", "value2"],
["value3", ""],
];

// Header font customizations.
let headerFontName = "Calibri";
let headerFontColor = "white";
let headerFontSize = 12;
let headerFillColor = "black";

// Border customizations.
const thinWeight = ExcelScript.BorderWeight.thin;
const thickWeight = ExcelScript.BorderWeight.thick;
const doubleStyle = ExcelScript.BorderLineStyle.double;
const continuousStyle = ExcelScript.BorderLineStyle.continuous;

// Border edge colors.
let rightEdgeColor = "blue";
let leftEdgeColor = "red";

// Iterate over each table.
tables.forEach((table) => {
let lastRow = table.getRange().getRowCount();
let columns = table.getHeaderRowRange().getColumnIndex();

// Append the sample data to the last empty row of the table(s).
let range = currentSheet.getRangeByIndexes(
lastRow,
columns,
data.length,
data[0].length
);

range.setValues(data);

// Format and border editing.

// Get header row and header font.
const headerRow = table.getHeaderRowRange().getFormat();
const headerRowFont = table.getHeaderRowRange().getFormat().getFont();

// Format the header row.
headerRowFont.setName(headerFontName);
headerRowFont.setColor(headerFontColor);
headerRowFont.setSize(headerFontSize);
headerRow.getFill().setColor(headerFillColor);

// Get right and left edge border of table.
const rightEdge = table
.getRange()
.getFormat()
.getRangeBorder(ExcelScript.BorderIndex.edgeRight);
const leftEdge = table
.getRange()
.getFormat()
.getRangeBorder(ExcelScript.BorderIndex.edgeLeft);

// Format the right and left edge borders.
rightEdge.setColor(rightEdgeColor);
rightEdge.setStyle(continuousStyle);
leftEdge.setColor(leftEdgeColor);
leftEdge.setWeight(thickWeight);

// Get bottom border of a select row.
// Change the index number in getRow() to select a specific row.
let edgeBottomSelectRow = table
.getRangeBetweenHeaderAndTotal()
.getRow(0)
.getFormat()
.getRangeBorder(ExcelScript.BorderIndex.edgeBottom);

// Get inside vertical border of select row.
// Change the index number in getRow() to select a specific row.
let insideVerticalSelectRow = table
.getRangeBetweenHeaderAndTotal()
.getRow(0)
.getFormat()
.getRangeBorder(ExcelScript.BorderIndex.insideVertical);

// Set border style for select Row.
edgeBottomSelectRow.setStyle(doubleStyle);
edgeBottomSelectRow.setWeight(thinWeight);
edgeBottomSelectRow.setColor("red");
insideVerticalSelectRow.setStyle(continuousStyle);
insideVerticalSelectRow.setColor("red");
insideVerticalSelectRow.setWeight(thinWeight);
});

// Freeze first row and column.
currentSheet.getFreezePanes().freezeRows();
currentSheet.getFreezePanes().freezeColumns();

// Autofit rows and columns.
currentSheet.getRange().getFormat().autofitColumns();
currentSheet.getRange().getFormat().autofitRows();
}
4 changes: 3 additions & 1 deletion examples/utils/embeddings_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
client = OpenAI(max_retries=5)


def get_embedding(text: str, model="text-embedding-3-small", **kwargs) -> List[float]:
def get_embedding(
text: str, model="text-embedding-3-small", **kwargs
) -> List[float]:
# replace newlines, which can negatively affect performance.
text = text.replace("\n", " ")

Expand Down