Skip to content
Merged
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
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sbin/**
**/chatbot_graph.png
**/*.sh
**/etc/*.json
**/optimizer_settings.json
!opentofu/**/cloudinit-oke.sh
!src/entrypoint.sh
!src/client/spring_ai/templates/env.sh
Expand All @@ -22,7 +23,7 @@ tests/db_startup_temp/**
##############################################################################
# Environment (PyVen, IDE, etc.)
##############################################################################
**/.venv
**/.*env*
**/.vscode
**/.DS_Store
**/*.swp
Expand Down Expand Up @@ -51,6 +52,11 @@ __pycache__/
opentofu/**/stage/*.*
opentofu/**/stage/kubeconfig

##############################################################################
# AI Code Assists
##############################################################################
**/*[Cc][Ll][Aa][Uu][Dd][Ee]*

##############################################################################
# Helm
##############################################################################
Expand All @@ -61,12 +67,8 @@ helm/values*.yaml
##############################################################################
# Random
##############################################################################
spring_ai/src/main/resources/data/optimizer_settings.json
spring_ai/target/**
spring_ai/create_user.sql
spring_ai/drop.sql
src/client/spring_ai/target/classes/*
api_server_key
.env

optimizer_settings.json
4 changes: 2 additions & 2 deletions docs/content/client/api_server/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ The {{< full_app_ref >}} is powered by an API Server to allow for any client to

Each client connected to the API Server, including those from the {{< short_app_ref >}} GUI client, share the same configuration but maintain their own settings. Database, Model, OCI, and Prompt configurations are used across all clients; but which database, models, OCI profile, and prompts set are specific to each client.

When started as part of the {{< short_app_ref >}} "All-in-One" deployment, you can change the Port it listens on and the API Server Key. A restart is required for the changes to take effect.
When started as part of the {{< short_app_ref >}} "All-in-One" deployment, by setting `API_SERVER_CONTROL=TRUE` before startup, you can change the Port it listens on and the API Server Key.

![Server Configuration](images/api_server_config.png)

If the API Server is started independently of the {{< short_app_ref >}} client, the configuration is shown, but cannot be modified from the client.

## Server Configuration

During the startup of the API Server, a `server` client is created and populated with minimal settings. The `server` client is the default when calling the API Server outside of the {{< short_app_ref >}} GUI client. To copy your {{< short_app_ref >}} GUI client settings to the `server` client for use with external application clients, click the "Copy AI Optimizer Settings".
During the startup of the API Server, a `server` client is created and populated with minimal settings. The `server` client is the default when calling the API Server outside of the {{< short_app_ref >}} GUI client. To copy your {{< short_app_ref >}} GUI client settings to the `server` client for use with external application clients, click the "Copy Client Settings".

![Server Settings](images/api_server_settings.png)

Expand Down
Binary file modified docs/content/client/api_server/images/api_server_activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/api_server/images/api_server_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/api_server/images/api_server_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/chatbot/images/chatbot_history_context.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/chatbot/images/language_parameters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/configuration/images/database_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/configuration/images/models_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/configuration/images/models_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/configuration/images/oci_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/configuration/images/settings_upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 2 additions & 19 deletions docs/content/client/configuration/model_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,13 @@ spell-checker:ignore ollama, mxbai, nomic, thenlper, minilm, uniqueid, huggingfa

At a minimum, a Large _Language Model_ (LLM) must be configured in {{< short_app_ref >}} for basic functionality. For Retrieval-Augmented Generation (**RAG**), an _Embedding Model_ will also need to be configured.

{{% notice style="default" title="Model APIs" icon="circle-info" %}}
If there is a specific model API that you would like to use, please [open an issue in GitHub](https://github.com/oracle/ai-optimizer/issues/new).
{{% /notice %}}

| Type | API | Location |
| ----- | -------------------------------------------------------- | ------------- |
| LLM | [ChatOCIGenAI](#additional-information) | Private Cloud |
| LLM | [ChatOllama](#additional-information) | On-Premises |
| LLM | [CompatOpenAI](#additional-information) | On-Premises |
| LLM | [OpenAI](#additional-information) | Third-Party |
| LLM | [ChatPerplexity](#additional-information) | Third-Party |
| LLM | [Cohere](#additional-information) | Third-Party |
| Embed | [OCIGenAIEmbeddings](#additional-information) | Private Cloud |
| Embed | [OllamaEmbeddings](#additional-information) | On-Premises |
| Embed | [HuggingFaceEndpointEmbeddings](#additional-information) | On-Premises |
| Embed | [CompatOpenAIEmbeddings](#additional-information) | On-Premises |
| Embed | [OpenAIEmbeddings](#additional-information) | Third-Party |
| Embed | [CohereEmbeddings](#additional-information) | Third-Party |
There is an extensive list of different API Model APIs available you can choose from.

## Configuration

The models can either be configured using environment variables or through the {{< short_app_ref >}} interface. To configure models through environment variables, please read the [Additional Information](#additional-information) about the specific model you would like to configure.

To configure an LLM or embedding model from the {{< short_app_ref >}}, navigate to `Configuration -> Models`:
To configure an LLM or embedding model from the {{< short_app_ref >}}, navigate to _Configuration_ page and _Models_ tab:

![Model Config](../images/models_config.png)

Expand Down
11 changes: 6 additions & 5 deletions docs/content/client/configuration/oci_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@ Oracle Cloud Infrastructure (OCI) can _optionally_ be configured to enable addit

## Configuration

OCI can either be configured through the [{{< short_app_ref >}} interface](#{{< short_app_ref >}}-interface), a [CLI Configuration File](#config-file), or by using [environment variables](#environment-variables).
OCI can either be configured through the [{{< short_app_ref >}} interface](#{{< short_app_ref >}}-interface), a [CLI Configuration File](#config-file), or by using [environment variables](#environment-variables).

You will need to [generate an API Key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#two) to obtain the required configuration values.

---

### Interface

To configure the Database from the {{< short_app_ref >}}, navigate to `Configuration -> OCI`:
To configure the Database from the {{< short_app_ref >}}, navigate to _Configuration_ menu and _OCI_ tab:

![OCI Config](../images/oci_config.png)

OCI GenAI Services can be configured once OCI access has been confirmed:
Provide the values obtained by [generating an API Key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#two).

OCI GenAI Services can also be configured on this page, once OCI access has been confirmed.

![OCI GenAI Config](../images/oci_genai_config.png)

Provide the values obtained by [generating an API Key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#two).

---

Expand Down
6 changes: 3 additions & 3 deletions docs/content/client/configuration/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Once you are happy with the specific configuration of your {{< short_app_ref >}}

## View and Download

To view and download the {{< short_app_ref >}} configuration, navigate to `Configuration -> Settings`:
To view and download the {{< short_app_ref >}} configuration, navigate to the _Configuration_ page and _Settings_ tab:

![Download Settings](../images/settings_download.png)

{{< icon "triangle-exclamation" >}} Settings contain sensitive information such as database passwords and API Keys. By default, these settings will not be exported and will have to be re-entered after uploading the settings in a new instance of the {{< short_app_ref >}}. If have a secure way to store the settings and would would like to export the sensitive data, tick the "Include Sensitive Settings" box.
{{< icon "triangle-exclamation" >}} Settings contain sensitive information such as database passwords and API Keys. By default, these settings will not be exported and will have to be re-entered after uploading the settings in a new instance of the {{< short_app_ref >}}. If you have a secure way to store the settings and would would like to export the sensitive data, tick the "Include Sensitive Settings" box.

## Upload

Expand All @@ -29,7 +29,7 @@ To upload previously downloaded settings, navigate to `Configuration -> Settings

If there are differences found, you can review the differences before clicking "Apply New Settings".

## SpringAI
## Source Code Templates

You can download from the console a basic template that could help to expose as a OpenAI API compliant REST endpoint the RAG Chatbot defined in the chat console.
If your configuration has both OLLAMA or OpenAI as providers for chat and embeddings LLMs, it will appear a button named “Download SpringAI”:
Expand Down
Binary file modified docs/content/client/testbed/images/generate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/tools/images/embed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/tools/images/prompt_eng_context.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/tools/images/prompt_eng_system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/client/tools/images/split.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions docs/content/client/tools/split_embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ Licensed under the Universal Permissive License v1.0 as shown at http://oss.orac

The first phase building of building a RAG Chatbot using Vector Search starts with the document chunking based on vector embeddings generation. Embeddings will be stored into a vector store to be retrieved by vectors distance search and added to the LLM context in order to answer the question grounded to the information provided.

We choose the freedom to exploit LLMs for vector embeddings provided by public services like Cohere, OpenAI, and Perplexity, or running on top a GPU compute node managed by the user and exposed through open source platforms like OLLAMA or HuggingFace, to avoid sharing data with external services that are beyond full customer control.
You have the freedom to choose different Embedding Models for vector embeddings provided by public services like Cohere, OpenAI, and Perplexity, or local models running on top a GPU compute node managed by the yourself. Running a local model, such as Ollama or HuggingFace, avoids sharing data with external services that are beyond your control.

From the **Split/Embed** voice of the left side menu, you’ll access to the ingestion page:
From the _Tools_ menu, select the _Split/Embed_ tab to perform the splitting and embedding process:

![Split](../images/split.png)

The Load and Split Documents, parts of Split/Embed form, will allow to choose documents (txt,pdf,html,etc.) stored on the Object Storage service available on the Oracle Cloud Infrastructure, on the client’s desktop or getting from URLs, like shown in following snapshot:
The Load and Split Documents, parts of Split/Embed form, will allow to choose documents (txt,pdf,html,etc.) stored on the Object Storage service available on the Oracle Cloud Infrastructure, on the client’s desktop or from URLs, like shown in following snapshot:

![Embed](../images/embed.png)

It will be created a “speaking” table, like the TEXT_EMBEDDING_3_SMALL_8191_1639_COSINE in the example. You can create, on the same set of documents, several options of vectorstore table, since nobody normally knows which is the best chunking size, and then test them indipendently.
"Populating the Vector Store" will create a table in the Oracle Database with the embeddings. You can create multiple vector stores, on the same set of documents, to experiment with chunking size, distance metrics, etc, and then test them independently.

## Embedding Configuration

Choose one of the **Embedding models available** from the listbox that will depend by the **Configuration/Models** page.
The **Embedding Server** URL associated to the model chosen will be shown. The **Chunk Size (tokens)** will change according the kind of embeddings model selected, as well as the **Chunk Overlap (% of Chunk Size)**.
The **Embedding Server** URL associated to the model chosen will be shown. The **Chunk Size (tokens)** will change according the kind of embeddings model selected, as well as the **Chunk Overlap (% of Chunk Size)**.

Then you have to choose one of the **Distance Metric** available in the Oracle DB23ai:
- COSINE
- EUCLIDEAN_DISTANCE
- DOT_PRODUCT
- MAX_INNER_PRODUCT

To understand the meaning of these metrics, please refer to the doc [Vector Distance Metrics](https://docs.oracle.com/en/database/oracle/oracle-database/23/vecse/vector-distance-metrics.html) in the Oracle DB23ai "*AI Vector Search User's Guide*".

The **Embedding Alias** field let you to add a more meaningful info to the vectorstore table that allows you to have more than one vector table with the same: *model + chunksize + chunk_overlap + distance_strategy* combination.
Expand Down
14 changes: 7 additions & 7 deletions docs/content/walkthrough/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Notice that there are no language models configured to use. Let's start the conf

### Configure the LLM

To configure the On-Premises **LLM**, navigate to the _Configuration -> Models_ screen:
To configure the On-Premises **LLM**, navigate to the _Configuration_ screen and _Models_ tab:

1. Enable the `llama3.1` model that you pulled earlier by clicking the _Edit_ button
![Configure LLM](images/models_edit.png)
Expand All @@ -240,15 +240,15 @@ Navigate to the _ChatBot_ screen:

The error about language models will have disappeared, but there are new warnings about embedding models and the database. You'll take care of those in the next steps.

The `Chat model:` will have been pre-set to the only enabled **LLM** (_llama3.1_) and a dialog box to interact with the **LLM** will be ready for input.
The `Chat model:` will have been pre-set to the only enabled **LLM** (_ollama/llama3.1_) and a dialog box to interact with the **LLM** will be ready for input.

Feel free to play around with the different **LLM** Parameters, hovering over the {{% icon circle-question %}} icons to get more information on what they do.

You'll come back to the _ChatBot_ later to experiment further.

### Configure the Embedding Model

To configure the On-Premises Embedding Model, navigate back to the _Configuration -> Models_ screen:
To configure the On-Premises Embedding Model, navigate back to the _Configuration_ screen and _Models_ tab:

1. Enable the `mxbai-embed-large` Embedding Model following the same process as you did for the Language Model.
![Configure Embedding Model](images/models_enable_embed.png)
Expand All @@ -257,12 +257,12 @@ To configure the On-Premises Embedding Model, navigate back to the _Configuratio

### Configure the Database

To configure Oracle Database 23ai Free, navigate to the _Configuration -> Database_ screen:
To configure Oracle Database 23ai Free, navigate to the _Configuration_ screen and _Databases_ tab:

1. Enter the Database Username: `WALKTHROUGH`
1. Enter the Database Password for the database user: `OrA_41_OpTIMIZER`
1. Enter the Database Connection String: `//localhost:1521/FREEPDB1`
1. Save
1. Save Database

![Configure Database](../client/configuration/images/database_config.png)

Expand All @@ -272,7 +272,7 @@ To configure Oracle Database 23ai Free, navigate to the _Configuration -> Databa

With the embedding model and database configured, you can now split and embed documents for use in **Vector Search**.

Navigate to the _Split/Embed_ Screen:
Navigate to the _Tools_ screen and _Split/Embed_ tab:

1. Change the File Source to `Web`
1. Enter the URL:
Expand All @@ -285,7 +285,7 @@ Navigate to the _Split/Embed_ Screen:
1. Please be patient...

{{% notice style="code" title="Performance: Grab a beverage of your choosing..." icon="circle-info" %}}
Depending on the infrastructure, the embedding process can take a few minutes. As long as the "RUNNING" dialog in the top-right corner is moving... it's working.
Depending on the infrastructure, the embedding process can take a few minutes. As long as the "Populating Vector Store..." timer is running... it's working.
{{% /notice %}}

![Split and Embed](images/split_embed_web.png)
Expand Down
Binary file modified docs/content/walkthrough/images/chatbot_say_hello.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/walkthrough/images/models_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/walkthrough/images/models_enable_embed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/walkthrough/images/models_enable_llm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/content/walkthrough/images/split_embed_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ FROM all_in_one_pyenv AS oai_application
ENV PATH=/opt/.venv/bin:$PATH
ENV TEMP=/app/tmp
ENV TNS_ADMIN=/app/tns_admin
ENV API_SERVER_CONTROL="TRUE"
ENV OCI_CLI_CONFIG_FILE=/app/runtime/.oci/config

# Expect the .oci directory to be mounted to /app/.oci
Expand Down
2 changes: 1 addition & 1 deletion src/client/content/config/tabs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def spring_ai_obaas(src_dir, file_name, provider, ll_config, embed_config):
for item in state.prompt_configs
if item["name"] == state.client_settings["prompts"]["sys"] and item["category"] == "sys"
)
logger.info(f"Prompt used in export:\n{sys_prompt}")
logger.info("Prompt used in export:\n%s", sys_prompt)
with open(src_dir / "templates" / file_name, "r", encoding="utf-8") as template:
template_content = template.read()

Expand Down
2 changes: 1 addition & 1 deletion src/client/content/tools/tabs/split_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def display_split_embed() -> None:
file_sources = ["OCI", "Local", "Web"]
oci_lookup = st_common.state_configs_lookup("oci_configs", "auth_profile")
oci_setup = oci_lookup.get(state.client_settings["oci"].get("auth_profile"))
if not oci_setup or "namespace" not in oci_setup or "tenancy" not in oci_setup:
if not oci_setup or oci_setup.get("namespace") is None or oci_setup.get("tenancy") is None:
st.warning("OCI is not fully configured, some functionality is disabled", icon="⚠️")
file_sources.remove("OCI")

Expand Down
12 changes: 9 additions & 3 deletions src/server/api/core/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ def get_database(name: Optional[DatabaseNameType] = None) -> Union[list[Database


def create_database(database: Database) -> Database:
"""Create a new Model definition"""
"""Create a new Database definition"""
database_objects = bootstrap.DATABASE_OBJECTS

_ = get_database(name=database.name)
try:
existing = get_database(name=database.name)
if existing:
raise ValueError(f"Database {database.name} already exists")
except ValueError as ex:
if "not found" not in str(ex):
raise

if any(not getattr(database_objects, key) for key in ("user", "password", "dsn")):
if any(not getattr(database, key) for key in ("user", "password", "dsn")):
raise ValueError("'user', 'password', and 'dsn' are required")

database_objects.append(database)
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/client/content/test_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def test_copy_client_settings_success(self, app_test, app_server):
assert app_server is not None
at = app_test(self.ST_FILE).run()

# Store original value for cleanup
original_auth_profile = at.session_state.client_settings["oci"]["auth_profile"]

# Check that Server/Client Identical
assert at.session_state.client_settings == at.session_state.server_settings
# Update Client Settings
Expand All @@ -38,3 +41,10 @@ def test_copy_client_settings_success(self, app_test, app_server):
# Validate settings have been copied
assert at.session_state.client_settings == at.session_state.server_settings
assert at.session_state.server_settings["oci"]["auth_profile"] == "TESTING"

# Clean up: restore original value both in session state and on server to avoid polluting other tests
at.session_state.client_settings["oci"]["auth_profile"] = original_auth_profile
# Copy the restored settings back to the server
at.button(key="copy_client_settings").click().run()
# Verify cleanup worked
assert at.session_state.server_settings["oci"]["auth_profile"] == original_auth_profile
Loading