-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01d61d5
commit 9d920d8
Showing
8 changed files
with
513 additions
and
86 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/04_educator_profile.ipynb. | ||
|
||
# %% auto 0 | ||
__all__ = ['EducatorProfileView'] | ||
|
||
# %% ../nbs/04_educator_profile.ipynb 1 | ||
from ipywidgets import VBox, HBox, HTML, Text, Button, Label | ||
|
||
# %% ../nbs/04_educator_profile.ipynb 2 | ||
class EducatorProfileView(VBox): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
# Username input | ||
self.username_label = Label('Name:') | ||
self.username_input = Text(placeholder='Enter your name') | ||
|
||
# Password input | ||
self.key_label = Label('Educator:') | ||
self.key_input = Text(placeholder='Enter Your Level', password=True) | ||
|
||
# Next button | ||
self.next_button = Button(description='Next') | ||
|
||
# Arrange labels and inputs horizontally | ||
self.username_box = HBox([self.username_label, self.username_input]) | ||
self.key_box = HBox([self.key_label, self.key_input]) | ||
|
||
# Arrange widgets vertically | ||
self.children = [ | ||
HTML('<h2>User Profile</h2>'), # Heading | ||
self.username_box, # Username label and input box | ||
self.key_box, # Password label and input box | ||
HBox([self.next_button], layout={'justify_content': 'flex-end'}), # Login button aligned to the right | ||
] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_llm.ipynb. | ||
|
||
# %% auto 0 | ||
__all__ = ['LLM', 'FileModel'] | ||
|
||
# %% ../nbs/01_llm.ipynb 1 | ||
from traitlets import HasTraits, Unicode | ||
from langchain_openai import ChatOpenAI | ||
import os | ||
from langchain.docstore.document import Document | ||
from langchain_community.document_loaders import UnstructuredMarkdownLoader | ||
from langchain_openai import OpenAIEmbeddings | ||
from langchain_community.document_loaders import PyPDFLoader | ||
from langchain_community.vectorstores import FAISS | ||
from langchain_openai import OpenAIEmbeddings | ||
|
||
# %% ../nbs/01_llm.ipynb 2 | ||
class LLM(HasTraits): | ||
|
||
def __init__(self, filepath='OPENAI_API_KEY'): | ||
super().__init__() | ||
|
||
with open(filepath, 'r') as file: | ||
openai_api_key = file.read().strip() | ||
os.environ['OPENAI_API_KEY'] = openai_api_key | ||
self.llm = ChatOpenAI(model_name="gpt-3.5-turbo") | ||
|
||
# %% ../nbs/01_llm.ipynb 4 | ||
class FileModel(LLM): | ||
# Define a Unicode string trait | ||
select = Unicode() | ||
|
||
def __init__(self): | ||
super().__init__() | ||
#self.embeddings = OpenAIEmbeddings() | ||
#doc = Document(page_content='Course') | ||
#self.db = FAISS.from_documents(doc, self.embeddings) | ||
|
||
def save_content_from_upload(values): | ||
for value in values: | ||
with open('course_files/' + value['name'], "wb") as fp: | ||
fp.write(value['content']) | ||
|
||
def load_text(self, text): | ||
doc = Document(page_content=text) | ||
db = FAISS.from_documents(doc, self.embeddings) | ||
self.db.merge_from(db) | ||
|
||
def load_pdf(self, filepath): | ||
loader = PyPDFLoader(filepath) | ||
pages = loader.load_and_split() | ||
db = FAISS.from_documents(pages, self.embeddings) | ||
self.db.merge_from(db) | ||
|
||
def load_markdown(filepath): | ||
loader = UnstructuredMarkdownLoader(filepath, mode="elements") #mode=elements breaks up the text into chunks | ||
doc = loader.load() | ||
db = FAISS.from_documents(doc, embeddings) | ||
self.db.merge_from(db) | ||
|
||
def save_content_from_upload(values): | ||
for value in values: | ||
with open(value['name'], "wb") as fp: | ||
fp.write(value['content']) |
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
Oops, something went wrong.