Skip to content

Commit 381f17d

Browse files
PhillipDowneyPhil Downey
andauthored
Llm rxn fix (#52)
* notebook and LLM updates * first merge llm * llm fix and rxn fix --------- Co-authored-by: Phil Downey <phildowney@pd-work-mac.local>
1 parent cbacab5 commit 381f17d

99 files changed

Lines changed: 38648 additions & 572 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ urls = [
1515
'https://cps.foc-deepsearch.zurich.ibm.com',
1616
'https://rxn.app.accelerate.science',
1717
'https://sds.app.accelerate.science',
18-
'https://platform.openai.com/account/api-keys'
18+
1919
]
2020
for (var i=0; i< urls.length; i++) {
2121
window.open(urls[i], '_blank', 'width=1000,height=600');
@@ -369,15 +369,15 @@ To run a command in bash mode, prepend it with `openad` and make sure to escape
369369

370370
To enable our AI assistant, you'll need either have access to [IBM BAM](https://bam.res.ibm.com/auth/signin) or to use a free open source LLM use [ollama](ollama.com).
371371

372-
**Note:** Ollama will regire a 8gb GPU
372+
**Note:** Ollama will requires a 8gb GPU
373373

374374
> **Note:** watsonx coming soon
375375
376376
## IBM BAM Setup
377377
For IBM BAM simply used your supplied API key if you have BAM access
378378

379379
### Run BAM LLM
380-
run `tell me` to be prompted for your OpenAI API credentials
380+
run `tell me` to be prompted for your BAM API credentials
381381
```
382382
>> set llm bam
383383
>> tell me <enter prompt>

openad/app/main.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import inspect
5858
import importlib
5959

60-
60+
MAGIC_PROMPT = None
6161
PLUGIN_CLASS_LIST = []
6262
installed_packages = pkg_resources.working_set
6363
installed_packages_list = [
@@ -116,8 +116,8 @@ class RUNCMD(Cmd):
116116
False # Signals the Refresh of the vector DB should be done due to changes in Workspace or Toolkits
117117
)
118118
refresh_train = False # Signals Refreshing of the training repository for help should be done
119-
llm_service = "OPENAI" # set with OPENAI as default type until WatsonX or alternative available
120-
llm_model = "gpt-3.5-turbo"
119+
llm_service = "OLLAMA" # set with OLLAMA as default type until WatsonX or alternative available
120+
llm_model = "instructlab/granite-7b-lab"
121121
llm_models = SUPPORTED_TELL_ME_MODELS_SETTINGS
122122

123123
# Load OpenAD Plugins into cmd_pointer
@@ -825,6 +825,8 @@ def error_first_word_grabber(error):
825825
# If the application is called with parameters, it executes the parameters.
826826
# If called without parameters, the command line enters the shell environment.
827827
# History is only kept for commands executed once in the shell.
828+
829+
828830
def api_remote(
829831
inp: str,
830832
api_context: dict = {"workspace": None, "toolkit": None},
@@ -842,16 +844,21 @@ def api_remote(
842844
- It is deliberate that the whole RUNCMD class object is not kept alive as there is no logical
843845
exit point for magic commands, unlike a command line.
844846
"""
845-
847+
global MAGIC_PROMPT
846848
# GLOBAL_SETTINGS["display"] = "notebook"
849+
847850
initialise()
848851

849852
arguments = inp.split()
850853
inp = "" # reset input after splitting into arguments
851854
a_space = "" # reset a_space
852855

853856
# setup for notebook mode
854-
magic_prompt = RUNCMD()
857+
if MAGIC_PROMPT is None:
858+
magic_prompt = RUNCMD()
859+
MAGIC_PROMPT = magic_prompt
860+
else:
861+
magic_prompt = MAGIC_PROMPT
855862

856863
if api_context["workspace"] is None:
857864
api_context["workspace"] = magic_prompt.settings["workspace"]

openad/app/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"banner": "OPENAD",
33
"title": "Welcome to the Open Accelerated Discovery CLI",
4-
"version": "0.3.2",
4+
"version": "0.3.6",
55
"commands": {
66
"intro": "If this is your first time, let us help you getting started.",
77
"? toolkits": "Learn about the toolkits.",

openad/helpers/credentials.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Helpers for getting and Saving Credentials"""
2+
23
import pickle
34
import readline
45
import os
@@ -56,7 +57,3 @@ def write_credentials(registry: dict, location):
5657
with open(os.path.expanduser(location), "wb") as handle:
5758
pickle.dump(registry, handle)
5859
return True
59-
60-
61-
if __name__ == "__main__":
62-
print(load_credentials("~/.openad/openai_api.json"))

openad/llm_assist/llm_interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
# Constants
2222
TRAINING_LLM_DIR = "/prompt_train/"
23-
SUPPORTED_LLMS = ["WATSONX", "OPENAI", "BAM", "OLLAMA"]
23+
# SUPPORTED_LLMS = ["WATSONX", "OPENAI", "BAM", "OLLAMA"]
24+
SUPPORTED_LLMS = ["WATSONX", "BAM", "OLLAMA"]
2425
PROMPT_DIR = "~/.chat_embedded"
2526
STANDARD_FILE_TYPES_EMBED = ["*.txt", "*.ipynb", "*.run", "*.cdoc", "*.pdf"]
2627
EXTENDED_FILE_TYPES_EMBED = ["**/*.txt", "**/*.ipynb", "**/*.run", "**/*.cdoc", "**/*.pdf"]

openad/llm_assist/model_reference.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
LOCAL_MODEL_KWARGS = {"device": LOCAL_EMBEDDINGS_DEVICE}
5353
LOCAL_ENCODE_KWARGS = {"normalize_embeddings": False}
5454

55-
DEFAULT_TELL_ME_MODEL = "BAM"
56-
SUPPORTED_TELL_ME_MODELS = ["BAM", "OPENAI", "OLLAMA"]
55+
DEFAULT_TELL_ME_MODEL = "OLLAMA"
56+
# SUPPORTED_TELL_ME_MODELS = ["BAM", "OPENAI", "OLLAMA"]
57+
SUPPORTED_TELL_ME_MODELS = ["BAM", "OLLAMA"]
5758
OLLAMA_HOST = "http://0.0.0.0:11434"
5859

5960
try:
@@ -83,7 +84,7 @@
8384
8485
Answer the question based only on the following context: {context} Question: {question} """,
8586
"settings": {
86-
"temperature": 0.7,
87+
"temperature": 0.5,
8788
"decoding_method": "greedy",
8889
"max_new_tokens": 2048,
8990
"min_new_tokens": 1,
@@ -95,7 +96,7 @@
9596
},
9697
"OLLAMA": {
9798
# "model": "granite-code:8b",
98-
"model": "llama3",
99+
"model": "instructlab/granite-7b-lab",
99100
"url": OLLAMA_HOST,
100101
"template": """You are a technical documentation writer and when responding follow the following rules:
101102
- Format All Command Syntax, Clauses, Examples or Option Syntax in codeblock ipython Markdown
@@ -175,15 +176,15 @@ def get_tell_me_model(service: str, api_key: str):
175176

176177
return model, SUPPORTED_TELL_ME_MODELS_SETTINGS[service]["template"]
177178
except Exception as e: # pylint: disable=broad-exception-caught
178-
output_error("Error Loading OPENAI Model see error Messsage : \n" + e, return_val=False)
179+
output_error("Error Loading Model see error Messsage : \n" + e, return_val=False)
179180
return None, None
180181
elif service == "OLLAMA":
181182
try:
182183
model = ChatOllama(model=SUPPORTED_TELL_ME_MODELS_SETTINGS[service]["model"], base_url=OLLAMA_HOST)
183184

184185
return model, SUPPORTED_TELL_ME_MODELS_SETTINGS[service]["template"]
185186
except Exception as e: # pylint: disable=broad-exception-caught
186-
output_error("Error Loading OPENAI Model see error Messsage : \n" + e, return_val=False)
187+
output_error("Error Loading Model see error Messsage : \n" + e, return_val=False)
187188
return None, None
188189
elif service == "BAM":
189190
creds = Credentials(api_key=api_key, api_endpoint=SUPPORTED_TELL_ME_MODELS_SETTINGS[service]["url"])

openad/llm_assist/prime_chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def __init__(
7878
document_types=document_types,
7979
db_dir_override=None,
8080
refresh_vector=False,
81-
llm_model="gpt-4",
82-
llm_service="OPENAI",
81+
llm_model="nstructlab/granite-7b-lab",
82+
llm_service="ollama",
8383
):
8484
self.organisation = organisation
8585
self.target = target

0 commit comments

Comments
 (0)