Spaces:
Sleeping
Sleeping
File size: 2,670 Bytes
5884015 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | import os
import requests
from dotenv import load_dotenv
load_dotenv(override=True)
def push(text: str):
"""Send a notification via Pushover when credentials are configured."""
if not os.getenv("PUSHOVER_TOKEN") or not os.getenv("PUSHOVER_USER"):
# Fail silently if pushover is not configured – avoids runtime errors
print("[PUSHOVER] Not configured, message was:", text, flush=True)
return
requests.post(
"https://api.pushover.net/1/messages.json",
data={
"token": os.getenv("PUSHOVER_TOKEN"),
"user": os.getenv("PUSHOVER_USER"),
"message": text,
},
)
def record_user_details(email, name="Name not provided", notes="not provided"):
push(f"Recording {name} with email {email} and notes {notes}")
return {"recorded": "ok"}
def record_unknown_question(question):
push(f"User made an interesting question that I could not answer: {question}")
return {"recorded": "ok"}
record_user_details_json = {
"name": "record_user_details",
"description": "Use this tool to record that a user is interested in being in touch and provided an email address",
"parameters": {
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "The email address of this user",
},
"name": {
"type": "string",
"description": "The user's name, if they provided it",
},
"notes": {
"type": "string",
"description": "Any additional information about the conversation that's worth recording to give context",
},
},
"required": ["email"],
"additionalProperties": False,
},
}
record_unknown_question_json = {
"name": "record_unknown_question",
"description": "Always use this tool to record any question that couldn't be answered as you didn't know the answer",
"parameters": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "The question that couldn't be answered",
},
},
"required": ["question"],
"additionalProperties": False,
},
}
TOOLS = [
{"type": "function", "function": record_user_details_json},
{"type": "function", "function": record_unknown_question_json},
]
FUNCTION_MAP = {
"record_user_details": record_user_details,
"record_unknown_question": record_unknown_question,
}
|