Skip to content

Commit

Permalink
[Refactor] lint (mmz-001#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmz-001 authored Feb 10, 2023
1 parent 187d8a7 commit 0789064
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 22 deletions.
6 changes: 2 additions & 4 deletions knowledge_gpt/embeddings.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
"""Wrapper around OpenAI embedding models."""
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Extra, root_validator

from langchain.embeddings.base import Embeddings
from langchain.utils import get_from_dict_or_env

from openai.error import APIConnectionError, APIError, RateLimitError, Timeout
from pydantic import BaseModel, Extra, root_validator
from tenacity import (
retry,
retry_if_exception_type,
stop_after_attempt,
wait_exponential,
)
from openai.error import Timeout, APIError, APIConnectionError, RateLimitError


class OpenAIEmbeddings(BaseModel, Embeddings):
Expand Down
8 changes: 4 additions & 4 deletions knowledge_gpt/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import streamlit as st
from components.sidebar import sidebar
from openai.error import OpenAIError
from utils import (
embed_docs,
get_answer,
get_sources,
parse_docx,
parse_pdf,
parse_txt,
search_docs,
embed_docs,
text_to_docs,
get_answer,
get_sources,
wrap_text_in_html,
)
from openai.error import OpenAIError


def clear_submit():
Expand Down
23 changes: 12 additions & 11 deletions knowledge_gpt/utils.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores.faiss import FAISS
from langchain import OpenAI, Cohere
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from embeddings import OpenAIEmbeddings
from langchain.llms import OpenAI
from langchain.docstore.document import Document
from langchain.vectorstores import FAISS, VectorStore
import docx2txt
from typing import List, Dict, Any
import re
from io import BytesIO
from typing import Any, Dict, List

import docx2txt
import streamlit as st
from embeddings import OpenAIEmbeddings
from langchain import Cohere, OpenAI
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.docstore.document import Document
from langchain.llms import OpenAI
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import FAISS, VectorStore
from langchain.vectorstores.faiss import FAISS
from openai.error import AuthenticationError
from prompts import STUFF_PROMPT
from pypdf import PdfReader
from openai.error import AuthenticationError


@st.experimental_memo()
Expand Down
20 changes: 19 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ tenacity = "^8.2.0"


[tool.poetry.group.dev.dependencies]
black = {version = "^23.1a1", allow-prereleases = true}
python-dotenv = "^0.21.1"
pytest = "^7.2.1"


[tool.poetry.group.lint.dependencies]
isort = "^5.12.0"
black = {version = "^23.1a1", allow-prereleases = true}

[tool.isort]
profile = "black"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
3 changes: 2 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from knowledge_gpt.utils import get_sources
from langchain.docstore.document import Document

from knowledge_gpt.utils import get_sources


def test_get_sources():
"""Test getting sources from an answer"""
Expand Down

0 comments on commit 0789064

Please sign in to comment.