Skip to content

Commit 7857e23

Browse files
authored
Merge pull request #3 from gcapuzzi/test
Test
2 parents 6e4e65c + 51fb588 commit 7857e23

File tree

7 files changed

+59
-6
lines changed

7 files changed

+59
-6
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ dataset*/
3333
responses.txt
3434
secrets.toml
3535
users.db
36-
homepage.py

config.yaml.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
llm_provider: "" # Options: "openai" or "mistral"
2+
model_name: "" # for OpenAI: "gpt-3.5-turbo" or "gpt-4", or "gpt-4-turbo", for Mistral: "mistral-medium" or "mistral-large-latest" or "mistral-small-2506"
3+
embedding_model: "" # "text-embedding-ada-002" or "text-embedding-3-small" for OpenAI or "mistral-embed" for Mistral
4+
use_query_rewriting: false # enable or disable query rewriting
5+
dataset_private_path: "./dataset/private"
6+
dataset_public_path: "./dataset/public"
7+
web_urls: "web_urls"
8+
yt_video_links: "yt_video_links"
9+
text_files: "text_files"
10+
pdf_files: "pdf_files"
11+
rtdocs_files: "rtdocs_files"
12+
html_files: "html_files"
13+
persist_directory: "faiss_index"
14+
host: "127.0.0.1"
15+
port: 8080
16+
system_prompt: ""
17+
query_rewriting_prompt: ""
18+
logo_pth: ""
19+
company_name: ""

homepage.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from utils import load_yaml_file
4+
5+
# Read config data
6+
config_data = load_yaml_file("config.yaml")
7+
8+
def gethomepage():
9+
markdown_string = f"""
10+
<div style="text-align: center;">
11+
<img src={config_data["logo_pth"]} alt="AIFAQ logo" style="height: 110px">
12+
<h1>AI Agent powered by <em>{config_data["company_name"]}</em></h1>
13+
</div>
14+
15+
## Try for free
16+
17+
Here the [Official GitHub Repository](https://github.com/hyperledger-labs/aifaq)
18+
19+
## Links and Resources
20+
21+
AIFAQ Inc. [website](https://aifaqpro.wordpress.com/)
22+
23+
## {config_data["company_name"]}
24+
25+
This chatbot is a {config_data["company_name"]} conversational AI tool. Please, register or login:
26+
"""
27+
return markdown_string

ingest_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def get_vectordb(owner: str, access: str, datasetdir: str):
157157
if config_data["llm_provider"] == "mistral":
158158
embeddings = MistralAIEmbeddings(model=config_data["embedding_model"], mistral_api_key=mistral_api_key)
159159
else: # default to OpenAI
160-
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
160+
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key, model=config_data["embedding_model"])
161161

162162
if documents:
163163
# Create the vector store

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def get_ragchain(filter):
3535
)
3636
else: # default to OpenAI
3737
embeddings = OpenAIEmbeddings(
38-
openai_api_key=openai_api_key
38+
openai_api_key=openai_api_key,
39+
model=config_data["embedding_model"]
3940
)
4041
model = ChatOpenAI(
4142
openai_api_key=openai_api_key,

menu.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import streamlit as st
2+
from utils import load_yaml_file
3+
4+
# Read config data
5+
config_data = load_yaml_file("config.yaml")
26

37
def handle_logout():
48
"""Handle logout action and state cleanup"""
@@ -14,7 +18,8 @@ def authenticated_menu():
1418
handle_logout()
1519

1620
# Show a navigation menu for authenticated users
17-
st.sidebar.page_link("pages/chatbot.py", label="AIFAQ ChatBot")
21+
chatbot_label = config_data["company_name"] + " ChatBot"
22+
st.sidebar.page_link("pages/chatbot.py", label=chatbot_label)
1823
if st.session_state.user_type in ["admin"]:
1924
st.sidebar.page_link("pages/config_page_public.py", label="Config Public Page")
2025
st.sidebar.page_link("pages/config_page_private.py", label="Config Private Page")

pages/chatbot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
# Redirect to app.py if not logged in
1212
menu_with_redirect()
1313

14-
st.markdown("# AIFAQ")
15-
1614
config_path = "./config.yaml"
1715
logo_path = "https://github.com/hyperledger-labs/aifaq/blob/mvt-streamlit/images/logo.png?raw=true"
1816
config_data = load_yaml_file(config_path)
1917

18+
title = config_data["company_name"]
19+
title = "# " + title if title else "# AIFAQ"
20+
st.markdown(title)
21+
2022
# filter public document in case of guest user
2123
filter = None
2224
if st.session_state.user_type in ['guest']:

0 commit comments

Comments
 (0)