This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tempfile | |
import streamlit as st | |
from streamlit_chat import message | |
from rag import ChatCSV | |
# adds a title for the web page | |
st.set_page_config(page_title="Resume Chatbot") | |
def display_messages(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain_community.vectorstores import Chroma | |
from langchain_community.chat_models import ChatOllama | |
from langchain_community.embeddings import FastEmbedEmbeddings | |
from langchain.schema.output_parser import StrOutputParser | |
from langchain_community.document_loaders.csv_loader import CSVLoader | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
from langchain.schema.runnable import RunnablePassthrough | |
from langchain.prompts import PromptTemplate | |
from langchain.vectorstores.utils import filter_complex_metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Thank you!</h1> | |
<p>The prompt: {{ prompt }}</p> | |
<p>The response:</p> {{ response }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Ask a question.</h1> | |
<form method="POST" action="/submit"> | |
<textarea id="prompt" name="prompt" rows="4" cols="50">{{ request.form['prompt'] }}</textarea> | |
<p> </p> | |
<input class="btn" type="submit" value="Submit"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import semantic_kernel as sk | |
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion | |
def chatgpt(prompt): | |
kernel = sk.Kernel() | |
api_key, org_id = sk.openai_settings_from_dot_env() | |
kernel.add_text_completion_service("dv", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id)) | |
with open('resume.txt', encoding='utf-8') as f: | |
lines = f.readlines() | |
user_input = ' '.join(lines) + ' ' + prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import semantic_kernel as sk | |
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion | |
kernel = sk.Kernel() | |
api_key, org_id = sk.openai_settings_from_dot_env() | |
kernel.add_text_completion_service("dv", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id)) | |
with open('resume.txt', encoding='utf-8') as f: | |
lines = f.readlines() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot_model(lda, plot='topic_distribution') | |
plot_model(lda, plot='topic_model') | |
plot_model(lda, plot='wordcloud', topic_num = 'Topic 5') | |
plot_model(lda, plot='frequency', topic_num = 'Topic 5') | |
plot_model(lda, plot='bigram', topic_num = 'Topic 5') | |
plot_model(lda, plot='trigram', topic_num = 'Topic 5') | |
plot_model(lda, plot='distribution', topic_num = 'Topic 5') | |
plot_model(lda, plot='sentiment', topic_num = 'Topic 5') | |
plot_model(lda, plot='tsne') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# initialize the setup | |
nlp = setup(data = df, target = 'tweet', session_id = 493, custom_stopwords = [ 'rt', 'https', 'http', 'co', 'amp']) | |
# create the model | |
lda = create_model('lda', num_topics = 6, multi_core = True) | |
# label the data using trained model | |
df_lda = assign_model(lda) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df.shape | |
df.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sampling the data to select only 1000 tweets | |
df = df.sample(1000, random_state=493).reset_index(drop=True) |
NewerOlder