Rudert commited on
Commit
0e723e3
·
verified ·
1 Parent(s): 94c307f

Upload 9 files

Browse files
DarkGPTV2/README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: DarkGPT
3
+ emoji: 🐨
4
+ colorFrom: green
5
+ colorTo: yellow
6
+ sdk: streamlit
7
+ sdk_version: 1.32.2
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
DarkGPTV2/app.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from g4f.client import Client
3
+ import sqlite3
4
+ import google.generativeai as genai
5
+ # import pyttsx3
6
+ import pyperclip
7
+ import os
8
+
9
+ api_key = os.getenv("Gemini_api")
10
+
11
+
12
+
13
+
14
+ st.set_page_config(page_title="DarkGPT",
15
+ page_icon="🤖",
16
+ initial_sidebar_state="expanded"
17
+ )
18
+
19
+
20
+ def local_css(file_name):
21
+ with open(file_name) as f:
22
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
23
+
24
+
25
+ local_css("style.css")
26
+
27
+ # Create a connection to the database
28
+ conn = sqlite3.connect('chat_history.db')
29
+ c = conn.cursor()
30
+
31
+ # Create table if not exists
32
+ try:
33
+ c.execute('''CREATE TABLE IF NOT EXISTS chat_history
34
+ (conversation_id INTEGER, role TEXT, content TEXT)''')
35
+ conn.commit()
36
+ except Exception as e:
37
+ st.error(f"An error occurred: {e}")
38
+
39
+
40
+
41
+ # Streamlit app
42
+ def main():
43
+ try:
44
+ if "chat_history" not in st.session_state:
45
+ st.session_state.chat_history = []
46
+
47
+ if "conversation_id" not in st.session_state:
48
+ st.session_state.conversation_id = 1
49
+
50
+ models = {
51
+ "🚀 Airoboros 70B": "airoboros-70b",
52
+ "👑 Gemini 1.0": "gemini-1.0-pro",
53
+ "🧨 Gemini 1.0 Pro ": "gemini-1.0-pro-001",
54
+ "⚡ Gemini 1.0 pro latest": "gemini-1.0-pro-latest",
55
+ "🔮 Gemini Pro": "gemini-pro",
56
+ }
57
+
58
+ columns = st.columns(3) # Split the layout into three columns
59
+ with columns[0]:
60
+ st.header("DarkGPT")
61
+
62
+ with columns[2]:
63
+
64
+ selected_model_display_name = st.selectbox("Select Model", list(models.keys()), index=0)
65
+ selected_model = models[selected_model_display_name]
66
+
67
+ with columns[1]:
68
+ pass
69
+ # if st.button("summarize"):
70
+ # st.switch_page('pages/summarize.py')
71
+
72
+
73
+ # Sidebar (left side) - New chat button
74
+ if st.sidebar.button("✨ New Chat", key="new_chat_button"):
75
+ st.session_state.chat_history.clear()
76
+ st.session_state.conversation_id += 1
77
+
78
+ # Sidebar (left side) - Display saved chat
79
+ st.sidebar.write("Chat History")
80
+ c.execute("SELECT DISTINCT conversation_id FROM chat_history")
81
+ conversations = c.fetchall()
82
+ for conv_id in reversed(conversations):
83
+ c.execute("SELECT content FROM chat_history WHERE conversation_id=? AND role='bot' LIMIT 1",
84
+ (conv_id[0],))
85
+ first_bot_response = c.fetchone()
86
+ if first_bot_response:
87
+ if st.sidebar.button(" ".join(first_bot_response[0].split()[0:5])):
88
+ display_conversation(conv_id[0])
89
+
90
+ # Sidebar (left side) - Clear Chat History button
91
+ if st.sidebar.button("Clear Chat History ✖️"):
92
+ st.session_state.chat_history.clear()
93
+ c.execute("DELETE FROM chat_history")
94
+ conn.commit()
95
+
96
+ # Main content area (center)
97
+ st.markdown("---")
98
+
99
+ user_input = st.chat_input("Ask Anything ...")
100
+
101
+ if user_input:
102
+ if selected_model == "airoboros-70b":
103
+ try:
104
+ client = Client()
105
+ response = client.chat.completions.create(
106
+ model=models[selected_model_display_name],
107
+ messages=[{"role": "user", "content": user_input}],
108
+ )
109
+ bot_response = response.choices[0].message.content
110
+
111
+ st.session_state.chat_history.append({"role": "user", "content": user_input})
112
+ st.session_state.chat_history.append({"role": "bot", "content": bot_response})
113
+
114
+ # Store chat in the database
115
+ for chat in st.session_state.chat_history:
116
+ c.execute("INSERT INTO chat_history VALUES (?, ?, ?)",
117
+ (st.session_state.conversation_id, chat["role"], chat["content"]))
118
+ conn.commit()
119
+
120
+ # Display chat history
121
+ for index, chat in enumerate(st.session_state.chat_history):
122
+ with st.chat_message(chat["role"]):
123
+ if chat["role"] == "user":
124
+ st.markdown(chat["content"])
125
+ elif chat["role"] == "bot":
126
+ st.markdown(chat["content"])
127
+
128
+
129
+ except Exception as e:
130
+ st.error(f"An error occurred: {e}")
131
+
132
+ else:
133
+ try:
134
+ # GEMINI Replace with your Gemini Api key
135
+ GOOGLE_API_KEY = api_key
136
+ genai.configure(api_key=GOOGLE_API_KEY)
137
+ model = genai.GenerativeModel(selected_model)
138
+ prompt = user_input
139
+ response = model.generate_content(prompt)
140
+ bot_response = response.candidates[0].content.parts[0].text
141
+
142
+ st.session_state.chat_history.append({"role": "user", "content": user_input})
143
+ st.session_state.chat_history.append({"role": "bot", "content": bot_response})
144
+
145
+ # Store chat in the database
146
+ for chat in st.session_state.chat_history:
147
+ c.execute("INSERT INTO chat_history VALUES (?, ?, ?)",
148
+ (st.session_state.conversation_id, chat["role"], chat["content"]))
149
+ conn.commit()
150
+
151
+ for index, chat in enumerate(st.session_state.chat_history):
152
+ with st.chat_message(chat["role"]):
153
+ if chat["role"] == "user":
154
+ st.markdown(chat["content"])
155
+ elif chat["role"] == "bot":
156
+ st.markdown(chat["content"])
157
+
158
+ except Exception as e:
159
+ st.error(f"An error occurred: {e}")
160
+
161
+
162
+
163
+
164
+
165
+ except Exception as e:
166
+ st.error(f"An error occurred: {e}")
167
+
168
+
169
+ def display_conversation(conversation_id):
170
+ c.execute("SELECT * FROM chat_history WHERE conversation_id=?", (conversation_id,))
171
+ chats = c.fetchall()
172
+ st.markdown(f"### Conversation")
173
+ for chat in chats:
174
+ st.markdown(f"{chat[1]}")
175
+ st.markdown(f"{chat[2]}")
176
+
177
+
178
+ if __name__ == "__main__":
179
+ main()
DarkGPTV2/chat_history.db ADDED
Binary file (16.4 kB). View file
 
