Skip to content

Commit 0882afb

Browse files
author
pjsingh28
authored
Merge pull request #648 from MicrosoftDocs/test_styles
Test styles
2 parents 9d1dccf + 2392954 commit 0882afb

File tree

23 files changed

+684
-1370
lines changed

23 files changed

+684
-1370
lines changed

scenarios/ConfigurePythonContainer/configure-python-container.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Results:
9999
}
100100
```
101101

102-
## Step 2: Show the current Python version
102+
## Show the current Python version
103103

104104
The following command retrieves the Python runtime version currently used by your Azure App Service.
105105

@@ -115,7 +115,7 @@ Results:
115115
"PYTHON|3.10"
116116
```
117117

118-
## Step 3: Set the desired Python version
118+
## Set the desired Python version
119119

120120
Update your Azure App Service instance to use a specific Python version. Replace the desired Python version (e.g., "PYTHON|3.11") as needed.
121121

@@ -124,6 +124,7 @@ export DESIRED_PYTHON_VERSION="PYTHON|3.11"
124124
az webapp config set --resource-group $RESOURCE_GROUP --name $APP_NAME --linux-fx-version $DESIRED_PYTHON_VERSION
125125
```
126126

127+
## Verify Version
127128
Verify the updated Python version:
128129

129130
```bash
@@ -138,7 +139,7 @@ Results:
138139
"PYTHON|3.11"
139140
```
140141

141-
## Step 4: List all supported Python runtime versions
142+
## List all supported Python runtime versions
142143

143144
Use the following command to view all Python versions supported by Azure App Service on Linux.
144145

scenarios/CreateAKSWebApp/create-aks-webapp.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,18 @@ Cert-manager provides Helm charts as a first-class method of installation on Kub
486486

487487
```bash
488488
helm repo add jetstack https://charts.jetstack.io
489+
helm repo update
490+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v1.7.0
489491
```
490492

491493
2. Update local Helm Chart repository cache
492494

493495
```bash
494-
helm repo update
495496
```
496497

497498
3. Install Cert-Manager addon via helm by running the following:
498499

499500
```bash
500-
helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v1.7.0
501501
```
502502

503503
4. Apply Certificate Issuer YAML File
@@ -538,9 +538,6 @@ Cert-manager provides Helm charts as a first-class method of installation on Kub
538538
nodeSelector:
539539
"kubernetes.io/os": linux
540540
EOF
541-
```
542-
543-
```bash
544541
cluster_issuer_variables=$(<cluster-issuer-prod.yml)
545542
```
546543

scenarios/ObtainPerformanceMetricsLinuxSustem/obtain-performance-metrics-linux-system.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ The metrics collected are:
573573
* Look for single processes with high read/write rates per second. This information is a guidance for processes with I/O more than identifying issues.
574574
Note: the `--human` option can be used to display numbers in human readable format (that is, `Kb`, `Mb`, `GB`).
575575

576-
### `ps`
576+
### Top CPU processes
577577

578578
Lastly `ps` command displays system processes, and can be either sorted by CPU or Memory.
579579

@@ -599,6 +599,7 @@ root 2186 42.0 0.0 73524 5836 pts/1 R+ 16:55 0:06 stress-ng --c
599599
root 2191 41.2 0.0 73524 5592 pts/1 R+ 16:55 0:06 stress-ng --cpu 12 --vm 2 --vm-bytes 120% --iomix 4 --timeout 240
600600
```
601601

602+
## Top memory processes
602603
To sort by `MEM%` and obtain the top 10 processes:
603604

604605
```azurecli-interactive
@@ -634,13 +635,4 @@ echo "$extracted"
634635

635636
To run, you can create a file with the above contents, add execute permissions by running `chmod +x gather.sh`, and run with `sudo ./gather.sh`.
636637

