Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cdb fix #46

Merged
merged 9 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ spring_ai/create_user.sql
spring_ai/drop.sql
start.sh
spring_ai/env.sh
temp/rag_agent.ipynb
temp/tools.ipynb
temp/tools.py
temp/json-dual.sql
6 changes: 6 additions & 0 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be required but will revisit

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ To run the application on bare-metal; download the [source](https://github.com/o
pip3 install -r app/requirements.txt
```

1. Exit from your shell and run again:

```bash
source .venv/bin/activate
```

1. Start Streamlit:

```bash
Expand Down
2 changes: 1 addition & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
bokeh==3.6.1
evaluate==0.4.3
faiss-cpu==1.9.0
giskard==2.15.5
giskard==2.15.2
IPython==8.29.0
langchain-cohere==0.3.1
langchain-community==0.3.7
Expand Down
6 changes: 2 additions & 4 deletions app/src/content/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ def main():
st_common.set_default_state("test_set", None)
st_common.set_default_state("temp_dir", None)

# TO CHECK
# file_path = "temp_file.csv"
# if os.path.exists(file_path):
# os.remove(file_path)

if state.toggle_generate_test:
st.header("Q&A Test Dataset Generation")
Expand Down Expand Up @@ -256,6 +252,8 @@ def main():
# Generate Q&A
qa_file = os.path.join(state["temp_dir"], f"{file_name}_{str(qa_count)}_test_set.json")
state.qa_file = qa_file
logger.info("calling generate with client: ")
logger.info(llm_client)
state.test_set = utilities.generate_qa(qa_file, kb, qa_count, client=llm_client)
placeholder.empty()
st.success("Q&A Generation Succeeded.", icon="✅")
Expand Down
8 changes: 4 additions & 4 deletions app/src/modules/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ def record_update():
# Text input for the question, storing the user's input in the session state
state.index_output = st.write("Record: " + str(state.index + 1) + "/" + str(state.df.shape[0]))
state.hide_input = st.checkbox("Hide", value=state.hide_input)
state.question_input = st.text_area("question", height=1, value=state.question_input)
state.reference_answer_input = st.text_area("Reference answer", height=1, value=state.reference_answer_input)
state.question_input = st.text_area("question", height=100, value=state.question_input)
state.reference_answer_input = st.text_area("Reference answer", height=100, value=state.reference_answer_input)
state.reference_context_input = st.text_area(
"Reference context", height=10, value=state.reference_context_input, disabled=True
"Reference context", height=100, value=state.reference_context_input, disabled=True
)
state.metadata_input = st.text_area("Metadata", height=1, value=state.metadata_input, disabled=True)
state.metadata_input = st.text_area("Metadata", height=100, value=state.metadata_input, disabled=True)

if save_clicked:
st.success("Q&A saved successfully!")
Expand Down
7 changes: 6 additions & 1 deletion app/src/modules/st_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,13 @@ def create_zip(state_dict_filt, provider):
def check_hybrid_conf(session_state_json):

chatModel = state.ll_model_config.get(session_state_json["ll_model"])
embModel = state.embed_model_config.get(state.rag_params["model"])

if "rag_params" in state and "model" in state.rag_params:
embModel = state.embed_model_config.get(state.rag_params["model"])
else:
# Handle the case where rag_params or "model" key does not exist
embModel = None # or some default value

logger.info("Model: %s",session_state_json["ll_model"])
logger.info("Embedding Model embModel: %s",embModel)
logger.info("Chat Model: %s",chatModel)
Expand Down
5 changes: 3 additions & 2 deletions app/src/modules/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def get_ll_model(model, ll_models_config=None, giskarded=False):
lm_params = ll_models_config[model]

logger.info(
"Configuring LLM - URL: %s; Temp - %s; Max Tokens - %s",
"Configuring LLM - Model: %s; URL: %s; Temp - %s; Max Tokens - %s",
model,
lm_params["url"],
lm_params["temperature"][0],
lm_params["max_tokens"][0],
Expand Down Expand Up @@ -115,7 +116,7 @@ def get_ll_model(model, ll_models_config=None, giskarded=False):
elif llm_api == "ChatPerplexity":
client = ChatPerplexity(pplx_api_key=lm_params["api_key"], model_kwargs=common_params)
elif llm_api == "ChatOllama":
client = ChatOllama(base_url=lm_params["url"], model_kwargs=common_params)
client = ChatOllama(model=model,base_url=lm_params["url"], model_kwargs=common_params)
## End - Add Additional Model Authentication Here
api_accessible, err_msg = is_url_accessible(llm_url)

Expand Down
3 changes: 2 additions & 1 deletion widget/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ document.addEventListener('DOMContentLoaded', () => {
});

const data = await response.json();
return data.choices[0].message.content;
return data.answer;
//return data.choices[0].message.content;
} catch (error) {
console.error('Error fetching API:', error);
return "Sorry, I couldn't connect to the server.";
Expand Down