Skip to content
Merged

woops #1163

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
19 changes: 9 additions & 10 deletions examples/slackbot/src/slackbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
logger = get_logger(__name__)
logger.debug(f"Starting Slackbot with model: {settings.model_name}")

if "gpt" in settings.model_name:
if not (openai_api_key := os.getenv("OPENAI_API_KEY")):
os.environ["OPENAI_API_KEY"] = Secret.load(
settings.openai_api_key_secret_name, _sync=True
).get()
if "claude" in settings.model_name:
if not (anthropic_api_key := os.getenv("ANTHROPIC_API_KEY")):
os.environ["ANTHROPIC_API_KEY"] = Secret.load(
settings.anthropic_key_secret_name, _sync=True
).get()
if not (openai_api_key := os.getenv("OPENAI_API_KEY")): # Needed for embeddings
os.environ["OPENAI_API_KEY"] = Secret.load(
settings.openai_api_key_secret_name, _sync=True
).get()

if not (anthropic_api_key := os.getenv("ANTHROPIC_API_KEY")): # Needed for LLM
os.environ["ANTHROPIC_API_KEY"] = Secret.load(
settings.anthropic_key_secret_name, _sync=True
).get()

uvicorn.run(
"slackbot.api:app",
Expand Down
3 changes: 2 additions & 1 deletion examples/slackbot/src/slackbot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def personality_and_maybe_notes(ctx: RunContext[UserContext]) -> str:
async def store_facts_about_user(
ctx: RunContext[UserContext], facts: list[str]
) -> str:
"""Store facts about the user, tracking data lineage from Slack messages."""
"""Store facts about the user that are useful for answering their questions."""
print(f"Storing {len(facts)} facts about user {ctx.deps['user_id']}")
# This creates an asset dependency: USER_FACTS depends on SLACK_MESSAGES
message = await store_user_facts(ctx, facts)
Expand All @@ -208,6 +208,7 @@ async def store_facts_about_user(

@agent.tool
def delete_facts_about_user(ctx: RunContext[UserContext], related_to: str) -> str:
"""Delete facts about the user related to a specific topic."""
print(f"forgetting stuff about {ctx.deps['user_id']} related to {related_to}")
user_id = ctx.deps["user_id"]
with TurboPuffer(
Expand Down