Skip to content

Commit 9a08ea8

Browse files
committed
Add prompt builder utility
Signed-off-by: David Weik <geekupyourlife@gmail.com>
1 parent 9666642 commit 9a08ea8

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
This changelog documents all the different updates that occur for this framework.
44

5+
## [0.1.32] - 2025-12-07
6+
7+
No changes are required at this time.
8+
9+
### Added
10+
11+
- Utility script for recreating the Prompt Builder JSON
12+
13+
### Changed
14+
15+
- None
16+
17+
### Fixed
18+
19+
- None
20+
521
## [0.1.31] - 2025-10-23
622

723
No changes are required at this time.

utility/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Utility
2+
3+
This folder contains additional utility scripts to help with administration and configuration.
4+
5+
If you go through the setup in one go, than you shouldn't need any of the provided files here.
6+
7+
## [Prompt Builder JSON](./prompt-builder-json.py)
8+
9+
This script helps you to regenerate your Prompt Builder JSON if you deleted it by accident.
10+
11+
```bash
12+
# Run the setup script with the help (-h) flag to get more information on each parameter
13+
# Run the setup script - make sure to update the parameter values that are passed into the script
14+
python ./prompt-builder-json.py -vs sas-viya-url -u username -p password -e endpoint_from_scr_deployment
15+
```

utility/prompt-builder-json.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright © 2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
import json
4+
import argparse
5+
try:
6+
from sasctl import Session
7+
from sasctl.services import model_repository as mr
8+
except:
9+
print('In order to run this script you need to install the sasctl package')
10+
raise
11+
12+
parser = argparse.ArgumentParser(description='This script sets up the LLM repository and LLM Model Project in SAS Model Manager')
13+
parser.add_argument('-vs', '--viya_server', type=str, help='Enter the URL for the SAS Viya server. An example is example.sas.com', required=True)
14+
parser.add_argument('-u', '--username', type=str, help='Enter your username for the SAS Viya server', required=True)
15+
parser.add_argument('-p', '--password', type=str, help='Enter your password for the SAS Viya server', required=True)
16+
parser.add_argument('-e', '--scr_endpoint', type=str, help='Enter the endpoint under which the LLM containers are published. Example: https://viya-host/llm', required=True)
17+
parser.add_argument('-dt', '--deployment_type', type=str, default='k8s', help='Enter the type of deployment, can be k8s (LLM & Embedding is deployed in k8s) or aca (Azure Container App)', required=False)
18+
parser.add_argument('-k', '--verify_ssl', type=str, default='true', help='Set to false if you have a self-signed certificat')
19+
args = parser.parse_args()
20+
21+
22+
23+
llm_prompt_builder = {
24+
'name': 'LLM Prompt Builder',
25+
'id': 'LPB',
26+
'width': 0,
27+
'type': 'promptBuilder',
28+
'modelRepositoryID': '',
29+
'llmProjectID': '',
30+
'SCREndpoint': args.scr_endpoint,
31+
'API_KEYS': {
32+
'Anthropic': 'key-value',
33+
'OpenAI': 'key-value',
34+
'Google': 'key-value'
35+
},
36+
'deploymentType': args.deployment_type
37+
}
38+
39+
# Establish a session
40+
try:
41+
with Session(args.viya_server, args.username, args.password, verify_ssl = (args.verify_ssl.lower() == 'true')) as s:
42+
repository_exists = mr.get_repository('LLM Repository')
43+
if repository_exists is None:
44+
raise Exception('LLM Repository does not exist. Please create the LLM Repository before running this script.')
45+
llm_prompt_builder['modelRepositoryID'] = repository_exists['id']
46+
project_exists = mr.get_project('LLM Model Project')
47+
if project_exists is None:
48+
raise Exception('LLM Model Project does not exist. Please create the LLM Model Project before running this script.')
49+
llm_prompt_builder['llmProjectID'] = project_exists['id']
50+
# Output the file for the Prompt Builder UI
51+
with open('llm-prompt-builder.json', 'w') as f:
52+
json.dump(llm_prompt_builder, f, indent=4)
53+
except:
54+
print(f'Failed to establish a connection to {args.viya_server} with the user {args.username} and the password {args.password}.')
55+
print('Make sure that the above values are valid - if that is the case, maybe try using the option -k False, to skip SSL verification.')
56+
raise

0 commit comments

Comments
 (0)