Skip to content

Commit

Permalink
Merge branch 'main' into mistral-ops
Browse files Browse the repository at this point in the history
  • Loading branch information
the-praxs authored Sep 19, 2024
2 parents c42c803 + 3e7f00c commit 2b5bd7a
Show file tree
Hide file tree
Showing 30 changed files with 890 additions and 5,163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ on:
paths:
- 'examples/**'
- 'docs/v1/examples/**'

- '.github/workflows/add-notebook-examples-to-docs.yml'

workflow_dispatch:

permissions:
contents: write
pull-requests: write
Expand Down Expand Up @@ -35,43 +38,32 @@ jobs:
echo "Processing file: $file"
source_file=$(grep -oP '(?<=\{/\* SOURCE_FILE: ).*(?= \*/\})' "$file" || true)
if [[ -z "$source_file" ]]; then
echo "Error: No source file found in $file, skipping..." >&2
continue
fi
echo "Source file: $source_file"
if [[ -f "$source_file" ]]; then
echo "Converting notebook to markdown"
jupyter nbconvert --to markdown "$source_file" || { echo "Error: Failed to convert $source_file" >&2; continue; }
markdown_file="${source_file%.ipynb}.md"
echo "Removing existing content after {/* SOURCE_FILE: ... */}"
sed -i '\#{/\* SOURCE_FILE:#,$d' "$file"
echo "Appending markdown to $file"
echo -e "\n\n" >> "$file"
echo -e "{/* SOURCE_FILE: $source_file */}\n" >> "$file"
cat "$markdown_file" >> "$file" || { echo "Error: Failed to append markdown to $file" >&2; continue; }
rm "$markdown_file" || { echo "Error: Failed to remove $markdown_file" >&2; continue; }
else
echo "Error: Source file not found: $source_file" >&2
fi
done
- name: Commit changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add docs/v1/examples/*.mdx
git diff --quiet && git diff --staged --quiet || git commit -m "GitHub Action: Update examples in docs from notebooks"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update examples in docs from notebooks
title: 'Update examples in docs from notebooks'
body: |
This PR updates the examples in the docs from the corresponding notebooks.
Please review the changes before merging.
branch: update-docs-examples
base: main
# - name: Push changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: main
committer: Howard Gil <howardbgil@gmail.com>
commit-message: GitHub Action - Update examples in docs from notebooks
title: GitHub Action - Update examples in docs from notebooks
body: Changes detected in examples/** or docs/v1/examples/** triggered an update of the docs/v1/examples/**.mdx files to incorporate markdown from the corresponding notebook in examples/**.
branch: update-examples-in-docs-from-notebooks
delete-branch: true
assignees: HowieG,siyangqiu,bboynton97,areibman
reviewers: HowieG,siyangqiu,bboynton97,areibman
7 changes: 5 additions & 2 deletions .github/workflows/black-formatter.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

name: Black Code Formatter Check

on: [pull_request]
on:
pull_request:
paths:
- '**/*.py'
- '**/*.ipynb'

jobs:
black-check:
Expand All @@ -19,7 +23,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
pip install "black[jupyter]"
- name: Run Black
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
branches:
- main
paths:
- 'agentops/**'
- 'agentops/**/*.py'
pull_request:
branches:
- main
paths:
- 'agentops/**'
- 'agentops/**/*.py'

jobs:
test:
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/notebook-gen.yml

This file was deleted.

12 changes: 8 additions & 4 deletions .github/workflows/python-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ on:
branches:
- main
paths:
- 'agentops/**'
- 'tests/**'
- 'agentops/**/*.py'
- 'agentops/**/*.ipynb'
- 'tests/**/*.py'
- 'tests/**/*.ipynb'
pull_request:
branches:
- main
paths:
- 'agentops/**'
- 'tests/**'
- 'agentops/**/*.py'
- 'agentops/**/*.ipynb'
- 'tests/**/*.py'
- 'tests/**/*.ipynb'

jobs:
build:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tach-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Tach Check
on:
pull_request:
paths:
- 'agentops/**'
- 'tests/**'
- 'examples/**'
- '**/*.py'
- '**/*.ipynb'

jobs:
tach-check:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
exit_code=0
exclude_notebooks=(
"./examples/crewai_examples/job_posting.ipynb",
"./examples/crewai_examples/job_posting.ipynb"
"./examples/demos/agentchat_agentops.ipynb"
)
Expand Down
7 changes: 5 additions & 2 deletions agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from termcolor import colored
from typing import Optional, List, Union
from uuid import UUID, uuid4
from dateutil import parser
from datetime import datetime

from .exceptions import ApiServerException
from .enums import EndState
Expand Down Expand Up @@ -106,7 +106,10 @@ def end_session(
self._flush_queue()

def format_duration(start_time, end_time):
duration = parser.parse(end_time) - parser.parse(start_time)
start = datetime.fromisoformat(start_time.replace("Z", "+00:00"))
end = datetime.fromisoformat(end_time.replace("Z", "+00:00"))
duration = end - start

hours, remainder = divmod(duration.total_seconds(), 3600)
minutes, seconds = divmod(remainder, 60)

Expand Down
2 changes: 1 addition & 1 deletion docs/v0/recording-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def sample_function(...):
...
```

The decorator will record the function's parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several openai calls, then each openai call will show in the replay graph as a child of the decorated function.
The decorator will record the function's parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several OpenAI calls, then each openai call will show in the replay graph as a child of the decorated function.


record_action:
Expand Down
Loading

0 comments on commit 2b5bd7a

Please sign in to comment.