637-
This script saves the output of the commands in a file located in the same directory where the script was invoked.
638-
639-
Additionally, all the commands in the bash block codes covered in this document, can be run through `az-cli` using the run-command extension, and parsing the output through `jq` to obtain a similar output to running the commands locally: `
640-
641-
```azurecli-interactive
642-
output=$(az vm run-command invoke -g $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --command-id RunShellScript --scripts "ls -l /dev/disk/azure")
643-
value=$(echo "$output" | jq -r '.value[0].message')
644-
extracted=$(echo "$value" | awk '/\[stdout\]/,/\[stderr\]/' | sed '/\[stdout\]/d' | sed '/\[stderr\]/d')
645-
echo "$extracted"
646-
```
638+
This script saves the output of the commands in a file located in the same directory where the script was invoked.

scenarios/PostgresRAGLLM/app.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

scenarios/PostgresRAGLLM/chat.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from db import VectorDatabase
99

1010
# Configure logging
11-
logging.basicConfig(level=logging.DEBUG)
11+
logging.basicConfig(level=logging.INFO)
1212

1313
parser = argparse.ArgumentParser()
1414
parser.add_argument('--api-key', dest='api_key', type=str)
@@ -18,13 +18,11 @@
1818
parser.add_argument('--pgpassword', dest='pgpassword', type=str)
1919
parser.add_argument('--pgdatabase', dest='pgdatabase', type=str)
2020
parser.add_argument('--populate', dest='populate', action="store_true")
21-
parser.add_argument('--question', dest='question', type=str, help="Question to ask the chatbot")
2221
args = parser.parse_args()
2322

2423

2524
class ChatBot:
2625
def __init__(self):
27-
logging.debug("Initializing ChatBot")
2826
self.db = VectorDatabase(pguser=args.pguser, pghost=args.phhost, pgpassword=args.pgpassword, pgdatabase=args.pgdatabase)
2927
self.api = AzureOpenAI(
3028
azure_endpoint=args.endpoint,
@@ -39,21 +37,17 @@ def __init__(self):
3937
)
4038

4139
def load_file(self, text_file: str):
42-
logging.debug(f"Loading file: {text_file}")
40+
logging.info(f"Loading file: {text_file}")
4341
with open(text_file, encoding="UTF-8") as f:
4442
data = f.read()
4543
chunks = self.text_splitter.create_documents([data])
4644
for i, chunk in enumerate(chunks):
4745
text = chunk.page_content
4846
embedding = self.__create_embedding(text)
4947
self.db.save_embedding(i, text, embedding)
50-
51-
def __create_embedding(self, text: str):
52-
logging.debug(f"Creating embedding for text: {text[:30]}...")
53-
return self.api.embeddings.create(model="text-embedding-ada-002", input=text).data[0].embedding
48+
logging.info("Done loading data.")
5449

5550
def get_answer(self, question: str):
56-
logging.debug(f"Getting answer for question: {question}")
5751
question_embedding = self.__create_embedding(question)
5852
context = self.db.search_documents(question_embedding)
5953

@@ -80,26 +74,21 @@ def get_answer(self, question: str):
8074
)
8175
return response.choices[0].message.content
8276

77+
def __create_embedding(self, text: str):
78+
return self.api.embeddings.create(model="text-embedding-ada-002", input=text).data[0].embedding
79+
8380

8481
def main():
8582
chat_bot = ChatBot()
8683

8784
if args.populate:
88-
logging.debug("Loading embedding data into database...")
8985
chat_bot.load_file("knowledge.txt")
90-
logging.debug("Done loading data.")
91-
return
92-
93-
if args.question:
94-
logging.debug(f"Question provided: {args.question}")
95-
print(chat_bot.get_answer(args.question))
96-
return
97-
98-
while True:
99-
q = input("Ask a question (q to exit): ")
100-
if q == "q":
101-
break
102-
print(chat_bot.get_answer(q))
86+
else:
87+
while True:
88+
q = input("Ask a question (q to exit): ")
89+
if q == "q":
90+
break
91+
print(chat_bot.get_answer(q))
10392

10493

10594
if __name__ == "__main__":

scenarios/PostgresRAGLLM/postgres-rag-llm.md

Lines changed: 6 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -136,101 +136,12 @@ pip install -r requirements.txt
136136
python chat.py --populate --api-key $API_KEY --endpoint $ENDPOINT --pguser $PGUSER --phhost $PGHOST --pgpassword $PGPASSWORD --pgdatabase $PGDATABASE
137137
```
138138

139-
## Set up Web Interface
139+
## Run Chat bot
140140

