Skip to content

Added test-on-pr.yml to run tests when a PR targets main branch #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/test-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 .
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 }}
run: |

## Run only two test files
# pytest tests/test_detect.py tests/test_evaluate.py

## 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
27 changes: 16 additions & 11 deletions examples/streamlit_apps/chatbot/aimon_chatbot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
)
Expand Down
4 changes: 2 additions & 2 deletions examples/streamlit_apps/chatbot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
llama-index
llama-index-readers-web
streamlit
aimon>=0.5.0

aimon>=0.10.0
httpx<0.28.1