Skip to content

Commit

Permalink
comments and consistent single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
choccccy committed Jul 17, 2023
1 parent a35cef1 commit 1680811
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 13 additions & 10 deletions demo/chat_pdf_streamlit_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@
LLM = os.getenv('LLM', 'LLM') # TODO: get this from non-openai openai api hosts
LLM_HOST = os.getenv('LLM_HOST', 'my-llm-host')
LLM_PORT = os.getenv('LLM_PORT', '8000')
# LLM "temperature"
LLM_TEMP = float(os.getenv('LLM_TEMP', '1'))
N_CTX = int(os.getenv('N_CTX', '2048')) # LLM max context size
K = int(os.getenv('K', '6')) # K - how many chunks to return for query context
# LLM max context size
N_CTX = int(os.getenv('N_CTX', '2048'))
# K - how many chunks to return for query context
K = int(os.getenv('K', '6'))
# Chunk size is the number of characters counted in the chunks
EMBED_CHUNK_SIZE = int(os.getenv('EMBED_CHUNK_SIZE', '500'))
# Chunk Overlap to connect ends of chunks together
EMBED_CHUNK_OVERLAP = int(os.getenv('EMBED_CHUNK_OVERLAP', '100'))
# sLLM for embeddings
# small LM for embeddings
# default https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
DOC_EMBEDDINGS_LLM = os.getenv('EMBED_CHUNK_OVERLAP', 'all-MiniLM-L6-v2')

Expand Down Expand Up @@ -121,7 +124,7 @@ async def async_main(openai_api, model, LLM_TEMP):
Oori — Ask your PDF 📄💬
'''
# create file upload box on Streamlit, set from the user's upload
pdf = st.file_uploader("Upload a PDF", type=["pdf"], accept_multiple_files=False)
pdf = st.file_uploader('Upload a PDF', type=['pdf'], accept_multiple_files=False)

if pdf:
# Show throbber, vectorize the PDF, and setup for similarity search
Expand Down Expand Up @@ -178,7 +181,7 @@ async def async_main(openai_api, model, LLM_TEMP):
max_tokens=1024 # Maximum tokens to return (Default 16)
)

# Response is a json-like object; extract the text
# Response is a json-like object
print('\nFull response data from LLM:\n', response)

# Response is a json-like object;
Expand All @@ -196,10 +199,10 @@ def main():
# Describing function via comments instead:
# Set up Streamlit page, LLM host connection & launch the main loop
st.set_page_config(
page_title="Ask your PDF",
page_icon="📄💬",
layout="wide",
initial_sidebar_state="expanded",
page_title='Ask your PDF',
page_icon='📄💬',
layout='wide',
initial_sidebar_state='expanded',
)

# Use OpenAI API if specified, otherwise emulate with supplied host, etc.
Expand All @@ -217,6 +220,6 @@ def main():
asyncio.run(async_main(openai_api, model, LLM_TEMP))


if __name__ == "__main__":
if __name__ == '__main__':
# TODO: Look into isolating huggingface's one time per process setup routines
main()
4 changes: 3 additions & 1 deletion demo/demo.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copy to .env in the same dir, and update as needed
# Used by:
# demo/alpaca_simple_qa_discord.py
# demo/chat_pdf_streamlit_ui

# Used by demo/alpaca_simple_qa_discord.py
# DISCORD_TOKEN={REPLACEME}
LLM_HOST=http://{my-llm-host}
# LLM_PORT=8000
Expand Down

0 comments on commit 1680811

Please sign in to comment.