Agents
This module contains LLMs and agents that let the bot work with natural language.
- async bobbot.agents.check_openai_safety(msg_history: str) bool | None [source]
Determine whether the message history would be handled well by OpenAI’s models.
Uses OpenAI’s moderation API and an LLM. Messages containing self-harm related content should be treated seriously. Serious threats toward a person or group of people should also be treated seriously. However, other NSFW messages should not be censored, and therefore should not be handled by OpenAI.
- Parameters:
msg_history – The message history to check.
- Returns:
Whether OpenAI’s models would handle these messages well.
- async bobbot.agents.decide_to_respond(msg_history: str, status: str | None = None) tuple[bool, str] [source]
Decide whether to send a response message, given the current message history.
- Parameters:
msg_history – The message history.
status – Bob’s current activity status.
- Returns:
A tuple containing a boolean indicating whether to respond and the decision agent’s thoughts.
- async bobbot.agents.decide_topics(theme: str, num_topics: int) list[str] [source]
Decide on a list of topics given a theme.
- Parameters:
theme – The theme to decide on.
- Returns:
Up to num_topics decided topics (pre-filtered). May return less.
- async bobbot.agents.extract_answers(msg_history: str, questions: list[str]) dict[int, tuple[bool, str]] [source]
Extract answers to a list of questions from a message history.
- Parameters:
msg_history – The message history.
questions – The list of questions.
- Returns:
A dictionary mapping question numbers to tuples. Each tuple contains a boolean indicating whether the question was answered (True) or needs clarification (False), and the answer or clarifying command.
- async bobbot.agents.get_hint_for_topic(theme: str, topic: str, helpfulness: float, hint_prompt: str | None = None) str [source]
Generate a hint for a given topic with adjustable helpfulness.
This function prompts the LLM to produce a hint that will help guess the topic from a given theme. The ‘helpfulness’ parameter controls how obvious the hint is. At helpfulness=0, the hint is cryptic but uniquely identifying; at helpfulness=1, the hint practically gives away the answer.
- Parameters:
theme – The theme that the topic falls under.
topic – The specific topic for which to generate a hint.
helpfulness – A float from 0 to 10 indicating how revealing the hint should be.
hint_prompt – Optional guidance on what the hint should be.
- Returns:
A single-line hint as a string.
- async bobbot.agents.get_response(msg_history: list[BaseMessage], context: str | None = None, obedient: bool = False, store_memories: bool = True, use_perplexity: bool = False, use_reasoning: bool = False) str [source]
Get a response from Bob given the server’s messages, with optional system context.
- Parameters:
msg_history – The message history.
context – The system context to provide right before the last message.
obedient – Whether to use obedient mode.
store_memories – Whether to store tool memories.
use_perplexity – Whether to use perplexity’s AI search.
use_reasoning – Whether to use a reasoning model.
- async bobbot.agents.get_response_with_tools(msg_history: list[BaseMessage], context: str | None = None, uncensored: bool = False, obedient: bool = False, store_memories: bool = True) str [source]
Get a response from Bob given the server’s messages, with optional system context. Can use tools as well.
- Parameters:
msg_history – The message history.
context – The system context to provide right before the last message.
uncensored – Whether to use Deepseek to provide uncensored responses.
obedient – Whether to use obedient mode.
store_memories – Whether to store tool memories.
- async bobbot.agents.get_vc_response(msg_history: list[BaseMessage], context: str | None = None) str [source]
Get a response from Bob given the VC’s messages, with optional system context right before the last message.
- Parameters:
msg_history – The message history.
context – The system context to provide right before the last message.