Skip to content

Commit 169b039

Browse files
softchrissinediedChrisDanWahlinmanekinekko
authored
Lessons (#44)
* refactor: prepare for curriculum * chore: copy .vscode folder * docs: adding ch1 (#4) * chore: moving video content to subfolder, adding new README (#3) Co-authored-by: Chris <[email protected]> * adding ch1 * updating lesson * removing files * moved to lessons folder and fixed narrative * adding video * Update lessons/01-intro-to-genai/README.md * adding character demo * update get started * Update lessons/01-intro-to-genai/README.md * Revise Chapter 1 README for clarity and consistency Multiple updates throuughout including shortening some unnecessary parts of the story, adding a little more detail here and there, and telling people where to go to learn more about prompting in the Assignment. * Add code sneak peek section to README Decided we should give people a little more from the technical side so added this "sneak peek" section. * fixing narrative, instructions and more * fix image viewport * fix image viewport * Remove "Getting Started" section from README * removing gen ai videos folder --------- Co-authored-by: Chris <[email protected]> Co-authored-by: Dan Wahlin <[email protected]> * docs: -adding lesson 2 (#7) * first commit lesson 2 * adding lesson * Update 02-first-ai-app/solution/solution.md * Update 02-first-ai-app/solution/solution.md * moved and improved narrative * minor correction * fix image size * fix image size * Update lessons/02-first-ai-app/README.md * bug bash fixes, adding sanple app * adding audio and character demo * adding missing packages * update get started * Update lessons/02-first-ai-app/README.md * fix character instruction --------- Co-authored-by: Chris <[email protected]> * docs: adding lesson 3 (#8) * updating content * updating solution * fixing text and images * Update lessons/03-prompt-engineering/README.md * adding sample app, corrected solution * adding character demo * update get started * Update lessons/03-prompt-engineering/README.md --------- Co-authored-by: Chris <[email protected]> * docs: adding lesson 4 (#9) * adding lesson 4 * Update 04-structured-output/README.md * Update 04-structured-output/README.md * Update 04-structured-output/README.md * fixing text and images * adding CTA * fixing sample * adding character interaction * adding characters app * fixing chat * adding audio * adding audio * fix * Apply suggestions from code review * Apply suggestions from code review * shortening story --------- Co-authored-by: Chris <[email protected]> * docs: add lesson 5 (#6) * docs: add lesson 5 * changing story, adding assets, adding quiz solution * shorten + binding it together better * integrated narrative a bit more * Update lessons/05-rag/README.md * Update lessons/05-rag/README.md * Update lessons/05-rag/README.md * adding character demo * Update lessons/05-rag/README.md * update get started --------- Co-authored-by: Chris <[email protected]> Co-authored-by: chris <[email protected]> * Create README.md (#12) * Create README.md * Update README.md * Update README.md (#13) * Shorten narrative (#14) * shorten, and cleanup * fix broken link * fixing image align and other things * fixing image align and other things * trying a fix * trying a fix * last try * reinstating styles * fixing, adding more text, shrinking images * fixing some more * padding out with more text * moving dinocrates image * moving time beetle image * fixes to ch1-4 * fixes to ch5 * fixes to ch5 * fixes to ch5 * removing all img alignment --------- Co-authored-by: Chris <[email protected]> * Build site (#30) * shorten, and cleanup * fix broken link * fixing image align and other things * fixing image align and other things * trying a fix * trying a fix * last try * reinstating styles * fixing, adding more text, shrinking images * fixing some more * padding out with more text * moving dinocrates image * moving time beetle image * fixes to ch1-4 * fixes to ch5 * fixes to ch5 * fixes to ch5 * github pages site * Add pull request trigger to deploy workflow --------- Co-authored-by: Chris <[email protected]> * Update deploy.yml * Update deploy.yml * Update deploy.yml * Update README.md * docs: update readme (#29) * docs: move images and rewrite video readme * docs: update readme * docs: update readme * docs: update readme * docs: fix links * Update README.md --------- Co-authored-by: chris <[email protected]> * docs: Update root README.md + setup (#34) * Update README.md * improving README and adding a setup directory * improving azure setup * adding setup steps * improving setup file --------- Co-authored-by: Chris <[email protected]> * Update README.md * Update getting-started-azure-openai.md * Update getting-started-azure-openai.md * feature: one app v2 (#32) * shorten, and cleanup * fix broken link * adding app * created an app that can be reused for all characters * fixing issue * adding speech * adding voices to the characters * making voice opt in via checkbox * chore: update one app (wip) * fixed bug, system message wasn't updated * feat: load character from URL * feat: improve chat conversation UI * feat: use custom avatars * chore: minor typo * cleaning up, removing template, fix bug with cancelling speech --------- * switch out chat app image (#36) * switch out chat app image * changed to chat image for an updated one * Update README.md (#35) * Update README.md * adding changes * changes * adding video description sentence * fixing navigation * docs: update lessons with slides (#39) * Update README.md * adding pptx, descriptions and slides per lesson * Update README.md * Update solution.md * Update README.md * Update README.md (#40) * Update README.md * Update README.md * adding disclaimer to app for responsible AI * Softchris patch 9 (#41) * Update README.md * Update README.md * adding disclaimer to app for responsible AI * add link to resp AI principles * docs: peer review updates (#42) * Update README.md * fixing a lot of small things * smaller fixes * docs: update README.md (#43) #9 tools and services - in table - has wrong links * docs: fix links * Update README.md * Update README.md --------- Co-authored-by: sinedied <[email protected]> Co-authored-by: Chris <[email protected]> Co-authored-by: Dan Wahlin <[email protected]> Co-authored-by: Wassim Chegham <[email protected]> Co-authored-by: Dina Berry (MSFT) <[email protected]>
1 parent 96b71ff commit 169b039

File tree

181 files changed

+10572
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+10572
-88
lines changed

.devcontainer/devcontainer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
33
{
4-
"name": "ollama-js",
4+
"name": "genai-js",
55

66
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
77
"image": "mcr.microsoft.com/devcontainers/javascript-node:20-bullseye",
@@ -24,7 +24,7 @@
2424
}
2525
},
2626

27-
"postCreateCommand": "npm install -g ollamazure tsx; cd demos && npm install",
27+
"postCreateCommand": "npm install -g ollamazure tsx; npm install; cd videos/demos && npm install",
2828

2929
// Set minimal host requirements for the container.
3030
"hostRequirements": {

.github/workflows/deploy.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
- name: Install dependencies
15+
run: npm install
16+
17+
- name: Build project
18+
run: npm run build
19+
20+
- name: Deploy to GitHub Pages
21+
uses: peaceiris/actions-gh-pages@v3
22+
with:
23+
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
publish_dir: ./dist

.vscode/settings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"code-runner.executorMap": {
3-
"typescript": "cd demos && dotenv run -- tsx",
4-
"javascript": "cd demos && dotenv run -- node",
3+
"typescript": "tsx",
4+
"javascript": "node",
55
},
66
"code-runner.clearPreviousOutput": true,
77
"code-runner.saveFileBeforeRun": true,

README.md

+104-84
Large diffs are not rendered by default.

app/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
This app allows you to speak to all character features in the curriculum.
2+
3+
## Installation
4+
5+
1. Start a GitHub Codespaces
6+
1. Run `npm install`
7+
1. Run `npm start`
8+
1. Open `http://localhost:3000`
9+
10+
You should see something like:
11+
12+
![Chat app](../character-chat.png)
13+
14+
## Speak to a character
15+
16+
You're faced with a text input field. Type your message and see the response from the character you are speaking to.
17+
18+
## Change character
19+
20+
Select the dropdown to change the character you are speaking to.
21+
22+
## Change the character behavior
23+
24+
In `characters.json`, there's a `description` property that will be used as a system message. If you change this, the characters personality will change.
25+
26+
## Please read
27+
28+
> [!IMPORTANT]
29+
> DISCLAIMER: This repository contains fictional content generated by AI. The historical characters depicted here are speaking back thanks to generative AI, which is based on training data. Any utterances made by these characters do not represent their actual views or quotes. This content is intended solely for entertainment purposes. [Microsoft Responsible AI principles here](https://www.microsoft.com/en-us/ai/principles-and-approach/)

app/app.js

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import express from 'express';
2+
import { OpenAI } from 'openai';
3+
import path from 'path';
4+
import { fileURLToPath } from 'url';
5+
import dotenv from 'dotenv';
6+
7+
import json from './public/characters.json' with { type: "json" };
8+
9+
let systemMessage = json[4].description;
10+
let page = json[4].page;
11+
12+
console.log("SERVER systemMessage: ", systemMessage);
13+
console.log("SERVER page: ", page);
14+
15+
dotenv.config();
16+
17+
const app = express();
18+
const port = process.env.PORT || 3000;
19+
20+
const __filename = fileURLToPath(import.meta.url);
21+
const __dirname = path.dirname(__filename);
22+
23+
app.use(express.json());
24+
25+
// Serve static files from the 'public' directory
26+
app.use(express.static(path.join(__dirname, 'public')));
27+
28+
app.locals.delimiters = '{{ }}';
29+
30+
function getCharacterByName(name) {
31+
for(let i=0; i< json.length; i++) {
32+
if(json[i].name == name) {
33+
return json[i];
34+
35+
}
36+
}
37+
return null;
38+
}
39+
40+
// Route to send the prompt
41+
app.post('/send', async (req, res) => {
42+
const { message, character } = req.body;
43+
44+
systemMessage = character.description;
45+
46+
const prompt = message;
47+
48+
const messages = [
49+
{
50+
"role": "system",
51+
"content": systemMessage,
52+
},
53+
{
54+
"role": "user",
55+
"content": prompt
56+
}
57+
];
58+
59+
const openai = new OpenAI({
60+
baseURL: "https://models.inference.ai.azure.com", // might need to change to this url in the future: https://models.github.ai/inference
61+
apiKey: process.env.GITHUB_TOKEN,
62+
});
63+
64+
try {
65+
console.log(`SERVER sending prompt ${prompt}`)
66+
const completion = await openai.chat.completions.create({
67+
model: 'gpt-4o-mini',
68+
messages: messages,
69+
});
70+
71+
console.log(`SERVER: ${completion.choices[0]?.message?.content}`);
72+
res.json({
73+
prompt: prompt,
74+
answer: completion.choices[0]?.message?.content
75+
});
76+
} catch (error) {
77+
console.log(`Error: ${error}`);
78+
res.status(500).json({ error: error });
79+
}
80+
});
81+
82+
app.listen(port, () => {
83+
console.log(`Server is running on http://localhost:${port}`);
84+
});

0 commit comments

Comments
 (0)