Skip to content

Commit c7908e4

Browse files
committed
AskME README instructions (usage and terraform deployment)
Refactoring, better error handling Default GenAI model change Signed-off-by: majolr <[email protected]>
1 parent 7ffd4ea commit c7908e4

31 files changed

+437
-187
lines changed

askme/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,49 @@ AskME is a suite of features designed to empower users to maximize the potential
1313

1414
5. Knowledge Base Management: Users can create and delete the vector tables.
1515

16+
## Prerequisite
17+
18+
You must have an OCI account. [Click here](https://docs.oracle.com/en/cloud/paas/content-cloud/administer/create-and-activate-oracle-cloud-account.html) for more information about Oracle Cloud account creation and activation. Free-tier accounts are currently not supported for the deployment of AskME resources.
19+
20+
There are required OCI resources (see the [Terraform documentation](./terraform/README.md) for more information) that are needed for this tutorial.
21+
22+
## Getting Started: answer questions using your documents
23+
24+
### Create a vector table
25+
26+
In the AskME app, it is easy to use your documents to create a new vector table.
27+
28+
<div style="text-align: center;" >
29+
<img src="assets/askme_kb_interface.png" alt="AskME Knowledge Base interface" width="72%" >
30+
</div>
31+
32+
From the `Knowledge Base Management` tab (${\textsf{\color{red}1}}$), under `Create Vector Table` (${\textsf{\color{red}2}}$), you can choose to upload one or more documents to AskME (${\textsf{\color{red}3}}$):
33+
- Here is a sample document you can download and use for that purpose: [Onboarding Checklist for New Hires at Nexus Innovations.pdf](./assets/Onboarding%20Checklist%20for%20New%20Hires%20at%20Nexus%20Innovations.pdf)<br />
34+
- Feel free to use your own documents to try the vector table creation.
35+
36+
After having browsed and selected the relevant files, you can change the vector table name if the default one does not match your needs (${\textsf{\color{red}4}}$).<br />
37+
This name will be used to identify the vector table, and may correspond to the common denominator of all selected files.
38+
39+
Then click on the `Upload` button to start the vector table creation process (${\textsf{\color{red}5}}$).<br />
40+
For the sample document provided earlier, this process should take 30-60 seconds. It may take several minutes if multiple files/bigger files are selected.
41+
42+
Once the vector table has been created, a green message is displayed, explaining that the table creation was successful, and the new table name should be added to the `Selected Vector Tables` list (${\textsf{\color{red}6}}$).
43+
<br />
44+
45+
### Use the vector table to answer questions
46+
47+
Any existing vector table can be used in AskME to generate an accurate answer, with references to the original documents.
48+
49+
<div style="text-align: center;" >
50+
<img src="assets/askme_answer_interface.png" alt="AskME free-style answer" width="72%" >
51+
</div>
52+
53+
From the `Free-style Answer` tab (${\textsf{\color{red}1}}$), you can enter your question in the input field (${\textsf{\color{red}3}}$).<br />
54+
Here, we choose to ask a question related to the sample document uploaded in the previous section: *What are the onboarding steps for new hires at Nexus Innovation?*
55+
56+
Please make sure that all vector tables needed for the question are selected in the Knowledge Base Selection area (${\textsf{\color{red}2}}$), and then you can click on the `Answer Question` button (${\textsf{\color{red}4}}$).
57+
58+
The answer should appear under the `Answer Question` button after a few seconds, followed by a clickable list of document references that have been used to generate the answer.
1659

1760
## Contributing
1861

askme/askme.py

Lines changed: 161 additions & 167 deletions
Large diffs are not rendered by default.
202 KB
Loading
193 KB
Loading
212 KB
Loading

askme/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
RETRIEVAL_NUM_CHUNK_AFTER = 1
2121
SUMMARY_MAX_PROMPT_SIZE = 12000 # characters
2222
ML_RAG_SEGMENT_OVERLAP = 2
23-
DEFAULT_LLM_MODEL = "meta.llama-3.1-70b-instruct"
23+
DEFAULT_LLM_MODEL = "meta.llama-3.3-70b-instruct"
2424
ANSWER_SUMMARY_PROMPT = """
2525
You are a data summarizer. I will provide you with a question and relevant context data. Your task is to summarize the parts of the context that are most relevant to answering the question.
2626

askme/styles/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ div.stButton > button {
1212
}
1313
.stMultiSelect [data-baseweb="tag"] div {
1414
margin-right: 8px !important;
15+
}
16+
17+
[data-testid="stBaseButton-secondaryFormSubmit"] {
18+
width: 100%;
1519
}

askme/terraform/README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=oracle-devrel_tech-content-heatwave)](https://sonarcloud.io/dashboard?id=oracle-devrel_tech-content-heatwave)
2+
3+
# Deploy AskME resources with terraform
4+
5+
This section explains how to deploy AskME in your tenancy, using the OCI Cloud Shell and terraform. The following resources are automatically created during the process:
6+
- A dynamic group and a policy in the root compartment
7+
- A Compartment for the AskME resources
8+
- An Object Storage bucket containing two documents
9+
- A Compute Instance to run the AskME app
10+
- A MySQL DBSystem with a HeatWave cluster
11+
- A Vault, a Vault key and three Vault secrets
12+
- A VCN with an Internet Gateway, two Security Lists and two Subnets
13+
14+
The application can then be accessed from your local machine, using local port forwarding, as detailed in [step 8](#step-8-use-askme).
15+
16+
## Step 1: Open OCI Cloud Shell
17+
Sign In to [your OCI tenancy](http://cloud.oracle.com/), switch to a [region supporting OCI Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/overview.htm#regions) (e.g: US Midwest), and open the Cloud Shell.
18+
You need to have the [Administrator role](https://docs.oracle.com/en-us/iaas/Content/Identity/roles/understand-administrator-roles.htm) to deploy the AskME resources in your tenancy.
19+
20+
![OCI starting page](assets/oci_home_page.png)
21+
22+
![OCI starting page, developer tools](assets/oci_home_page_dev_tools.png)
23+
24+
![OCI starting page, cloud shell](assets/oci_home_page_cloud_shell.png)
25+
26+
## Step 2: Get the repository archive
27+
In the Cloud Shell interface, fetch the tech-content-heatwave repository archive.
28+
29+
Command:
30+
```
31+
wget -O tech-content-heatwave.zip -nv https://github.com/oracle-devrel/tech-content-heatwave/archive/refs/heads/tech-content-heatwave_askme.zip
32+
```
33+
34+
## Step 3: Unzip the archive
35+
Command:
36+
```
37+
unzip tech-content-heatwave.zip '*/askme/*' -d tech-content-heatwave
38+
```
39+
40+
## Step 4: Change directory to the terraform folder
41+
Command:
42+
```
43+
cd tech-content-heatwave/*/askme/terraform
44+
```
45+
46+
## Step 5 (optional): Create a screen session to run terraform
47+
Command:
48+
```
49+
screen -S askme_session
50+
```
51+
52+
## Step 6: Run the setup script
53+
Run the script `askme_setup.sh`, and follow the instructions. Additional information will be asked by the script to setup the DBSystem and the compute instance.
54+
55+
Command:
56+
```
57+
sh askme_setup.sh
58+
```
59+
60+
![Cloud Shell: Run deployment script](assets/cloud_shell_script.png)
61+
62+
### Step 6.a: Compartment name
63+
64+
Name of the AskME demo compartment to create (default: `heatwave-genai-askme`).
65+
66+
If your tenancy already contains a compartment with the default name `heatwave-genai-askme`, please provide another compartment name and press Enter. Otherwise, no need to provide a value, press Enter and the default value will be used.
67+
68+
![Deployment script: compartment input parameter](assets/cloud_shell_script_compartment.png)
69+
70+
71+
### Step 6.b: Allowed IPv4 CIDR block
72+
73+
Set of IPv4 addresses (CIDR notation) allowed to connect to the compute instance.
74+
75+
The CIDR notation follows the format: `a.b.c.d/e` where `a`, `b`, `c` and `d` are numbers between 0 and 255, and `e` is a number between 0 and 32. More information about the CIDR block notation in the [Network Overview](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/overview.htm#:~:text=CIDR%20NOTATION) page.
76+
77+
Use `0.0.0.0/0` to indicate all IP addresses. The prefix is required (for example, include the /32 if specifying an individual IP address). For more information, check the [Security Rules](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/securityrules.htm) page.
78+
79+
![Deployment script: IPv4 CIDR block input parameter](assets/cloud_shell_script_ip_cidr.png)
80+
81+
### Step 6.c: SSH authorized key
82+
83+
Content of the SSH public key file (OpenSSH format) located in your local machine. More information about SSH keys in the [Key Pair management and generation](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/managingkeypairs.htm) page.
84+
85+
![Deployment script: SSH authorized key input parameter](assets/cloud_shell_script_ssh.png)
86+
87+
## Step 7: Resource deployment
88+
Wait until the terraform deployment finishes. Expected deployment time: 30-40 minutes.
89+
90+
## Step 8: Use AskME
91+
Connect to the AskME compute instance and access the streamlit page.
92+
Follow the instructions provided in the Cloud Shell output. The instructions should look similar to this:
93+
```
94+
================================================
95+
Open a terminal in your local computer, and run:
96+
ssh -L 8501:localhost:8501 [email protected]
97+
Then in your web browser, open the URL:
98+
127.0.0.1:8501
99+
================================================
100+
```
101+
102+
This information can be displayed again with the command `sh askme_output.sh` from the location described in [step 4](#step-4-change-directory-to-the-terraform-folder).
103+
104+
105+
# Cleanup AskME resources with terraform
106+
107+
This section explains how to remove AskME resources from your tenancy, using the OCI Cloud Shell and terraform.
108+
109+
#### Warning: Cleanup setup requirement
110+
Please make sure that the AskME resources have been created following the [deployment instructions](#deploy-askme-resources-with-terraform), and that the setup folders/files located in [deployment step 4](#step-4-change-directory-to-the-terraform-folder) have not been modified or removed since the last deployment.
111+
112+
More specifically, please make sure that the file `terraform.tfstate` still exists there. If not, all resources described in the [deployment instructions](#deploy-askme-resources-with-terraform) need to be removed manually.
113+
114+
#### Warning: Cleanup retention period
115+
There is a retention period of 30 days before the OCI Vault can be removed, blocking the compartment deletion. Please rerun the [cleanup step 2](#step-2-run-the-cleanup-script) again after 30 days to complete the cleanup process.
116+
117+
## Step 1: Remove Vector Tables in the AskME app (if any)
118+
Follow the instructions in [step 8](#step-8-use-askme) to access the streamlit page.
119+
In the `Knowledge Base Management` tab, go to the section `Reset Knowledge Base` and follow the page instructions to remove all vector store tables.
120+
121+
![Remove Vector Tables from AskME](assets/askme_reset_kb.png)
122+
123+
## Step 2: Run the cleanup script
124+
Follow the instructions in [deployment step 1](#step-1-open-oci-cloud-shell) and [deployment step 4](#step-4-change-directory-to-the-terraform-folder) to use the Cloud Shell from the right location.
125+
126+
Run the script `sh askme_cleanup.sh`, and follow the instructions. Additional information will be asked by the script to choose the right compartment name.
127+
128+
Command:
129+
```
130+
sh askme_cleanup.sh
131+
```
132+
133+
![Cloud Shell: Run deployment script](assets/cloud_shell_script_cleanup.png)
134+
135+
### Step 2.a: Compartment name
136+
137+
Name of the AskME demo compartment to delete (default: `heatwave-genai-askme`).
138+
139+
If you used a custom compartment name in [deployment step 6.a](#step-6a-compartment-name), please provide the same compartment name here and press Enter. Otherwise, no need to provide a value, press Enter and the default value will be used.
140+
141+
![Cleanup script: compartment input parameter](assets/cloud_shell_script_compartment.png)
142+
143+
144+
# Troubleshooting
145+
146+
## Compartment already exists
147+
148+
![Troubleshooting: compartment already exists](assets/troubleshooting_compartment_exists.png)
149+
150+
If the compartment already exists in your tenancy, please rerun the [step 6](#step-6-run-the-setup-script) and specify another compartment name in [step 6.a](#step-6a-compartment-name).
151+
152+
## Current OCI region does not support Generative AI
153+
154+
![Troubleshooting: region does not support GenAI](assets/troubleshooting_region_genai_support.png)
155+
156+
Please close the current Cloud Shell session:
157+
158+
![Exit Cloud Shell](assets/cloud_shell_exit.png)
159+
160+
![Exit Cloud Shell Confirm](assets/cloud_shell_exit_confirm.png)
161+
162+
Then change the OCI Console region to a [region supporting OCI Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/overview.htm#regions) (e.g: US Midwest):
163+
164+
![Change OCI Region](assets/oci_home_page_change_region.png)
165+
166+
Then reopen the Cloud Shell ([step 1](#step-1-open-oci-cloud-shell)) and in the same folder as in [step 4](#step-4-change-directory-to-the-terraform-folder), please rerun [step 6](#step-6-run-the-setup-script).
167+
168+
## Compartment name length must be between 4 and 20
169+
170+
![Troubleshooting: bad compartment name format](assets/troubleshooting_compartment_name_format.png)
171+
172+
Please rerun [step 6](#step-6-run-the-setup-script) and use a smaller/longer compartment name in [step 6.a](#step-6a-compartment-name).
173+
174+
## Invalid IPv4 CIDR block notation
175+
176+
![Troubleshooting: bad IPv4 CIDR format](assets/troubleshooting_cidr_format.png)
177+
178+
Please rerun [step 6](#step-6-run-the-setup-script) and provide a valid IPv4 block range in [step 6.b](#step-6b-allowed-ipv4-cidr-block), following the CIDR block notation.
179+
180+
More information about the CIDR block notation in the [Network Overview](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/overview.htm#:~:text=CIDR%20NOTATION) page.
181+
182+
## The SSH public key value must follow the OpenSSH format
183+
184+
![Troubleshooting: bad SSH public key format](assets/troubleshooting_ssh_key_format.png)
185+
186+
Please rerun [step 6](#step-6-run-the-setup-script) and provide a valid SSH public key in [step 6.c](#step-6c-ssh-authorized-key), following the OpenSSH format.
187+
188+
More information about SSH keys in the [Key Pair management and generation](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/managingkeypairs.htm) page.

askme/terraform/askme_output.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License (UPL), Version 1.0.
4+
5+
set -e # Exit script if any command fails
6+
7+
terraform init >/dev/null
8+
public_ip=`terraform output -json askme_instance_public_ip 2>/dev/null || echo ""`
9+
public_ip=`echo $public_ip | tr -d '"'`
10+
if [ -z "$public_ip" ]
11+
then
12+
echo "No terraform resource detected.."
13+
echo "Please run the deployment instructions to create the resources."
14+
else
15+
echo "================================================"
16+
echo "Open a terminal in your local computer, and run:"
17+
echo " ssh -L 8501:localhost:8501 opc@$public_ip"
18+
echo "Then in your web browser, open the URL:"
19+
echo " 127.0.0.1:8501"
20+
echo "================================================"
21+
fi

askme/terraform/askme_setup.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@ set -e # Exit script if any command fails
66

77
terraform init
88
TF_VAR_TENANCY=$OCI_TENANCY TF_VAR_REGION=$OCI_REGION terraform apply -auto-approve
9-
public_ip=`terraform output -raw askme_instance_public_ip`
10-
echo "================================================"
11-
echo "Open a terminal in your local computer, and run:"
12-
echo " ssh -L 8501:localhost:8501 opc@$public_ip"
13-
echo "Then in your web browser, open the URL:"
14-
echo " 127.0.0.1:8501"
15-
echo "================================================"
9+
sh askme_output.sh

0 commit comments

Comments
 (0)