141-
Create a simple web interface for the chatbot using Flask.
142-
143-
1. **Install Flask**
144-
145-
```bash
146-
pip install Flask
147-
```
148-
149-
2. **Create `app.py`**
150-
151-
Create a file named `app.py` in the `scenarios/PostgresRagLlmDemo` directory with the following content:
152-
153-
```python
154-
from flask import Flask, request, render_template
155-
import subprocess
156-
import os
157-
158-
app = Flask(__name__)
159-
160-
@app.route('/', methods=['GET'])
161-
def home():
162-
return render_template('index.html', response='')
163-
164-
@app.route('/ask', methods=['POST'])
165-
def ask():
166-
question = request.form['question']
167-
result = subprocess.run([
168-
'python', 'chat.py',
169-
'--api-key', os.getenv('API_KEY'),
170-
'--endpoint', os.getenv('ENDPOINT'),
171-
'--pguser', os.getenv('PGUSER'),
172-
'--phhost', os.getenv('PGHOST'),
173-
'--pgpassword', os.getenv('PGPASSWORD'),
174-
'--pgdatabase', os.getenv('PGDATABASE'),
175-
'--question', question
176-
], capture_output=True, text=True)
177-
response = result.stdout
178-
return render_template('index.html', response=response)
179-
180-
if __name__ == '__main__':
181-
app.run(host='0.0.0.0', port=5000)
182-
```
183-
184-
3. **Create `index.html`**
185-
186-
Create a `templates` directory inside `scenarios/PostgresRagLlmDemo` and add an `index.html` file with the following content:
187-
188-
```html
189-
<!doctype html>
190-
<html lang="en">
191-
<head>
192-
<title>Chatbot Interface</title>
193-
</head>
194-
<body>
195-
<h1>Ask about Zytonium</h1>
196-
<form action="/ask" method="post">
197-
<input type="text" name="question" required>
198-
<button type="submit">Ask</button>
199-
</form>
200-
<pre>{{ response }}</pre>
201-
</body>
202-
</html>
203-
```
204-
205-
4. **Run the Web Server**
206-
207-
Ensure that all environment variables are exported and then run the Flask application:
208-
209-
```bash
210-
export API_KEY="$API_KEY"
211-
export ENDPOINT="$ENDPOINT"
212-
export PGUSER="$PGUSER"
213-
export PGHOST="$PGHOST"
214-
export PGPASSWORD="$PGPASSWORD"
215-
export PGDATABASE="$PGDATABASE"
216-
217-
python app.py
218-
```
219-
220-
The web interface will be accessible at `http://localhost:5000`. You can ask questions about Zytonium through the browser.
221-
222-
## Next Steps
223-
224-
- Explore more features of [Azure Cognitive Search](https://learn.microsoft.com/azure/search/search-what-is-azure-search).
225-
- Learn how to [use Azure OpenAI with your data](https://learn.microsoft.com/azure/cognitive-services/openai/use-your-data).
226-
<!-- ## Run Chat bot
227-
228-
This final step initializes the chatbot in your terminal. You can ask it questions about Zytonium and it will use the embeddings in the postgres database to augment your query with relevant context before sending it to the LLM model.
229-
230-
```bash
231-
echo "Ask the chatbot a question about Zytonium!"
232-
```
141+
To run the chatbot, paste this following command to the terminal: `cd ~/scenarios/PostgresRagLlmDemo && python chat.py --api-key $API_KEY --endpoint $ENDPOINT --pguser $PGUSER --phhost $PGHOST --pgpassword $PGPASSWORD --pgdatabase $PGDATABASE`
233142

234143
```bash
235-
python chat.py --api-key $API_KEY --endpoint $ENDPOINT --pguser $PGUSER --phhost $PGHOST --pgpassword $PGPASSWORD --pgdatabase $PGDATABASE
236-
``` -->
144+
echo "
145+
To run the chatbot, see the last step for more info.
146+
"
147+
```
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
azure-identity==1.17.1
22
openai==1.55.3
33
psycopg2==2.9.9
4-
langchain-text-splitters==0.2.2
5-
Flask==2.3.2
4+
langchain-text-splitters==0.2.2

scenarios/PostgresRAGLLM/templates/index.html

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)