From 68e4d5797d0e8dcaaab05b7784a82e9903ce3b2f Mon Sep 17 00:00:00 2001 From: Sudhendra Date: Wed, 16 Oct 2024 05:25:45 -0400 Subject: [PATCH] workflows --- .github/workflows/step1workflow.yml | 17 +++++++++++++++-- medapp.py | 6 +++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/step1workflow.yml b/.github/workflows/step1workflow.yml index 43a9a0c..38110ac 100644 --- a/.github/workflows/step1workflow.yml +++ b/.github/workflows/step1workflow.yml @@ -1,8 +1,21 @@ jobs: example-job: steps: - - name: Use API Key + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run application env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - # Your script that uses the API key \ No newline at end of file + python medapp.py diff --git a/medapp.py b/medapp.py index fefdcc9..e9e2cbd 100644 --- a/medapp.py +++ b/medapp.py @@ -20,10 +20,10 @@ # Wrap the entire app in streamlit_analytics.track() with streamlit_analytics.track(): # Set up OpenAI client - st.sidebar.title("OpenAI API Key") key = os.getenv("OPENAI_API_KEY") if not key: - key = st.sidebar.text_input("Enter your OpenAI API key:", type="password") + st.error("OpenAI API key not found. Please set the OPENAI_API_KEY environment variable.") + st.stop() client = OpenAI(api_key=key) # Check for GPU availability @@ -85,7 +85,7 @@ def retrieve_passages(query: str, index, embeddings: np.ndarray, video_data: Lis def generate_answer(query: str, context: str) -> str: try: response = client.chat.completions.create( - model="gpt-4o-mini", + model="gpt-4-0125-preview", messages=[ {"role": "system", "content": "You are a helpful assistant that answers medical questions based on the provided context. Always ground your answers in the given context and be concise."}, {"role": "user", "content": f"Context: {context}\n\nQuestion: {query}\n\nAnswer:"}