MVPilgrim commited on
Commit
d33695d
·
1 Parent(s): fc8b872

8vcpu invalid instruction

Browse files
Files changed (1) hide show
  1. app.py +63 -59
app.py CHANGED
@@ -457,44 +457,7 @@ try:
457
  logger.debug(f"### o.properties: {wstr}")
458
  logger.info("#### getAllRagData() exited.")
459
  return wstrObjs
460
-
461
- ##########################
462
- # Display UI text areas. #
463
- ##########################
464
- col1, col2 = st.columns(2)
465
- with col1:
466
- if "sysTA" not in st.session_state:
467
- st.session_state.sysTA = st.text_area(label="System Prompt",placeholder="You are a helpful AI assistant", help="Instruct the LLM about how to handle the user prompt.")
468
- elif "sysTAtext" in st.session_state:
469
- st.session_state.sysTA = st.text_area(label="System Prompt",value=st.session_state.sysTAtext,placeholder="You are a helpful AI assistant", help="Instruct the LLM about how to handle the user prompt.")
470
- else:
471
- st.session_state.sysTA = st.text_area(label="System Prompt",value=st.session_state.sysTA,placeholder="You are a helpful AI assistant", help="Instruct the LLM about how to handle the user prompt.")
472
-
473
- if "userpTA" not in st.session_state:
474
- st.session_state.userpTA = st.text_area(label="User Prompt",placeholder="Prompt the LLM with a question or instruction.", \
475
- help="Enter a prompt for the LLM. No special characters needed.")
476
- elif "userpTAtext" in st.session_state:
477
- st.session_state.userpTA = st.text_area (label="User Prompt",value=st.session_state.userpTAtext,placeholder="Prompt the LLM with a question or instruction.", \
478
- help="Enter a prompt for the LLM. No special characters needed.")
479
- else:
480
- st.session_state.userpTA = st.text_area(label="User Prompt",value=st.session_state.userpTA,placeholder="Prompt the LLM with a question or instruction.", \
481
- help="Enter a prompt for the LLM. No special characters needed.")
482
-
483
- with col2:
484
- if "ragpTA" not in st.session_state:
485
- st.session_state.ragpTA = st.text_area(label="RAG Response",placeholder="Output if RAG selected.",help="RAG output if enabled.")
486
- elif "ragpTAtext" in st.session_state:
487
- st.session_state.ragpTA = st.text_area(label="RAG Response",value=st.session_state.ragpTAtext,placeholder="Output if RAG selected.",help="RAG output if enabled.")
488
- else:
489
- st.session_state.ragpTA = st.text_area(label="RAG Response",value=st.session_state.ragpTA,placeholder="Output if RAG selected.",help="RAG output if enabled.")
490
-
491
- if "rspTA" not in st.session_state:
492
- st.session_state.rspTA = st.text_area(label="LLM Completion",placeholder="LLM completion.",help="Output area for LLM completion (response).")
493
- elif "rspTAtext" in st.session_state:
494
- st.session_state.rspTA = st.text_area(label="LLM Completion",value=st.session_state.rspTAtext,placeholder="LLM completion.",help="Output area for LLM completion (response).")
495
- else:
496
- st.session_state.rspTA = st.text_area(label="LLM Completion",value=st.session_state.rspTA,placeholder="LLM completion.",help="Output area for LLM completion (response).")
497
-
498
 
499
  ####################################################################
500
  # Prompt the LLM with the user's input and return the completion. #
@@ -511,17 +474,18 @@ try:
511
 
512
  modelOutput = ""
513
  #with st.spinner('Generating Completion (but slowly. 40+ seconds.)...'):
514
- with st.markdown("<h1 style='text-align: center; color: #666666;'>LLM with RAG Prompting <br style='page-break-after: always;'>Proof of Concept</h1>",
515
- unsafe_allow_html=True):
516
- with st.spinner('Generating Completion (but slowly. 40+ seconds.)...'):
517
- modelOutput = llm.create_chat_completion(
518
- prompt
519
- #max_tokens=max_tokens,
520
- #temperature=temperature,
521
- #top_p=top_p,
522
- #echo=echoVal,
523
- #stop=stop,
524
- )
 
525
  if modelOutput != "":
526
  result = modelOutput["choices"][0]["message"]["content"]
527
  else:
@@ -560,6 +524,54 @@ try:
560
  logger.info("setPrompt exited.")
561
  return fullPrompt
562
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
 
564
  #####################################
565
  # Run the LLM with the user prompt. #
@@ -567,16 +579,8 @@ try:
567
  def on_runLLMButton_Clicked():
568
  logger = st.session_state.logger
569
  logger.info("### on_runLLMButton_Clicked entered.")
570
- st.session_state.sysTAtext = st.session_state.sysTA
571
- logger.debug(f"sysTAtext: {st.session_state.sysTAtext}")
572
-
573
- wrklist = setPrompt(st.session_state.userpTA,st.selectRag)
574
- st.session_state.userpTA = wrklist[1]["content"]
575
- logger.debug(f"userpTAtext: {st.session_state.userpTA}")
576
-
577
- rsp = runLLM(wrklist)
578
- st.session_state.rspTA = rsp
579
- logger.debug(f"rspTAtext: {st.session_state.rspTA}")
580
 
581
  logger.info("### on_runLLMButton_Clicked exited.")
582
 
 
457
  logger.debug(f"### o.properties: {wstr}")
