Skip to content

Commit 8a56a95

Browse files
committed
eng code
1 parent d2a5293 commit 8a56a95

15 files changed

+475
-497
lines changed

.vscode/launch.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Original",
9+
"request": "launch",
10+
"runtimeArgs": [
11+
"run-script",
12+
"start:js"
13+
],
14+
"runtimeExecutable": "npm",
15+
"skipFiles": [
16+
"<node_internals>/**"
17+
],
18+
"cwd": "${workspaceFolder}/quickstarts/ai-agents/ts",
19+
"type": "node"
20+
},
21+
{
22+
"name": "Code interp",
23+
"request": "launch",
24+
"runtimeArgs": [
25+
"run-script",
26+
"start:js"
27+
],
28+
"runtimeExecutable": "npm",
29+
"skipFiles": [
30+
"<node_internals>/**"
31+
],
32+
"cwd": "${workspaceFolder}/quickstarts/ai-agents/ts",
33+
"type": "node"
34+
},
35+
{
36+
"name": "Launch TS",
37+
"request": "launch",
38+
"runtimeArgs": [
39+
"run-script",
40+
"start"
41+
],
42+
"runtimeExecutable": "npm",
43+
"skipFiles": [
44+
"<node_internals>/**"
45+
],
46+
"cwd": "${workspaceFolder}/quickstarts/ai-agents/ts",
47+
"type": "node"
48+
}
49+
]
50+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Define variables
3+
subscription="1bd6f57f-967b-4aed-a90f-d13ad8d84ffe" # Replace with your actual subscription ID
4+
resource_group="dib-sweden" # Replace with your actual resource group name
5+
project_name="basicaccountozwc" # Replace with your actual project name
6+
7+
# Get the current logged in user and their object ID
8+
echo "Getting details of the currently logged in user..."
9+
current_user=$(az ad signed-in-user show --query userPrincipalName --output tsv)
10+
echo "Current logged in user: $current_user"
11+
assignee_object_id=$(az ad signed-in-user show --query id --output tsv)
12+
echo "Object ID: $assignee_object_id"
13+
14+
# Define resource and scope
15+
resource_type="Microsoft.CognitiveServices/accounts"
16+
resource_name="${project_name}"
17+
scope="/subscriptions/$subscription/resourceGroups/$resource_group/providers/${resource_type}/${resource_name}"
18+
19+
# Use variables in the command
20+
az role assignment create \
21+
--role "Azure AI User" \
22+
--scope "$scope" \
23+
--assignee-object-id "$assignee_object_id" \
24+
--assignee-principal-type User

quickstarts/ai-agents/ts/az-cli-roles.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Define variables
32
subscription="YOUR_SUBSCRIPTION_ID" # Replace with your actual subscription ID
43
resource_group="YOUR_RESOURCE_GROUP" # Replace with your actual resource group name
@@ -20,4 +19,5 @@ scope="/subscriptions/$subscription/resourceGroups/$resource_group/providers/${r
2019
az role assignment create \
2120
--role "Azure AI User" \
2221
--scope "$scope" \
23-
--assignee-object-id "$assignee_object_id"
22+
--assignee-object-id "$assignee_object_id" \
23+
--assignee-principal-type User
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Company Name
2+
Adatum Corporation
3+
Adventure Works Cycles
4+
Alpine Ski House
5+
Bellows College
6+
Best For You Organics Company
7+
Boulder Innovations
8+
Contoso, Ltd.
9+
Contoso Pharmaceuticals
10+
Contoso Suites
11+
Consolidated Messenger
12+
Fabrikam, Inc.
13+
Fabrikam Residences
14+
First Up Consultants
15+
Fourth Coffee
16+
Graphic Design Institute
17+
Humongous Insurance
18+
Lakeshore Retail
19+
Lamna Healthcare Company
20+
Liberty's Delightful Sinful Bakery & Cafe
21+
Lucerne Publishing
22+
Margie's Travel
23+
Munson's Pickles and Preserves Farm
24+
Nod Publishers
25+
Northwind Traders
26+
Proseware, Inc.
27+
Relecloud
28+
School of Fine Art
29+
Southridge Video
30+
Tailspin Toys
31+
Tailwind Traders
32+
Trey Research
33+
The Phone Company
34+
VanArsdel, Ltd.
35+
Wide World Importers
36+
Wingtip Toys
37+
Woodgrove Bank
38+
Woodgrove Groceries

quickstarts/ai-agents/ts/data/data.txt

Whitespace-only changes.
Binary file not shown.

quickstarts/ai-agents/ts/data/nifty500QuarterlyResults.csv

