Skip to content

Commit

Permalink
Merge branch 'main' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin authored Jan 16, 2024
2 parents b97e7ba + 81d7501 commit 1a688e6
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-cloudrun-revision-community.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Authenticate to google cloud
uses: google-github-actions/auth@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-cloudrun-revision-internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Authenticate to google cloud
uses: google-github-actions/auth@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image-build-and-push-community.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image-build-and-push-internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
publish-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: python3 -m pip install --upgrade build && python3 -m build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ jobs:
MARVIN_ANTHROPIC_API_KEY: ${{ secrets.MARVIN_ANTHROPIC_API_KEY }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Run pre-commit
Expand Down
9 changes: 1 addition & 8 deletions cookbook/slackbot/start.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import asyncio
import re
from datetime import timedelta
from typing import Callable

import uvicorn
from fastapi import FastAPI, HTTPException, Request
Expand All @@ -28,17 +26,12 @@
)
from prefect import flow, task
from prefect.states import Completed
from prefect.tasks import task_input_hash

BOT_MENTION = r"<@(\w+)>"
CACHE = JSONBlockState(block_name="marvin-thread-cache")
USER_MESSAGE_MAX_TOKENS = 300


def cached(func: Callable) -> Callable:
return task(cache_key_fn=task_input_hash, cache_expiration=timedelta(days=1))(func)


async def get_notes_for_user(
user_id: str, max_tokens: int = 100
) -> dict[str, str | None]:
Expand Down Expand Up @@ -145,7 +138,7 @@ async def handle_message(payload: SlackPayload) -> Completed:

with Assistant(
name="Marvin",
tools=[cached(multi_query_chroma), cached(search_github_issues)],
tools=[multi_query_chroma, search_github_issues],
instructions=(
"You are Marvin, the paranoid android from Hitchhiker's Guide to the"
" Galaxy. Act subtly in accordance with your character, but remember"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dev = [
tests = [
"pytest-asyncio>=0.18.2,!=0.22.0,<0.23.0",
"pytest-env>=0.8,<2.0",
"pytest-rerunfailures>=10,<13",
"pytest-rerunfailures>=10,<14",
"pytest-sugar~=0.9",
"pytest~=7.3.1",
"pytest-timeout",
Expand Down
22 changes: 11 additions & 11 deletions src/marvin/utilities/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class EventBlock(BaseModel):
class SlackEvent(BaseModel):
client_msg_id: Optional[str] = None
type: str
text: str
user: str
ts: str
team: str
channel: str
text: Optional[str] = None
user: Optional[str] = None
ts: Optional[str] = None
team: Optional[str] = None
channel: Optional[str] = None
event_ts: str
thread_ts: Optional[str] = None
parent_user_id: Optional[str] = None
Expand Down Expand Up @@ -75,18 +75,18 @@ async def get_token() -> str:
marvin.settings.slack_api_token
) # set `MARVIN_SLACK_API_TOKEN` in `~/.marvin/.env
except AttributeError:
if token := os.getenv("MARVIN_SLACK_API_TOKEN"):
return token
try: # TODO: clean this up
from prefect.blocks.system import Secret

return (await Secret.load("slack-api-token")).get()
except ImportError:
pass
token = os.getenv("MARVIN_SLACK_API_TOKEN")
if not token:
raise ValueError(
"`MARVIN_SLACK_API_TOKEN` not found in environment."
" Please set it in `~/.marvin/.env` or as an environment variable."
)
raise ValueError(
"`MARVIN_SLACK_API_TOKEN` not found in environment."
" Please set it in `~/.marvin/.env` or as an environment variable."
)
return token


Expand Down

0 comments on commit 1a688e6

Please sign in to comment.