Skip to content

Commit 67ab04c

Browse files
Move LM clients to LiteLMM (#252)
* Use LiteLLM for all LMs * Use API_BASE for Model * Fix Streaming Issue * Removed cyclic import on databases * Removed cyclic import on oci * IaC Updates * LangChain MCP template fix * API Server Control --------- Co-authored-by: corradodebari <corrado.de.bari@oracle.com>
1 parent 3ea31c1 commit 67ab04c

Some content is hidden

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

84 files changed

+2166
-1457
lines changed

.pylintrc

Lines changed: 647 additions & 0 deletions
Large diffs are not rendered by default.

opentofu/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ resource "oci_database_autonomous_database" "default_adb" {
8080
module "vm" {
8181
count = var.infrastructure == "VM" ? 1 : 0
8282
source = "./modules/vm"
83+
optimizer_version = var.optimizer_version
8384
label_prefix = local.label_prefix
8485
tenancy_id = var.tenancy_ocid
8586
compartment_id = local.compartment_ocid

opentofu/modules/kubernetes/iam.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ resource "oci_identity_policy" "workers_policies" {
4242
format("allow any-user to read objects in compartment id %s where all {request.principal.type = 'workload', request.principal.namespace = '%s', request.principal.cluster_id = '%s'}", var.compartment_id, var.label_prefix, oci_containerengine_cluster.default_cluster.id),
4343
format("allow any-user to manage repos in compartment id %s where all {request.principal.type = 'workload', request.principal.namespace = '%s', request.principal.cluster_id = '%s'}", var.compartment_id, var.label_prefix, oci_containerengine_cluster.default_cluster.id),
4444
# Instance Principles
45-
format("allow dynamic-group %s to use generative-ai-family in compartment id %s", oci_identity_dynamic_group.workers_dynamic_group.name, var.compartment_id),
4645
format("allow dynamic-group %s to manage repos in compartment id %s", oci_identity_dynamic_group.workers_dynamic_group.name, var.compartment_id),
46+
format("allow dynamic-group %s to use generative-ai-family in tenancy", oci_identity_dynamic_group.workers_dynamic_group.name),
4747
]
4848
provider = oci.home_region
4949
}

opentofu/modules/vm/iam.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ resource "oci_identity_policy" "identity_node_policies" {
3434
"allow dynamic-group %s to read objects in compartment id %s",
3535
oci_identity_dynamic_group.compute_dynamic_group.name, var.compartment_id
3636
),
37+
format(
38+
"allow dynamic-group %s to use generative-ai-family in tenancy",
39+
oci_identity_dynamic_group.compute_dynamic_group.name
40+
),
3741
]
3842
provider = oci.home_region
3943
}

opentofu/modules/vm/locals.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
locals {
66
cloud_init_compute = templatefile("${path.module}/templates/cloudinit-compute.tpl", {
7-
tenancy_id = var.tenancy_id
8-
compartment_id = var.compartment_id
9-
oci_region = var.region
10-
db_name = var.adb_name
11-
db_password = var.adb_password
12-
install_ollama = var.vm_is_gpu_shape ? true : false
7+
tenancy_id = var.tenancy_id
8+
compartment_id = var.compartment_id
9+
oci_region = var.region
10+
db_name = var.adb_name
11+
db_password = var.adb_password
12+
optimizer_version = var.optimizer_version
13+
install_ollama = var.vm_is_gpu_shape ? true : false
1314
})
1415

1516
cloud_init_database = templatefile("${path.module}/templates/cloudinit-database.tpl", {

opentofu/modules/vm/templates/cloudinit-compute.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ write_files:
5757
permissions: '0755'
5858
content: |
5959
#!/bin/bash
60-
# Setup for Instance Principles
61-
6260
# Download/Setup Source Code
63-
curl -L https://github.com/oracle/ai-optimizer/releases/latest/download/ai-optimizer-src.tar.gz \
64-
| tar -xz -C /app
61+
if [ "${optimizer_version}" = "main" ]; then
62+
URL="https://github.com/oracle/ai-optimizer/archive/refs/heads/main.tar.gz"
63+
curl -L "$URL" | tar -xz -C /app --strip-components=2 ai-optimizer-main/src
64+
else
65+
URL="https://github.com/oracle/ai-optimizer/releases/latest/download/ai-optimizer-src.tar.gz"
66+
curl -L "$URL" | tar -xz -C /app
67+
fi
6568
cd /app
6669
python3.11 -m venv .venv
6770
source .venv/bin/activate
@@ -84,6 +87,7 @@ write_files:
8487
content: |
8588
#!/bin/bash
8689
export OCI_CLI_AUTH=instance_principal
90+
export API_SERVER_CONTROL="True"
8791
export DB_USERNAME='AI_OPTIMIZER'
8892
export DB_PASSWORD='${db_password}'
8993
export DB_DSN='${db_name}_TP'

opentofu/modules/vm/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
33
# spell-checker: disable
44

5+
variable "optimizer_version" {
6+
type = string
7+
}
8+
59
variable "tenancy_id" {
610
type = string
711
}

opentofu/schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ variableGroups:
2828

2929
- title: "Hidden (Defaults)"
3030
variables:
31+
- optimizer_version
3132
- adb_version
3233
- k8s_run_cfgmgt
3334
visible: false

opentofu/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
# spell-checker: disable
44

55
// Standard Default Vars
6+
variable "optimizer_version" {
7+
description = "Determines if latest release or main is used"
8+
type = string
9+
default = "latest"
10+
validation {
11+
condition = var.optimizer_version == "latest" || var.optimizer_version == "main"
12+
error_message = "optimizer_version must be either 'latest' or 'main'."
13+
}
14+
}
15+
616
variable "tenancy_ocid" {
717
description = "The Tenancy ID of the OCI Cloud Account in which to create the resources."
818
type = string

src/client/content/api_server.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414
import streamlit as st
1515
from streamlit import session_state as state
1616

17-
import client.utils.client as client
18-
import client.utils.api_call as api_call
19-
import common.logging_config as logging_config
17+
from client.utils import client, api_call
18+
from common import logging_config
2019

2120
logger = logging_config.logging.getLogger("client.content.api_server")
2221

2322
try:
2423
import launch_server
25-
26-
REMOTE_SERVER = False
2724
except ImportError:
28-
REMOTE_SERVER = True
25+
pass
2926

3027

3128
#####################################################
@@ -72,16 +69,16 @@ async def main() -> None:
7269
key="user_server_port",
7370
min_value=1,
7471
max_value=65535,
75-
disabled=REMOTE_SERVER,
72+
disabled=not state.server["control"],
7673
)
7774
right.text_input(
7875
"API Server Key:",
7976
value=state.server["key"],
8077
key="user_server_key",
8178
type="password",
82-
disabled=REMOTE_SERVER,
79+
disabled=not state.server["control"],
8380
)
84-
if not REMOTE_SERVER:
81+
if state.server["control"]:
8582
st.button("Restart Server", type="primary", on_click=server_restart)
8683

8784
st.header("Server Settings", divider="red")

0 commit comments

Comments
 (0)