DarkGPTV2/cookies.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from g4f.cookies import set_cookies
2
+
3
+ set_cookies(".bing.com", {
4
+ "_clck": "w3y6fr%7C2%7Cfjl%7C0%7C1517"
5
+ })
6
+ set_cookies("chat.openai.com", {
7
+ "__cflb": "0H28vVfF4aAyg2hkHEuhVVUPGkAFmYvk57xoxRMRm1X"
8
+ })
9
+ set_cookies(".google.com", {
10
+ "__Secure-3PSID": "g.a000hQh_KYcwS81vIoGwzKsyOPzas0X1x5e-k5t1hP-yKs9Glr4Y3QvqZySWierihtij8oAHvgACgYKAcgSAQASFQHGX2Mi2gQjmlI3XdU3m8xFFwtpzRoVAUF8yKoOoZXsIMZcs3KirlD37H8A0076"
11
+ })
DarkGPTV2/gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
DarkGPTV2/howtouse.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GPT Chat Explorer
2
+
3
+ GPT Chat Explorer is an interactive web application that allows users to engage in conversations with various GPT (Generative Pre-trained Transformer) models in real-time. This repository contains the source code for the application.
4
+
5
+ ## Features
6
+
7
+ - **Real-time Conversations:** Engage in natural conversations with GPT models and explore their responses in real-time.
8
+ - **Chat History:** Review and manage chat history organized by conversation ID for easy reference.
9
+ - **Model Selection:** Choose from a selection of GPT models, including GPT-3.5 Turbo, GPT-4, and more.
10
+ - **Custom Styling:** Customize the appearance of the app with custom CSS styles to suit your preferences.
11
+ - **Clear Chat History:** Easily clear chat history with a single click to start fresh.
12
+ - **Interactive Sidebar:** Access key functionalities such as starting a new chat and clearing chat history conveniently from the sidebar.
13
+ - **Error Handling:** Robust error handling ensures smooth operation and provides feedback in case of any issues.
14
+ - **Timestamped Conversations:** View conversation history with timestamps for each message, providing context and chronological order.
15
+ - **Responsive Design:** Enjoy a seamless experience across devices with responsive design elements.
16
+
17
+ ## Getting Started
18
+
19
+ To get started with the GPT Chat Explorer, follow these steps:
20
+
21
+ 1. **Clone the Repository:**
22
+ ```
23
+ git clone https://github.com/codewithdark-git/DarkGPT-Chatbot.git
24
+ ```
25
+
26
+ 2. **Install Dependencies:**
27
+ ```
28
+ pip install -r requirements.txt
29
+ ```
30
+
31
+ 3. **Run the Application:**
32
+ ```
33
+ streamlit run app.py
34
+ ```
35
+
36
+ 4. **Start Chatting:**
37
+ Open the application in your web browser and start chatting with GPT models!
38
+
39
+ ## Contributing
40
+
41
+ Contributions are welcome! If you'd like to contribute to the project, please follow these steps:
42
+
43
+ 1. Fork the repository.
44
+ 2. Create a new branch (`git checkout -b feature/new-feature`).
45
+ 3. Make your changes and commit them (`git commit -am 'Add new feature'`).
46
+ 4. Push to the branch (`git push origin feature/new-feature`).
47
+ 5. Create a new Pull Request.
48
+
49
+ ## License
50
+
51
+ This project is licensed under the MIT License - see the [LICENSE](../Chatbot/LICENSE) file for details.
52
+
53
+ ## Acknowledgements
54
+
55
+ - This project was inspired by the capabilities of GPT models and the desire to create an interactive chat exploration tool.
56
+ - Special thanks to the Streamlit team for providing a powerful framework for building interactive web applications.
DarkGPTV2/pages/summarize.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import time
3
+ from io import StringIO
4
+ import nltk
5
+ from nltk.tokenize import word_tokenize, sent_tokenize
6
+ from nltk.corpus import stopwords
7
+ import readtime
8
+ import textstat
9
+ from transformers import pipeline
10
+
11
+ st.set_page_config(page_title="DarkGPT",
12
+ page_icon="🤖",
13
+ layout="wide",
14
+ initial_sidebar_state="expanded"
15
+ )
16
+
17
+ # Function to summarize text using BART model
18
+ def summarize_text(input_text):
19
+ summarizer = pipeline("summarization")
20
+ summarized_text = summarizer(input_text, max_length=10050, min_length=50, do_sample=False)[0]['summary_text']
21
+ return summarized_text
22
+
23
+ # Function to analyze text and return metrics
24
+ def analyze_text(input_text):
25
+ nltk.download('punkt')
26
+ tokenized_words = word_tokenize(input_text)
27
+ reading_time = readtime.of_text(input_text)
28
+ text_complexity = textstat.flesch_reading_ease(input_text)
29
+ lexical_richness = len(set(tokenized_words)) / len(tokenized_words)
30
+ num_sentences = len(sent_tokenize(input_text))
31
+ analysis_results = {
32
+ 'reading_time': reading_time,
33
+ 'text_complexity': text_complexity,
34
+ 'lexical_richness': lexical_richness,
35
+ 'num_sentences': num_sentences
36
+ }
37
+ return analysis_results
38
+
39
+ # Function to display the homepage
40
+ def display_homepage():
41
+ st.markdown("<h1 style='text-align: center; color: white; font-size:28px;'>Welcome to DarkGPT!🧨</h1>", unsafe_allow_html=True)
42
+ st.markdown("<h3 style='text-align: center; font-size:56px;'<p>🤖</p></h3>", unsafe_allow_html=True)
43
+ st.markdown("<h3 style='text-align: center; color: grey; font-size:20px;'>DarkGPT: Your AI text assistant for quick summarization and analysis. Summarize text, analyze complexity, and get insights instantly.!</h3>", unsafe_allow_html=True)
44
+
45
+ st.markdown('___')
46
+ st.markdown("<h3 style='text-align: left; color:#F63366; font-size:18px;'><b>What is this App about?<b></h3>", unsafe_allow_html=True)
47
+ st.write("The provided code is a Streamlit web application named 'DarkGPT' that allows users to summarize and analyze text. Here's an overview of each page and the footer mentioning the author:")
48
+ st.markdown("<h3 style='text-align: left; color:#F63366; font-size:18px;'><b>Display Functionality:<b></h3>", unsafe_allow_html=True)
49
+
50
+ st.markdown("Homepage:\n"
51
+ "- Displays a welcome message and introduction to the DarkGPT app.\n"
52
+ "- Provides information about the purpose and target audience of the app.\n"
53
+ "- Users are encouraged to explore the app's features and contribute to its open-source development on GitHub.")
54
+
55
+ st.markdown("Summarization Page:\n"
56
+ "- Allows users to input text or upload a file for summarization.\n"
57
+ "- Users can choose between inputting text directly or uploading a file.\n"
58
+ "- Provides an example text for users to test.\n"
59
+ "- After input, users can click the 'Summarize' button to generate a summary using the BART model.\n"
60
+ "- Error messages are displayed if input text length requirements are not met.")
61
+
62
+ st.markdown("Analysis Page:\n"
63
+ "- Similar to the Summarization page, but focuses on analyzing text.\n"
64
+ "- Users can input text or upload a file for analysis.\n"
65
+ "- Provides an example text for users to test.\n"
66
+ "- After input, users can click the 'Analyze' button to generate various metrics such as reading time, text complexity, lexical richness, and number of sentences.\n"
67
+ "- Error messages are displayed if input text length requirements are not met.")
68
+
69
+ footer = '''
70
+ <footer style="text-align: center; margin-top: 50px; font-family: Arial, sans-serif; color: #555;">
71
+ <p>Developed by DarkCoder</p>
72
+ <p>
73
+ <a href="https://github.com/codewithdark-git" target="_blank" style="text-decoration: none; color: #007bff; margin-right: 10px;">GitHub</a>
74
+ <a href="https://www.linkedin.com/in/codewithdark/" target="_blank" style="text-decoration: none; color: #007bff; margin-right: 10px;">Linkedin</a>
75
+ <a href="https://www.facebook.com/codewithdark.fb/" target="_blank" style="text-decoration: none; color: #007bff;">Facebook</a>
76
+ </p>
77
+ </footer>
78
+ '''
79
+
80
+ # Display the footer
81
+ st.markdown(footer, unsafe_allow_html=True)
82
+
83
+ # Function to display the text summarization page
84
+ def display_summarization_page():
85
+ st.markdown("<h4 style='text-align: center; color:grey;'>Accelerate knowledge with DarkGPT &#129302;</h4>", unsafe_allow_html=True)
86
+ st.text('')
87
+ st.markdown("<h3 style='text-align: left; color:#F63366; font-size:28px;'>Summarize</h3>", unsafe_allow_html=True)
88
+ st.text('')
89
+
90
+ source = st.radio("How would you like to start? Choose an option below", ("I want to input some text", "I want to upload a file"))
91
+ st.text('')
92
+
93
+ s_example = "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to the natural intelligence displayed by humans or animals. Leading AI textbooks define the field as the study of 'intelligent agents': any system that perceives its environment and takes actions that maximize its chance of achieving its goals. Some popular accounts use the term 'artificial intelligence' to describe machines that mimic cognitive functions that humans associate with the human mind, such as learning and problem solving, however this definition is rejected by major AI researchers. AI applications include advanced web search engines, recommendation systems (used by YouTube, Amazon and Netflix), understanding human speech (such as Siri or Alexa), self-driving cars (such as Tesla), and competing at the highest level in strategic game systems (such as chess and Go). As machines become increasingly capable, tasks considered to require intelligence are often removed from the definition of AI, a phenomenon known as the AI effect. For instance, optical character recognition is frequently excluded from things considered to be AI, having become a routine technology."
94
+
95
+ if source == 'I want to input some text':
96
+ input_su = st.text_area("Use the example below or input your own text in English (between 1,000 and 10,000 characters)", value=s_example, max_chars=10000, height=330)
97
+ if st.button('Summarize'):
98
+ if len(input_su) < 50:
99
+ st.error('Please enter a text in English of minimum 1,000 characters')
100
+ else:
101
+ # Call the summarization function
102
+ summarized_text = summarize_text(input_su)
103
+ st.success(summarized_text)
104
+ st.balloons()
105
+
106
+ if source == 'I want to upload a file':
107
+ file = st.file_uploader('Upload your file here', type=['txt'])
108
+ if file is not None:
109
+ stringio = StringIO(file.getvalue().decode("utf-8"))
110
+ string_data = stringio.read()
111
+ if len(string_data) < 50 or len(string_data) > 10000:
112
+ st.error('Please upload a file between 50 and 10,000 characters')
113
+ else:
114
+ # Call the summarization function
115
+ summarized_text = summarize_text(string_data)
116
+ st.success(summarized_text)
117
+ st.balloons()
118
+
119
+ # Function to display the text analysis page
120
+ def display_analysis_page():
121
+ st.markdown("<h4 style='text-align: center; color:grey;'>Accelerate knowledge with DarkGPT &#129302;</h4>", unsafe_allow_html=True)
122
+ st.text('')
123
+ st.markdown("<h3 style='text-align: left; color:#F63366; font-size:28px;'>Analyze</h3>", unsafe_allow_html=True)
124
+ st.text('')
125
+
126
+ a_example = "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to the natural intelligence displayed by humans or animals. Leading AI textbooks define the field as the study of 'intelligent agents': any system that perceives its environment and takes actions that maximize its chance of achieving its goals. Some popular accounts use the term 'artificial intelligence' to describe machines that mimic cognitive functions that humans associate with the human mind, such as learning and problem solving, however this definition is rejected by major AI researchers. AI applications include advanced web search engines, recommendation systems (used by YouTube, Amazon and Netflix), understanding human speech (such as Siri or Alexa), self-driving cars (such as Tesla), and competing at the highest level in strategic game systems (such as chess and Go). As machines become increasingly capable, tasks considered to require intelligence are often removed from the definition of AI, a phenomenon known as the AI effect. For instance, optical character recognition is frequently excluded from things considered to be AI, having become a routine technology."
127
+
128
+ source = st.radio("How would you like to start? Choose an option below", ("I want to input some text", "I want to upload a file"))
129
+ st.text('')
130
+
131
+ if source == 'I want to input some text':
132
+ input_me = st.text_area("Use the example below or input your own text in English (maximum of 10,000 characters)", max_chars=10000, value=a_example, height=330)
133
+ if st.button('Analyze'):
134
+ if len(input_me) > 10000:
135
+ st.error('Please enter a text in English of maximum 10,000 characters')
136
+ else:
137
+ # Call the text analysis function
138
+ analysis_results = analyze_text(input_me)
139
+ st.write('Reading Time:', analysis_results['reading_time'])
140
+ st.write('Text Complexity:', analysis_results['text_complexity'])
141
+ st.write('Lexical Richness:', analysis_results['lexical_richness'])
142
+ st.write('Number of Sentences:', analysis_results['num_sentences'])
143
+ st.balloons()
144
+
145
+ if source == 'I want to upload a file':
146
+ file = st.file_uploader('Upload your file here', type=['txt'])
147
+ if file is not None:
148
+ stringio = StringIO(file.getvalue().decode("utf-8"))
149
+ string_data = stringio.read()
150
+ if len(string_data) > 10000:
151
+ st.error('Please upload a file of maximum 10,000 characters')
152
+ else:
153
+ # Call the text analysis function
154
+ analysis_results = analyze_text(string_data)
155
+ st.write('Reading Time:', analysis_results['reading_time'])
156
+ st.write('Text Complexity:', analysis_results['text_complexity'])
157
+ st.write('Lexical Richness:', analysis_results['lexical_richness'])
158
+ st.write('Number of Sentences:', analysis_results['num_sentences'])
159
+ st.balloons()
160
+
161
+ # Main function to run the Streamlit app
162
+ def main():
163
+ st.sidebar.header('DarkGPT, I want to :crystal_ball:')
164
+ nav = st.sidebar.radio('', ['Go to homepage', 'Summarize text', 'Analyze text'])
165
+
166
+ if nav == 'Go to homepage':
167
+ display_homepage()
168
+ elif nav == 'Summarize text':
169
+ display_summarization_page()
170
+ elif nav == 'Analyze text':
171
+ display_analysis_page()
172
+
173
+ if __name__ == "__main__":
174
+ main()
DarkGPTV2/requirements.txt ADDED
Binary file (6.32 kB). View file
 
DarkGPTV2/style.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ section[data-testid="stSidebar"] div.stButton button {
2
+ border: none;
3
+ color: white;
4
+ padding: auto; /* Adjust padding */
5
+ text-align: center;
6
+ text-decoration: none;
7
+ display: inline-block;
8
+ font-size: 14px;
9
+ margin: -2px -2px;
10
+ transition-duration: 0.4s;
11
+ cursor: pointer;
12
+ border-radius: 10px;
13
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
14
+ min-width: 200px; /* Set minimum width */
15
+ height: auto;
16
+ white-space: normal; /* Allow long text to wrap */
17
+ word-wrap: break-word; /* Allow long text to wrap */
18
+ }
19
+
20
+ section[data-testid="stSidebar"] div.stButton button:hover {
21
+ background-color: black; /* Darker green on hover */
22
+ }