-
Notifications
You must be signed in to change notification settings - Fork 9
/
About.py
107 lines (90 loc) · 3.71 KB
/
About.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Import necessary modules with clear names
import sys
import traceback
from src.db.database.creation_utilities import CreationUtilities
from src.db.models.default_data import (
ensure_conversation_role_types,
ensure_supported_source_control_providers,
)
from src.db.models.vector_database import VectorDatabase
import src.ui.streamlit_shared as ui_shared
import streamlit as st
# Constants
PAGE_TITLE = "Hello"
PAGE_ICON = "😎"
ABOUT_JARVIS_HEADER = "# About Jarvis 🤖"
# Documentation strings and error messages
ERROR_MSG_ROLE_TYPES = "Error ensuring conversation role types are in the database: {}. You probably didn't run the `migration_utilities.create_migration()`"
ERROR_MSG_SOURCE_CONTROL = "Error ensuring supported source control providers are in the database: {}. You probably didn't run the `migration_utilities.create_migration()`"
def verify_database():
"""
Verifies that the database is set up correctly by performing the following:
- Enables the pgvector extension if not already enabled.
- Runs migration scripts to set up the database schema.
- Ensures that default conversation role types are populated in the database.
"""
# Enable pgvector extension
CreationUtilities.create_pgvector_extension()
# Run migration scripts
CreationUtilities.run_migration_scripts()
# Populate default conversation role types
try:
ensure_conversation_role_types()
except Exception as e:
print(ERROR_MSG_ROLE_TYPES.format(e))
try:
ensure_supported_source_control_providers()
except Exception as e:
print(ERROR_MSG_SOURCE_CONTROL.format(e))
def setup_streamlit_interface():
"""
Configures the Streamlit page and displays the UI components for the application.
"""
try:
# Set Streamlit page configuration
try:
st.set_page_config(page_title=PAGE_TITLE, page_icon=PAGE_ICON)
# Display the header for the About section
st.write(ABOUT_JARVIS_HEADER)
except:
pass
# Display the version information from the shared UI module
ui_shared.show_version()
# Display the capabilities of Jarvis
st.markdown(
"""
Contains a general purpose AI that can do a lot of things.
Capabilities:
- ✅ Chat with the AI (Conversation Mode)
- ✅ Get the News
- ✅ Get the Weather
- ✅ Upload your Documents, and talk about them with the AI, including:
- ✅ Search for information
- ✅ Summarize a topic or whole documents
- ✅ Perform multi-hop queries, such as "What is the capital of the country that has the highest population in Europe?"
- ✅ Code Understanding
- ✅ Code Summarization
- ✅ Code Review
- ✅ Code Documentation
- ✅ Unit Test Generation
"""
)
except:
# This whole thing is dumb as shit, and I don't know why python is like this... maybe I'm just a noob.
# Check to see if the type of exception is a "StopException",
# which gets thrown when a user navigates away from a page while the debugger is attached.
# But we don't have access to that type, so we have to check the string. Dumb.
# Get the last exception
exc_type, exc_value, exc_traceback = sys.exc_info()
if "StopException" in str(
exc_value.__class__
) or "StreamlitAPIException" in str(exc_value.__class__):
# If so, then just return
return
else:
# Otherwise, raise the exception
raise
# Main execution
if __name__ == "__main__":
verify_database()
setup_streamlit_interface()