Skip to content

Commit

Permalink
Merge pull request #27 from paulparkinson/main
Browse files Browse the repository at this point in the history
added insert and expsoure via rest endpoint of q+a results,, comparmentid from env, repeated queries, ai/eye/etc commands, fixes to ragchat
  • Loading branch information
enschilling authored Aug 8, 2024
2 parents 4b894d7 + 3851c88 commit 010492a
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 115 deletions.
Binary file removed MLH.jpg
Binary file not shown.
55 changes: 0 additions & 55 deletions download.html

This file was deleted.

51 changes: 32 additions & 19 deletions python-rag-chatbot/oracle_bot_exp.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#
# Streamlit App to demo OCI AI GenAI
# this is the main code, with the UI
#
import streamlit as st
import time
import traceback
import sys

# this function initialise the rag chain, creating retriever, llm and chain
from init_rag_streamlit_exp import initialize_rag_chain, get_answer

#
# Configs
#
from streamlit_feedback import streamlit_feedback

def process_feedback(feedback_value):
st.write("Feedback value:", feedback_value)
with open("feedback.txt", "a", encoding="utf-8") as f:
f.write(f"{feedback_value}\n")

def reset_conversation():
st.session_state.messages = []
st.session_state.feedback_rendered = False
st.session_state.feedback_key = 0


#
# Main
#
st.title("Oracle Database AI Bot powered by RAG")
st.title("Developing an AI bot powered by RAG and Oracle Database")

# Added reset button
st.button("Clear Chat History", on_click=reset_conversation)
Expand All @@ -43,18 +41,33 @@ def reset_conversation():
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": question})

# here we call OCI genai...

try:
print("...")
response = get_answer(rag_chain, question)

# Display assistant response in chat message container
with st.chat_message("assistant"):
st.markdown(response)

# Add assistant response to chat history
with st.container():
st.markdown("How was my response?")

if not st.session_state.feedback_rendered:
def _submit_feedback(feedback_value, *args, **kwargs):
print("Feedback submitted:", feedback_value, file=sys.stderr) # Redirect to stderr
process_feedback(feedback_value)
st.session_state.feedback_rendered = False

feedback_component = streamlit_feedback(
feedback_type="faces",
on_submit=_submit_feedback,
key=f"feedback_{st.session_state.feedback_key}",
optional_text_label="Please provide some more information",
args=["✅"]
)
st.session_state.feedback_key += 1
st.session_state.feedback_rendered = True

st.session_state.messages.append({"role": "assistant", "content": response})

except Exception as e:
st.error("An error occurred: " + str(e))
st.error(f"An error occurred: {e}")
traceback.print_exc()
Loading

0 comments on commit 010492a

Please sign in to comment.