From 12dbbdbca1960750d4f72a698e0be47ca7b8d0ec Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Tue, 27 May 2025 14:05:02 -0400 Subject: [PATCH 1/9] Version bump to 10.5 --- aimon/_version.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aimon/_version.py b/aimon/_version.py index 23f5cd5..938f4f9 100644 --- a/aimon/_version.py +++ b/aimon/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "aimon" -__version__ = "0.10.4" +__version__ = "0.10.5" diff --git a/setup.py b/setup.py index c2ecb17..d1299cc 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ name='aimon', python_requires='>3.8.0', packages=find_packages(), - version="0.10.4", + version="0.10.5", install_requires=[ "annotated-types~=0.6.0", "anyio~=4.9.0", From c80d5ca027196138a7b4ce25dba8eb2fa500a4b9 Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 15:55:50 -0400 Subject: [PATCH 2/9] Added yml file to automatically run tests when a PR is opened, synchronized (updated), or reopened that targets the branch --- .github/workflows/test-on-pr.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/test-on-pr.yml diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml new file mode 100644 index 0000000..da032c3 --- /dev/null +++ b/.github/workflows/test-on-pr.yml @@ -0,0 +1,31 @@ +name: Test on Pull Request + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + + - name: Run tests + # env: + # AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} + run: | + pytest tests/ From 18f0c88246d76836bda8fa67365e9efae272c3ff Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 16:10:30 -0400 Subject: [PATCH 3/9] Updated pip install packages --- .github/workflows/test-on-pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index da032c3..e7a3102 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -21,8 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest + pip install pytest setuptools wheel twine - name: Run tests # env: From b993eb7016e550830ba05c4168ef02247dd8c29f Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 16:12:46 -0400 Subject: [PATCH 4/9] pip install . --- .github/workflows/test-on-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index e7a3102..ba03860 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -21,7 +21,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest setuptools wheel twine + pip install . + pip install pytest - name: Run tests # env: From 48dcefaa35de24f736f4a9af5a740edb8af151f4 Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 16:17:28 -0400 Subject: [PATCH 5/9] Uncommenting API Key env var --- .github/workflows/test-on-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index ba03860..cdc2361 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -25,7 +25,7 @@ jobs: pip install pytest - name: Run tests - # env: - # AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} + env: + AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} run: | pytest tests/ From 5841ebe45c21102b0cc7837e89047612ea8c2503 Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 17:18:50 -0400 Subject: [PATCH 6/9] Ignoring obsolete and low level tests --- .github/workflows/test-on-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index cdc2361..4f98639 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -28,4 +28,5 @@ jobs: env: AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} run: | - pytest tests/ + # pytest tests/test_detect.py tests/test_evaluate.py + pytest tests/ --ignore=tests/obsolete/ --ignore=tests/test_low_level_api.py -v From e34cebc77730910ba40c72c0fbdc0f06683b4235 Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 17:46:13 -0400 Subject: [PATCH 7/9] Added descriptive logging to tests --- .github/workflows/test-on-pr.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index 4f98639..9c3eddc 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -28,5 +28,12 @@ jobs: env: AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} run: | + + ## Run only two test files # pytest tests/test_detect.py tests/test_evaluate.py - pytest tests/ --ignore=tests/obsolete/ --ignore=tests/test_low_level_api.py -v + + ## Ignore some files and run without descriptive logging + # pytest tests/ --ignore=tests/obsolete/ --ignore=tests/test_low_level_api.py -v + + ## Ignore some files and run with descriptive logging + pytest tests/ --ignore=tests/obsolete/ --ignore=tests/test_low_level_api.py -v --log-cli-level=INFO From 21b8631e406a218d7a3aecaa6059b7dc4ec3e038 Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 17:53:22 -0400 Subject: [PATCH 8/9] Debugging yml file and requirements modified for streamlit chatbot example --- .github/workflows/test-on-pr.yml | 6 ++++++ examples/streamlit_apps/chatbot/requirements.txt | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index 9c3eddc..9a72962 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -24,6 +24,12 @@ jobs: pip install . pip install pytest + - name: Debug env var + env: + AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} + run: | + echo "API KEY LENGTH: ${#AIMON_API_KEY}" + - name: Run tests env: AIMON_API_KEY: ${{ secrets.AIMON_API_KEY }} diff --git a/examples/streamlit_apps/chatbot/requirements.txt b/examples/streamlit_apps/chatbot/requirements.txt index 5665f53..46d3b2c 100644 --- a/examples/streamlit_apps/chatbot/requirements.txt +++ b/examples/streamlit_apps/chatbot/requirements.txt @@ -1,5 +1,5 @@ llama-index llama-index-readers-web streamlit -aimon>=0.5.0 - +aimon>=0.10.0 +httpx<0.28.1 \ No newline at end of file From fc77b91c9d2123466fe733c4bb4c910d836faf78 Mon Sep 17 00:00:00 2001 From: Devvrat Bhardwaj Date: Thu, 29 May 2025 18:11:56 -0400 Subject: [PATCH 9/9] Adjusted streamlit chatbot to be compatible with IA2 --- .../chatbot/aimon_chatbot_demo.py | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/examples/streamlit_apps/chatbot/aimon_chatbot_demo.py b/examples/streamlit_apps/chatbot/aimon_chatbot_demo.py index 8b1a6dc..e8c49a1 100644 --- a/examples/streamlit_apps/chatbot/aimon_chatbot_demo.py +++ b/examples/streamlit_apps/chatbot/aimon_chatbot_demo.py @@ -43,7 +43,7 @@ def load_data(): system_prompt="""You are an expert on answering questions on Essays and your job is to answer questions related to this domain. Your answers should be based on - facts – do not hallucinate features.""", + facts - do not hallucinate features.""", ) logging.info("Finished creating OpenAI LLM...") Settings.chunk_size = 256 @@ -107,10 +107,12 @@ def execute(): openai_api_key = os.getenv("OPENAI_API_KEY") openai.api_key = openai_api_key - instructions = st.text_input( - "Instructions for the chatbot. Ex: Answer the user's question in a professional tone.", - value="Answer the user's question in a professional tone." + raw_instructions = st.text_input( + "Instructions for the chatbot (comma-separated). Ex: Answer professionally, Be concise", + value="Answer professionally, Be concise" ) + instructions = [instr.strip() for instr in raw_instructions.split(',') if instr.strip()] + st.title("Ask questions on Paul Graham's Work Experience") if "messages" not in st.session_state.keys(): # Initialize the chat messages history @@ -125,16 +127,19 @@ def execute(): memory = ChatMemoryBuffer.from_defaults(token_limit=1200) if "chat_engine" not in st.session_state.keys(): # Initialize the chat engine + formatted_instructions = "; ".join(instructions) if instructions else "Respond helpfully." + + context_prompt = ( + "You are a chatbot, able to answer questions on an essay about Paul Graham's Work experience. " + "Here are the relevant documents for the context:\n" + "{context_str}\n\n" + f"Instruction: Use the previous chat history, or the context above, to interact and help the user. {formatted_instructions}" + ) + st.session_state.chat_engine = index.as_chat_engine( chat_mode="condense_plus_context", memory=memory, - context_prompt=( - "You are a chatbot, able to answer questions on an essay about Paul Graham's Work experience." - "Here are the relevant documents for the context:\n" - "{context_str}" - "\nInstruction: Use the previous chat history, or the context above, to interact and help the user. " + - "{}".format(instructions if instructions else "") - ), + context_prompt=context_prompt, verbose=False, similarity_top_k=4, )