458
  logger.info("#### getAllRagData() exited.")
459
  return wstrObjs
460
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
 
462
  ####################################################################
463
  # Prompt the LLM with the user's input and return the completion. #
 
474
 
475
  modelOutput = ""
476
  #with st.spinner('Generating Completion (but slowly. 40+ seconds.)...'):
477
+ #with st.markdown("<h1 style='text-align: center; color: #666666;'>LLM with RAG Prompting <br style='page-break-after: always;'>Proof of Concept</h1>",
478
+ # unsafe_allow_html=True):
479
+ st.session_state.spinGenMsg = True
480
+ modelOutput = llm.create_chat_completion(
481
+ prompt
482
+ #max_tokens=max_tokens,
483
+ #temperature=temperature,
484
+ #top_p=top_p,
485
+ #echo=echoVal,
486
+ #stop=stop,
487
+ )
488
+ st.session_state.spinGenMsg = False
489
  if modelOutput != "":
490
  result = modelOutput["choices"][0]["message"]["content"]
491
  else:
 
524
  logger.info("setPrompt exited.")
525
  return fullPrompt
526
 
527
+ ##########################
528
+ # Display UI text areas. #
529
+ ##########################
530
+ col1, col2 = st.columns(2)
531
+ with col1:
532
+ if "sysTA" not in st.session_state:
533
+ st.session_state.sysTA = st.text_area(label="System Prompt",placeholder="You are a helpful AI assistant", help="Instruct the LLM about how to handle the user prompt.")
534
+ elif "sysTAtext" in st.session_state:
535
+ st.session_state.sysTA = st.text_area(label="System Prompt",value=st.session_state.sysTAtext,placeholder="You are a helpful AI assistant", help="Instruct the LLM about how to handle the user prompt.")
536
+ else:
537
+ st.session_state.sysTA = st.text_area(label="System Prompt",value=st.session_state.sysTA,placeholder="You are a helpful AI assistant", help="Instruct the LLM about how to handle the user prompt.")
538
+
539
+ if "userpTA" not in st.session_state:
540
+ st.session_state.userpTA = st.text_area(label="User Prompt",placeholder="Prompt the LLM with a question or instruction.", \
541
+ help="Enter a prompt for the LLM. No special characters needed.")
542
+ elif "userpTAtext" in st.session_state:
543
+ st.session_state.userpTA = st.text_area (label="User Prompt",value=st.session_state.userpTAtext,placeholder="Prompt the LLM with a question or instruction.", \
544
+ help="Enter a prompt for the LLM. No special characters needed.")
545
+ else:
546
+ st.session_state.userpTA = st.text_area(label="User Prompt",value=st.session_state.userpTA,placeholder="Prompt the LLM with a question or instruction.", \
547
+ help="Enter a prompt for the LLM. No special characters needed.")
548
+
549
+ with col2:
550
+ if st.session_state.spinGenMsg and st.session_state.spinGenMsg == True:
551
+ st.session_state.spinGenMsg = False;
552
+ with st.spinner('Generating Completion (but slowly. 40+ seconds.)...'):
553
+ st.session_state.sysTAtext = st.session_state.sysTA
554
+ logger.debug(f"sysTAtext: {st.session_state.sysTAtext}")
555
+ wrklist = setPrompt(st.session_state.userpTA,st.selectRag)
556
+ st.session_state.userpTA = wrklist[1]["content"]
557
+ logger.debug(f"userpTAtext: {st.session_state.userpTA}")
558
+ rsp = runLLM(wrklist)
559
+ st.session_state.rspTA = rsp
560
+ logger.debug(f"rspTAtext: {st.session_state.rspTA}")
561
+ if "ragpTA" not in st.session_state:
562
+ st.session_state.ragpTA = st.text_area(label="RAG Response",placeholder="Output if RAG selected.",help="RAG output if enabled.")
563
+ elif "ragpTAtext" in st.session_state:
564
+ st.session_state.ragpTA = st.text_area(label="RAG Response",value=st.session_state.ragpTAtext,placeholder="Output if RAG selected.",help="RAG output if enabled.")
565
+ else:
566
+ st.session_state.ragpTA = st.text_area(label="RAG Response",value=st.session_state.ragpTA,placeholder="Output if RAG selected.",help="RAG output if enabled.")
567
+
568
+ if "rspTA" not in st.session_state:
569
+ st.session_state.rspTA = st.text_area(label="LLM Completion",placeholder="LLM completion.",help="Output area for LLM completion (response).")
570
+ elif "rspTAtext" in st.session_state:
571
+ st.session_state.rspTA = st.text_area(label="LLM Completion",value=st.session_state.rspTAtext,placeholder="LLM completion.",help="Output area for LLM completion (response).")
572
+ else:
573
+ st.session_state.rspTA = st.text_area(label="LLM Completion",value=st.session_state.rspTA,placeholder="LLM completion.",help="Output area for LLM completion (response).")
574
+
575
 
576
  #####################################
577
  # Run the LLM with the user prompt. #
 
579
  def on_runLLMButton_Clicked():
580
  logger = st.session_state.logger
581
  logger.info("### on_runLLMButton_Clicked entered.")
582
+
583
+ st.session_state.spinGenMsg = True
 
 
 
 
 
 
 
 
584
 
585
  logger.info("### on_runLLMButton_Clicked exited.")
586