Skip to content
Snippets Groups Projects
Commit 3a865a42 authored by Ryan Melvin's avatar Ryan Melvin
Browse files

Merge branch 'feature/azure2' into 'main'

Feature/azure2

See merge request !3
parents 9f593a34 cf262e37
No related branches found
No related tags found
1 merge request!3Feature/azure2
...@@ -4,7 +4,7 @@ Uses OpenAI API to determine if a research idea is reasonable and novel for the ...@@ -4,7 +4,7 @@ Uses OpenAI API to determine if a research idea is reasonable and novel for the
## Deploy ## Deploy
### Docker-compose ### Docker-compose
``` ```
docker-compose up docker-compose up --rebuild --force=recreate
``` ```
You can use the `-d` flag at the end to runin in detached (background) mode You can use the `-d` flag at the end to runin in detached (background) mode
...@@ -17,4 +17,6 @@ To stop the app, ...@@ -17,4 +17,6 @@ To stop the app,
``` ```
docker-compose down docker-compose down
``` ```
\ No newline at end of file
or ctrl+c once to gracefully exit, twice to ungracefully exit.
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import streamlit as st import streamlit as st
from langchain.vectorstores import FAISS from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings from langchain.embeddings import OpenAIEmbeddings
from langchain.chat_models import ChatOpenAI from langchain.chat_models import AzureChatOpenAI
from langchain.prompts import ( from langchain.prompts import (
ChatPromptTemplate, ChatPromptTemplate,
SystemMessagePromptTemplate, SystemMessagePromptTemplate,
...@@ -17,9 +17,13 @@ import os ...@@ -17,9 +17,13 @@ import os
# secrets # secrets
def manage_sensitive(name): def manage_sensitive(name):
v1 = os.getenv(name)
secret_fpath = f'/run/secrets/{name}' secret_fpath = f'/run/secrets/{name}'
existence = os.path.exists(secret_fpath) existence = os.path.exists(secret_fpath)
if v1 is not None:
return v1
if existence: if existence:
v2 = open(secret_fpath).read().rstrip('\n') v2 = open(secret_fpath).read().rstrip('\n')
return v2 return v2
...@@ -72,7 +76,7 @@ st.markdown(""" ...@@ -72,7 +76,7 @@ st.markdown("""
Brought to you by the Anesthesiology MPOG Steering Committee, Informatics, and Data Science teams Brought to you by the Anesthesiology MPOG Steering Committee, Informatics, and Data Science teams
_Not affiliated with MPOG. Uses external resources. Not approved for use with PHI or sensitive data._ _Not affiliated with MPOG. Not approved for use with PHI._
All submissions are recorded for potential review by the MPOG Steering Committee. All submissions are recorded for potential review by the MPOG Steering Committee.
...@@ -89,9 +93,24 @@ You can trick generative AIs into saying whatever you want. If you succeed in tr ...@@ -89,9 +93,24 @@ You can trick generative AIs into saying whatever you want. If you succeed in tr
As always, use your best judgment. An AI can do the wrong thing at the worst time. As always, use your best judgment. An AI can do the wrong thing at the worst time.
""") """)
chat = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo") chat = AzureChatOpenAI(
openai_api_base="https://nlp-openai-svc.openai.azure.com",
openai_api_version="2023-03-15-preview",
deployment_name="ChatGPT35Turbo",
openai_api_key=OPENAI_API_KEY,
openai_api_type = "azure",
temperature=0
)
# Load vectorstore # Load vectorstore
embedding = OpenAIEmbeddings() embedding = OpenAIEmbeddings(
deployment="AdaEmbedding2",
model="text-embedding-ada-002",
openai_api_base="https://nlp-openai-svc.openai.azure.com",
openai_api_type="azure",
openai_api_key=OPENAI_API_KEY,
openai_api_version="2023-03-15-preview",
)
vectordb = FAISS.load_local("faiss_index", embedding) vectordb = FAISS.load_local("faiss_index", embedding)
docsearch = vectordb.as_retriever() docsearch = vectordb.as_retriever()
......
...@@ -29,4 +29,4 @@ EXPOSE 8501 ...@@ -29,4 +29,4 @@ EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"] ENTRYPOINT ["./startup.sh"]
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.10 # This file is autogenerated by pip-compile with Python 3.10
# by the following command: # by the following command:
# #
# pip-compile requirements.in # pip-compile
# #
aiohttp==3.8.4 aiohttp==3.8.4
# via # via
...@@ -24,7 +24,7 @@ blinker==1.6.2 ...@@ -24,7 +24,7 @@ blinker==1.6.2
# via streamlit # via streamlit
cachetools==5.3.0 cachetools==5.3.0
# via streamlit # via streamlit
certifi==2022.12.7 certifi==2023.5.7
# via requests # via requests
charset-normalizer==3.1.0 charset-normalizer==3.1.0
# via # via
...@@ -62,7 +62,7 @@ jinja2==3.1.2 ...@@ -62,7 +62,7 @@ jinja2==3.1.2
# pydeck # pydeck
jsonschema==4.17.3 jsonschema==4.17.3
# via altair # via altair
langchain==0.0.155 langchain==0.0.179
# via -r requirements.in # via -r requirements.in
markdown-it-py==2.2.0 markdown-it-py==2.2.0
# via rich # via rich
...@@ -166,9 +166,7 @@ toolz==0.12.0 ...@@ -166,9 +166,7 @@ toolz==0.12.0
tornado==6.3.1 tornado==6.3.1
# via streamlit # via streamlit
tqdm==4.65.0 tqdm==4.65.0
# via # via openai
# langchain
# openai
typing-extensions==4.5.0 typing-extensions==4.5.0
# via # via
# pydantic # pydantic
......
nameserver 172.29.160.1
options ndots:0
\ No newline at end of file
#!/bin/bash
cp -f ./resolv.conf /etc/resolv.conf
streamlit run app.py --server.port=8501 --server.address=0.0.0.0
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment