Skip to content

Instantly share code, notes, and snippets.

View ecdedios's full-sized avatar

Ednalyn C. De Dios ecdedios

View GitHub Profile
@ecdedios
ecdedios / app.py
Last active January 21, 2024 00:56
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():
@ecdedios
ecdedios / rag.py
Last active January 21, 2024 00:51
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
@ecdedios
ecdedios / submit.html
Created October 6, 2023 02:17
semantic kernel flask output
<h1>Thank you!</h1>
<p>The prompt: {{ prompt }}</p>
<p>The response:</p> {{ response }}</p>
@ecdedios
ecdedios / index.html
Created October 6, 2023 02:12
semantic kernel flask input
<h1>Ask a question.</h1>
<form method="POST" action="/submit">
<textarea id="prompt" name="prompt" rows="4" cols="50">{{ request.form['prompt'] }}</textarea>
<p>&nbsp;</p>
<input class="btn" type="submit" value="Submit">
</form>
@ecdedios
ecdedios / app.py
Last active October 6, 2023 01:17
semantic kernel chatgpt flask
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
@ecdedios
ecdedios / ask.py
Last active October 5, 2023 23:58
semantic kernel chatgpt
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()
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')
# 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)
# sampling the data to select only 1000 tweets
df = df.sample(1000, random_state=493).reset_index(drop=True)