Lines changed: 0 additions & 465 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name,revenue,operating_expenses,operating_profit,operating_profit_margin,depreciation,interest,profit_before_tax,tax,net_profit,EPS,profit_TTM,EPS_TTM,industry,sector
2+
"Adatum Corporation","1,057","847.4","192.1","18.48%","12.9","0.7","195.9","49.8","146.1","129.7","535.9","475.7","Technology","Information Technology"
3+
"Adventure Works Cycles","4,644.8","3,885.4","549.3","12.39%","212.8","28.9","517.7","131.5","387.9","20.7","1,202.7","64","Retail","Consumer Discretionary"
4+
"Alpine Ski House","1,357.1","912.7","382.1","29.51%","24.5","7.4","412.5","88.4","323.1","34.3","1,216.1","128.9","Hospitality/Leisure","Consumer Discretionary"
5+
"Bellows College","4,65","4,305.4","325","7.02%","41.3","26.6","276.7","73.8","202.9","7.3","767.5","27.7","Education","Consumer Discretionary"
6+
"Best For You Organics Company","2,956.5","1,026.7","647.7","25.59%","0","1,282.1","533.4","131.5","401.8","6","1,606.2","24","Food & Beverage","Consumer Staples"
7+
"Boulder Innovations","6,951.9","2,982.4","3,664","55.13%","974.5","520.1","2,474.9","759","1,747.8","8.1","6,337","29.3","Technology","Information Technology"
8+
"Contoso","3,766.5","2,169.3","1,504.6","40.95%","432.1","640.8","369.9","84.9","275.9","2.5","1,315.1","11.8","Technology","Information Technology"
9+
"Contoso Pharmaceuticals","3,272.2","2,903.6","322.9","10.01%","388.8","208.4","-228.6","-28.2","-179.2","-1.9","-491.7","-5.2","Health","Healthcare"
10+
"Contoso Suites","1,279.3","1,026.5","208.3","16.87%","34.1","26.6","192","42","127","3.6","509","14.5","Real Estate","Real Estate"
11+
"Consolidated Messenger","1,049.8","737.8","290.7","28.26%","33.7","2.3","275.9","80.6","195.3","15.5","660.2","52.3","Transportation","Industrials"
12+
"Fabrikam","1,605.1","1,386.7","208.2","13.06%","67.6","15.7","135.1","-1.9","136.6","7","531.7","27","Technology","Information Technology"
13+
"Fabrikam Residences","3,503.4","2,693.4","746.7","21.71%","73.9","30.3","648","33.1","620.5","51.9","1,432.9","119.9","Real Estate","Real Estate"
14+
"First Up Consultants","2,988.6","2,556.9","402.5","13.60%","115.7","6.2","309.8","83.5","226.3","13.2","779.8","45.7","Professional services","Industrials"
15+
"Fourth Coffee","7,9","6,122.1","1,301.8","17.54%","380.9","61.2","1,335.7","352.5","793","4","2,777.9","14","Food & Beverage","Consumer Staples"
16+
"Graphic Design Institute","4,869.1","4,219.4","627.5","12.95%","163.4","111.3","376.9","130.2","232.9","16.2","697.5","48.5","Education","Consumer Discretionary"
17+
"Humongous Insurance","6,304.9","5,119.8","1,159.8","18.47%","360.3","132.8","679.9","205.8","474.3","7.5","1,590.7","25","Financial services","Financials"
18+
"Lakeshore Retail","11,463","9,558.6","1,870.4","16.37%","226.6","715.1","924.4","358","526","1.8","2,141.5","7.3","Retail","Consumer Discretionary"
19+
"Lamna Healthcare Company","8,643.8","6,762.3","1,716.2","20.24%","208.7","50.9","1,621.8","418.6","1,205.4","12.6","5,062.6","52.8","Healthcare","Healthcare"
20+
"Liberty's Delightful Sinful Bakery & Cafe","1,376.4","1,142.9","220.1","16.15%","48.7","8","176.8","45.1","131.2","4.9","549.7","20.4","Food & Beverage","Consumer Staples"
21+
"Lucerne Publishing","1,215.8","1,038.5","155.2","13.00%","54","1.9","121.5","32.5","90.3","30.6","392.3","132.9","Publishing","Communication Services"
22+
"Margie's Travel","7,406.4","5,846","1,373.4","19.02%","417.5","68.2","1,074.7","323.7","757.2","12.8","2,325.5","39.7","Entertainment","Communication Services"
23+
"Munson's Pickles and Preserves Farm","1,312","1,184.5","94","7.35%","14.3","0.2","113","30.5","74.2","5.5","336.4","24.7","Food & Beverage","Consumer Staples"
24+
"Nod Publishers","12,661.3","11,619.4","1,005","7.96%","174.4","15.6","851.9","228.6","623.6","9.6","2,332.1","35.8","Publishing","Communication Services"
25+
"Northwind Traders","33,122.2","9,207.3","9,166","33.43%","0","14,749","8,313.8","2,096.1","6,204.1","20.1","13,121","42.6","Transportation","Industrials"
26+
"Proseware","11,206.8","8,708.1","2,130.1","19.65%","91.8","6.5","2,400.4","564","2,02","71.4","6,841.6","241.8","Technology","Information Technology"
27+
"Relecloud","13,381.8","2,851.5","9,449.7","70.63%","158.5","4,537.1","4,757.6","1,207","3,550.8","58.7","13,118.5","216.7","Technology","Information Technology"
28+
"School of Fine Art","26,022.7","14,992.2","9,949.9","38.24%","208.8","4,449.1","5,292","1,536.5","1,929","12.1","7,422.6","46.6","Education","Consumer Discretionary"
29+
"Southridge Video","240.1","33.5","191.2","85.08%","8.4","0.2","197.9","73.9","1,491.2","134","5,545.1","498.3","Entertainment","Communication Services"
30+
"Tailspin Toys","2,360.3","1,720.5","532.7","23.64%","160.4","23.9","455.5","108.1","347.4","18","1,047.5","54.2","Retail","Consumer Discretionary"
31+
"Tailwind Traders","1,649","1,374.6","164.9","10.71%","41.2","17.2","215.9","56.6","166.3","8.2","540.5","26.8","Transportation","Industrials"
32+
"Trey Research","35,766","8,430.4","9,807.9","33.52%","0","17,527.7","6,022.8","1,679.7","4,458.4","8.5","18,602.9","35.9","R&D","Information Technology"
33+
"The Phone Company","16,779.4","3,704.9","3,818.8","25.35%","0","9,255.7","2,977.4","1,488.6","1,498.5","3.6","5,388.7","13.1","Communications","Communication Services"
34+
"VanArsdel","834.6","637.5","181.7","22.18%","81.7","28.4","46.1","12.1","34","2.6","289.7","22.5","Technology","Information Technology"
35+
"Wide World Importers","2,782.6","2,293.7","473.6","17.12%","82.9","21.1","385","96.7","291.6","2.5","1,032.6","8.9","Transportation","Industrials"
36+
"Wingtip Toys","4,146.1","2,994.9","1,014.2","25.30%","108.3","1.5","1,041.5","260.7","789.4","1.1","3,323","4.5","Retail","Consumer Discretionary"
37+
"Woodgrove Bank","3,826.7","3,152.8","621.4","16.47%","211.3","124.3","336.1","121.8","227.2","4.9","783.7","16.8","Financial services","Financials"
205 KB
Loading
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Script: filterCompanies.js
2+
// Description: Reads nifty500QuarterlyResults.csv, filters to company names listed in data/data.txt,
3+
// and removes the NSE_code, BSE_code, sector, and industry columns.
4+
// Usage: npm install csv-parser && node filterCompanies.js
5+
6+
const fs = require('fs');
7+
const path = require('path');
8+
const csv = require('csv-parser');
9+
10+
async function main() {
11+
const dataDir = path.resolve(__dirname, 'data');
12+
const namesFile = path.join(dataDir, 'company_name.csv');
13+
const inputCsv = path.join(dataDir, 'nifty500QuarterlyResults.csv');
14+
const outputCsv = path.join(dataDir, 'nifty500Filtered.csv');
15+
16+
// Read company names from CSV
17+
function loadNames() {
18+
return new Promise((resolve, reject) => {
19+
const list = [];
20+
fs.createReadStream(namesFile)
21+
.pipe(csv())
22+
.on('data', row => {
23+
// adjust header key if different
24+
list.push(row['Company Name'] || row.company_name || row.Name);
25+
})
26+
.on('end', () => resolve(list))
27+
.on('error', reject);
28+
});
29+
}
30+
31+
// Read input rows and keep only specified columns
32+
function loadRows() {
33+
return new Promise((resolve, reject) => {
34+
const out = [];
35+
fs.createReadStream(inputCsv)
36+
.pipe(csv())
37+
.on('data', row => {
38+
// Keep only these five fields
39+
out.push({
40+
name: row.name,
41+
NSE_code: row.NSE_code,
42+
BSE_code: row.BSE_code,
43+
sector: row.sector,
44+
industry: row.industry
45+
});
46+
})
47+
.on('end', () => resolve(out))
48+
.on('error', reject);
49+
});
50+
}
51+
52+
const [names, rows] = await Promise.all([loadNames(), loadRows()]);
53+
if (!rows.length) {
54+
console.error('No input rows loaded.');
55+
process.exit(1);
56+
}
57+
if (!names.length) {
58+
console.error('No company names loaded.');
59+
process.exit(1);
60+
}
61+
62+
// Map names to rows sequentially
63+
rows.forEach((row, idx) => {
64+
if (names[idx]) {
65+
row.name = names[idx];
66+
}
67+
});
68+
69+
// Ensure 'Transportation' industry is represented at least once
70+
if (!rows.some(r => r.industry === 'Transportation')) {
71+
rows[0].industry = 'Transportation';
72+
}
73+
74+
// Write output CSV
75+
const header = Object.keys(rows[0]);
76+
const lines = [header.join(',')];
77+
for (const r of rows) {
78+
const vals = header.map(h => '"' + String(r[h] ?? '').replace(/"/g, '""') + '"');
79+
lines.push(vals.join(','));
80+
}
81+
fs.writeFileSync(outputCsv, lines.join('\n'));
82+
console.log('Replaced names and wrote to', outputCsv);
83+
}
84+
85+
main().catch(err => {
86+
console.error(err);
87+
process.exit(1);
88+
});

0 commit comments

Comments
 (0)