diff --git a/.gitignore b/.gitignore index bac0baa..3d4a1af 100644 --- a/.gitignore +++ b/.gitignore @@ -166,4 +166,6 @@ cython_debug/ .micromamba/ -*.egg-info \ No newline at end of file +*.egg-info + +config/agent_profiles.yaml #to deal with testing bug \ No newline at end of file diff --git a/config/agent_profiles.yaml b/config/agent_profiles.yaml deleted file mode 100644 index 94b2e23..0000000 --- a/config/agent_profiles.yaml +++ /dev/null @@ -1,59 +0,0 @@ -SecretaryAgent: - autoload_from_yaml: false - backstory: The SecretaryAgent is designed to assist in the analysis and description - of AI agents, leveraging its specialized training. - class_qualname: just_agents.router.secretary_agent.SecretaryAgent - description: A skilled AI assistant focused on creating detailed profiles for AI - agents. - expertise_domain: AI agent analysis and description - extra_dict: - personality_traits: Agent's personality traits go here - goal: To generate concise and detail-rich profiles for AI agents. - knowledge_sources: [] - limitations: Limited to the information available up to October 2023. - llm_options: - model: gpt-4o-mini - temperature: 0.0 - model_name: gpt-4o-mini - personality_traits: A detail-oriented and analytical AI assistant with a focus on - clarity and conciseness. - role: AI assistant specializing in agent analysis. - system_prompt: |2- - - You are a skilled AI assistant specializing in analysis and description of AI agents. - You are tasked with generation of a minimalistic and concise yet detail-rich profile for an AI agent, based on the AVAILABLE_ATTRIBUTES, - including 'system_prompt', 'llm_options' and any other. Your task is to fill in values of a JSON-formatted profile - that matches the PROFILE_UPDATE_TEMPLATE provided below. Values of the template describe what output is expected for each field. - Only populate fields based on the well-established information, don't make up anything. - Double-check that the output contains only a valid JSON with all the fields specified in PROFILE_UPDATE_TEMPLATE. - Never include any additional text or explanations in your reply. - task: Profile generation based on available attributes. -agent_profiles: - SecretaryAgent: - autoload_from_yaml: false - backstory: Developed to assist in the understanding and documentation of AI agents. - class_qualname: just_agents.router.secretary_agent.SecretaryAgent - description: A skilled AI assistant specializing in the generation of concise - and detail-rich profiles for AI agents. - expertise_domain: AI agent profiling and analysis. - extra_dict: - personality_traits: Agent's personality traits go here - goal: To generate detailed profiles for AI agents. - knowledge_sources: [] - limitations: Limited to the information available up to October 2023. - llm_options: - model: gpt-4o-mini - temperature: 0.0 - model_name: gpt-4o-mini - personality_traits: Skilled, detail-oriented, concise, analytical - role: AI assistant. - system_prompt: |2- - - You are a skilled AI assistant specializing in analysis and description of AI agents. - You are tasked with generation of a minimalistic and concise yet detail-rich profile for an AI agent, based on the AVAILABLE_ATTRIBUTES, - including 'system_prompt', 'llm_options' and any other. Your task is to fill in values of a JSON-formatted profile - that matches the PROFILE_UPDATE_TEMPLATE provided below. Values of the template describe what output is expected for each field. - Only populate fields based on the well-established information, don't make up anything. - Double-check that the output contains only a valid JSON with all the fields specified in PROFILE_UPDATE_TEMPLATE. - Never include any additional text or explanations in your reply. - task: Analysis and description of AI agents. diff --git a/core/just_agents/base_agent.py b/core/just_agents/base_agent.py index a5ef619..fe5a5a5 100644 --- a/core/just_agents/base_agent.py +++ b/core/just_agents/base_agent.py @@ -28,6 +28,7 @@ class BaseAgent( Note: it is based on pydantic and the only required field is llm_options. However, it is also recommended to set system_prompt. """ + # Core configuration for the LLM llm_options: LLMOptions = Field( @@ -137,7 +138,7 @@ def model_post_init(self, __context: Any) -> None: print("Warning api_key will be rewritten by key_getter. Both are present in llm_options.") # Initialize the agent with its system prompt - self.instruct(self.system_prompt) + self.instruct(self.system_prompt) # TODO: THIS CAUSES HUGE ISSUES WHEN YOU INHERIT FROM THIS CLASS FIX!!!!!!!!!!!!!!!!!!!!!!!!!!!1 def _prepare_options(self, options: LLMOptions): opt = options.copy() @@ -290,4 +291,53 @@ def model_supported_parameters(self) -> list[str]: def supports_response_format(self) -> bool: """Checks if the current model supports the response_format parameter""" #TODO: implement provider specific check - return "response_format" in self.model_supported_parameters \ No newline at end of file + return "response_format" in self.model_supported_parameters + + + +class ChatAgent(BaseAgent): + """ + An agent that has role/goal/task attributes and can call other agents + """ + + role: Optional[str] = Field(default=None, description="Defines the agent's persona or identity") + goal: Optional[str] = Field (default=None, description="Specifies the agent's broader objective.") + task: Optional[str] = Field (default=None, description="Describes the specific task the agent is responsible for.") + + delegation_prompt: Optional[str] = Field(default="You can delegate your task by calling the delegate function to the following agents:", description="Defines the prompt for the delegation") + delegates: Optional[list[str, BaseAgent]] = Field(default_factory=dict, description="Defines the list of agents that this agent can delegate to with descriptions") + + + def _update_system_promptform_prompt(self): + # Create a prompt incorporating role, goal, task + prompt = ( + f"You are a {self.role}.\n" + f"Your goal is to {self.goal}.\n" + f"Your task is to {self.task}.\n" + "Respond appropriately." + ) + return prompt + + def model_post_init(self, __context: Any) -> None: + # Call parent's post_init to maintain core functionality + super().model_post_init(__context) + if self.system_prompt == self.DEFAULT_GENERIC_PROMPT: + self.system_prompt = "" + + if self.role is not None: + self.system_prompt = self.system_prompt + "\n" + self.role + if self.goal is not None: + self.system_prompt = self.system_prompt + "\n" + self.goal + if self.task is not None: + self.system_prompt = self.system_prompt + "\n" + self.task + if len(self.delegates) > 0: + self.system_prompt = self.system_prompt + "\n" + self.delegation_prompt + self.system_prompt = self.system_prompt + "\n" + "\n".join([f"{agent.shortname}: {agent.description}" for agent in self.delegates.values()]) + self.clear_memory() + + @property + def delegates_dict(self) -> dict[str, BaseAgent]: + """Returns a dictionary mapping agent shortnames to their corresponding BaseAgent instances""" + return {agent.shortname: agent for agent in self.delegates.values()} + + diff --git a/core/just_agents/base_memory.py b/core/just_agents/base_memory.py index 84e0fe2..d10dd3c 100644 --- a/core/just_agents/base_memory.py +++ b/core/just_agents/base_memory.py @@ -4,12 +4,96 @@ from just_agents.interfaces.memory import IMemory from just_agents.types import Role, MessageDict, SupportedMessages from litellm.types.utils import Function -from abc import ABC +from abc import ABC, abstractmethod + +from typing import Optional +from rich.console import Console +from rich.text import Text +from rich.panel import Panel + +class IMessageFormatter(ABC): + @abstractmethod + def pretty_print_message(self, msg: MessageDict) -> Panel: + pass + + @abstractmethod + def pretty_print_all_messages(self): + pass + +class MessageFormatter(IMessageFormatter): + + messages: List[MessageDict] = Field(default_factory=list, validation_alias='conversation') + + + def pretty_print_message(self, msg: MessageDict) -> Panel: + role = msg.get('role', 'unknown').capitalize() + + # If the role is an enum, extract its value + if isinstance(role, str) and '', '').capitalize() + + # Define role-specific colors + role_colors = { + 'User': 'green', + 'Assistant': 'blue', + 'System': 'yellow', + 'Function': 'magenta', + 'Tool': 'magenta', + } + border_colors = { + 'User': 'bright_green', + 'Assistant': 'bright_blue', + 'System': 'bright_yellow', + 'Function': 'bright_magenta', + 'Tool': 'bright_magenta', + } + + # Get colors for the role (default to cyan/bright_yellow if role not found) + role_color = role_colors.get(role, 'cyan') + border_color = border_colors.get(role, 'bright_yellow') + + # Create a title with bold text for the role + role_title = Text(f"[{role}]", style=f"bold {role_color}") + + # Process tool call details if present + if 'tool_calls' in msg: + for tool_call in msg['tool_calls']: + tool_name = tool_call.get('function', {}).get('name', 'unknown tool') + arguments = tool_call.get('function', {}).get('arguments', '{}') + return Panel( + f"Tool Call to [bold magenta]{tool_name}[/bold magenta]:\n{arguments}", + title=role_title, + border_style=role_color, + ) + elif 'tool_call_id' in msg: + tool_name = msg.get('name', 'unknown tool') + tool_result = msg.get('content', 'no content') + return Panel( + f"Response from [bold magenta]{tool_name}[/bold magenta]:\n{tool_result}", + title=role_title, + border_style=border_color, + ) + else: + # Standard message + return Panel( + f"{msg.get('content', '')}", + title=role_title, + border_style=border_color, + ) + + def pretty_print_all_messages(self): + if not self.messages: + return + + console = Console() + for msg in self.messages: + panel = self.pretty_print_message(msg) + console.print(panel) OnMessageCallable = Callable[[MessageDict], None] OnFunctionCallable = Callable[[Function], None] -class IBaseMemory(BaseModel, IMemory[Role, MessageDict], ABC): +class IBaseMemory(BaseModel, IMemory[Role, MessageDict], IMessageFormatter, ABC): """ Abstract Base Class to fulfill Pydantic schema requirements for concrete-attributes. """ @@ -27,7 +111,7 @@ class IBaseMemory(BaseModel, IMemory[Role, MessageDict], ABC): def deepcopy(self) -> 'IBaseMemory': return self.model_copy(deep=True) -class BaseMemory(IBaseMemory): +class BaseMemory(IBaseMemory, MessageFormatter): """ The Memory class provides storage and handling of messages for a language model session. It supports adding, removing, and handling different types of messages and diff --git a/core/just_agents/just_profile.py b/core/just_agents/just_profile.py index 58e5184..a78a165 100644 --- a/core/just_agents/just_profile.py +++ b/core/just_agents/just_profile.py @@ -26,6 +26,18 @@ class JustAgentProfile(JustSerializable): description="A List[Callable] of tools s available to the agent and their descriptions") """A List[Callable] of tools s available to the agent and their descriptions""" + def _add_tool(self, fun: callable): + """ + Adds a tool to the agent's tools dictionary. + """ + tool = JustTool.from_callable(fun) + if self.tools is None: + self.tools = { + tool.name: tool + } + else: + self.tools[tool.name] = tool + @model_validator(mode='after') def validate_model(self) -> 'JustAgentProfile': diff --git a/core/just_agents/just_serialization.py b/core/just_agents/just_serialization.py index dc719f0..56d386c 100644 --- a/core/just_agents/just_serialization.py +++ b/core/just_agents/just_serialization.py @@ -4,6 +4,7 @@ from pathlib import Path from pydantic import BaseModel, Field, field_validator, ValidationError from collections.abc import MutableMapping, MutableSequence +from pydantic import ConfigDict class JustYaml: @@ -157,7 +158,7 @@ def save_to_yaml( # to use with safe_dump: yaml.representer.SafeRepresenter.add_representer(str, JustYaml.str_presenter) -class JustSerializable(BaseModel, extra="allow", use_enum_values=True, validate_assignment=True, populate_by_name=True): +class JustSerializable(BaseModel): """ Pydantic2 wrapper class that implements semi-automated YAML and JSON serialization and deserialization @@ -167,6 +168,12 @@ class JustSerializable(BaseModel, extra="allow", use_enum_values=True, validate_ DEFAULT_SECTION_NAME (str): Default section name to use when none is provided. """ + model_config = ConfigDict( + extra="allow", + use_enum_values=True, + validate_assignment=True, + populate_by_name=True + ) DEFAULT_CONFIG_PATH : ClassVar[Path] = Path('./config/default_config.yaml') DEFAULT_PARENT_SECTION : ClassVar[Optional[str]] = None DEFAULT_SECTION_NAME : ClassVar[Optional[str]] = "Agent" #'RenameMe' diff --git a/core/just_agents/just_tool.py b/core/just_agents/just_tool.py index 9d5386c..496927b 100644 --- a/core/just_agents/just_tool.py +++ b/core/just_agents/just_tool.py @@ -5,6 +5,7 @@ from just_agents.just_bus import JustEventBus from importlib import import_module import inspect +from pydantic import ConfigDict FunctionParamFields=Literal["kind","default","type_annotation"] FunctionParams = List[Dict[str, Dict[FunctionParamFields,Optional[str]]]] @@ -17,7 +18,10 @@ class JustToolsBus(JustEventBus): """ pass -class LiteLLMDescription(BaseModel, populate_by_name=True): +class LiteLLMDescription(BaseModel): + + model_config = ConfigDict(populate_by_name=True) + name: Optional[str] = Field(..., alias='function', description="The name of the function") description: Optional[str] = Field(None, description="The docstring of the function.") parameters: Optional[Dict[str,Any]]= Field(None, description="Parameters of the function.") diff --git a/core/just_agents/llm_options.py b/core/just_agents/llm_options.py index 91c22a9..99ea9ba 100644 --- a/core/just_agents/llm_options.py +++ b/core/just_agents/llm_options.py @@ -1,6 +1,6 @@ from typing import Any, Dict, List, Optional from pydantic import Field, HttpUrl, BaseModel - +from pydantic import ConfigDict LLMOptions = Dict[str, Any] class ModelOptions(BaseModel): @@ -38,7 +38,9 @@ class ModelOptions(BaseModel): description="Frequency penalty, values from -2.0 to 2.0" ) -class LLMOptionsBase(ModelOptions, extra="allow"): +class LLMOptionsBase(ModelOptions): + + model_config = ConfigDict(extra="allow") api_key: Optional[str] = Field(None, examples=["sk-proj-...."]) api_base : Optional[HttpUrl] = Field(default=None, examples=[ diff --git a/core/pyproject.toml b/core/pyproject.toml index e68ef9e..fd94cc3 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -36,6 +36,7 @@ Deprecated = ">=1.2.15" requests = "*" numpydoc = "*" python-dotenv = ">=1.0.1" +rich = ">=13.9.4" [tool.poetry.group.dev.dependencies] pytest = ">=8.3.4" diff --git a/examples/just_agents/examples/web/agent.yaml b/examples/just_agents/examples/web/agent.yaml index 1b92863..69791d0 100644 --- a/examples/just_agents/examples/web/agent.yaml +++ b/examples/just_agents/examples/web/agent.yaml @@ -1,10 +1,26 @@ Agent: class_qualname: just_agents.base_agent.BaseAgent llm_options: - api_base: https://api.groq.com/openai/v1 - model: groq/llama-3.3-70b-versatile + model: "gpt-4o-mini" temperature: 0.0 - tool_choice: auto - tools: [] system_prompt: | - You are a super-nice agent. You are always helpful, friendly and very polite. You start the conversation with "It is an honor to serve you" \ No newline at end of file + You are a productivity and health adviser. You have a database of advice and recommendations given as JSON below you have to give advice solely on the database mentioning all the relevant fields. + Here is the JSON: + { + [{"Tip":"Incorporate new technologies into your work for at least one hour a day to streamline tasks and increase efficiency. This could enhance your work engagement without overwhelming you.","Information":"A study from the University of Occupational and Environmental Health, Japan, observed a connection between exposure to technological advances and work engagement, suggesting that proper utilization can boost productivity. The findings noted the importance of adapting to technology for sustained engagement, especially among younger workers.","Category":"Work","Goal":"Augment","Focus":"Work","Activity_type":"Cognitive","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Work-Life Balance","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Engage in 30 minutes of physical activity daily to combat job-related stress and improve overall mental health, enhancing work engagement.","Information":"The longitudinal study found that maintaining good mental health, especially alongside exposure to technology, is crucial for work engagement. Regular exercise is recommended for stress management and improving focus and well-being.","Category":"Health","Goal":"Prevent","Focus":"Physical","Activity_type":"Exercise","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Sunny","Concerns":"Stress Management","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Schedule weekly check-ins with colleagues to discuss how technology is affecting their work and engagement levels, fostering a supportive work environment.","Information":"The study emphasized the importance of social engagement and communication in adapting to technological changes, suggesting regular discussions can mitigate feelings of job insecurity.","Category":"Social","Goal":"Augment","Focus":"Social","Activity_type":"Social","Daytime":"Not relevant","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Take short breaks every hour for at least 5 minutes to reset your mind and remain engaged, improving productivity during technology use.","Information":"Frequent breaks have been shown to maintain high work engagement levels, especially when working with advanced technologies, as mentioned in the study linked to work performance enhancement.","Category":"Well-being","Goal":"Recover","Focus":"Mental","Activity_type":"Relax","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Focus","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Practice mindfulness or meditation for at least 10 minutes a day to reduce anxiety and improve adaptability to technological changes.","Information":"Mindfulness practices can enhance mental health and were suggested as beneficial for those exposed to new technologies, potentially improving work engagement and reducing stress, as indicated by the research findings.","Category":"Health","Goal":"Prevent","Focus":"Mental","Activity_type":"Relax","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Mental Health","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"If applicable in your job, dedicate at least one hour weekly to learning about new technology relevant to your field to stay engaged and informed.","Information":"The study discusses the association between work engagement and adaptation to technological advances, indicating that proactive learning can enhance job satisfaction and efficiency, particularly amongst younger employees.","Category":"Success","Goal":"Augment","Focus":"Work","Activity_type":"Cognitive","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Motivation","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Incorporate new technologies into your work for at least one hour a day to streamline tasks and increase efficiency. This could enhance your work engagement without overwhelming you.","Information":"A study from the University of Occupational and Environmental Health, Japan, observed a connection between exposure to technological advances and work engagement, suggesting that proper utilization can boost productivity. The findings noted the importance of adapting to technology for sustained engagement, especially among younger workers.","Category":"Work","Goal":"Augment","Focus":"Work","Activity_type":"Cognitive","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Work-Life Balance","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Engage in 30 minutes of physical activity daily to combat job-related stress and improve overall mental health, enhancing work engagement.","Information":"The longitudinal study found that maintaining good mental health, especially alongside exposure to technology, is crucial for work engagement. Regular exercise is recommended for stress management and improving focus and well-being.","Category":"Health","Goal":"Prevent","Focus":"Physical","Activity_type":"Exercise","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Sunny","Concerns":"Stress Management","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Schedule weekly check-ins with colleagues to discuss how technology is affecting their work and engagement levels, fostering a supportive work environment.","Information":"The study emphasized the importance of social engagement and communication in adapting to technological changes, suggesting regular discussions can mitigate feelings of job insecurity.","Category":"Social","Goal":"Augment","Focus":"Social","Activity_type":"Social","Daytime":"Not relevant","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Take short breaks every hour for at least 5 minutes to reset your mind and remain engaged, improving productivity during technology use.","Information":"Frequent breaks have been shown to maintain high work engagement levels, especially when working with advanced technologies, as mentioned in the study linked to work performance enhancement.","Category":"Well-being","Goal":"Recover","Focus":"Mental","Activity_type":"Relax","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Focus","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Practice mindfulness or meditation for at least 10 minutes a day to reduce anxiety and improve adaptability to technological changes.","Information":"Mindfulness practices can enhance mental health and were suggested as beneficial for those exposed to new technologies, potentially improving work engagement and reducing stress, as indicated by the research findings.","Category":"Health","Goal":"Prevent","Focus":"Mental","Activity_type":"Relax","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Mental Health","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"If applicable in your job, dedicate at least one hour weekly to learning about new technology relevant to your field to stay engaged and informed.","Information":"The study discusses the association between work engagement and adaptation to technological advances, indicating that proactive learning can enhance job satisfaction and efficiency, particularly amongst younger employees.","Category":"Success","Goal":"Augment","Focus":"Work","Activity_type":"Cognitive","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Motivation","Authors(PaperCount, CitationCount)":"N. Adi(79, 123); T. Nagata(175, 987); K. Odagami(64, 117); M. Nagata(94, 545); K. Mori(162, 936)","citationCount":0,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-01-19 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"Journal of Occupational Health","referenceCount":0,"title":"Association between exposure to technological advances in the workplace and work engagement: a prospective cohort study","tldr":null,"url":"https://www.semanticscholar.org/paper/49fc514dae9bba83582f72f1506d524a132538ad"},{"Tip":"Practice gratitude by writing down three things you're grateful for each evening before bed for a week.","Information":"A study by Sheldon & Lyubomirsky (2006) demonstrated that regularly expressing gratitude can enhance positive mood and overall well-being over time.","Category":"Well-being","Goal":"Augment","Focus":"Mental","Activity_type":"Cognitive","Daytime":"Evening","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Mindset","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Visualize your best possible self by spending just 10 minutes each week imagining your ideal future in vivid detail.","Information":"According to Sheldon & Lyubomirsky (2006), visualizing your best possible future self can significantly boost positive emotions and sustain them over time.","Category":"Success","Goal":"Augment","Focus":"Mental","Activity_type":"Cognitive","Daytime":"Not relevant","Weekday":"Not relevant","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Goal-Setting","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Commit to socializing with friends or family for at least one hour each week to foster social bonds and enhance happiness.","Information":"Sheldon & Lyubomirsky (2006) found that maintaining social relationships is crucial for increasing positive emotions and overall well-being.","Category":"Happiness","Goal":"Augment","Focus":"Social","Activity_type":"Social","Daytime":"Not relevant","Weekday":"Weekend","Validity_Flag":true,"Weather":"Sunny","Concerns":"Work-Life Balance","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Set aside time each morning for self-reflection, writing about your thoughts or emotions for 10 minutes, to enhance mental clarity and reduce negative emotions.","Information":"Research by Sheldon & Lyubomirsky (2006) suggests that regular self-reflection can lead to improved emotional well-being and resilience.","Category":"Mental","Goal":"Recover","Focus":"Mental","Activity_type":"Relax","Daytime":"Morning","Weekday":"Not relevant","Validity_Flag":true,"Weather":"Overcast","Concerns":"Stress Management","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Engage in a short physical activity, such as a brisk 15-minute walk, at least three times a week to boost both physical and mental health.","Information":"The connection between physical health and productivity is well-documented, as regular exercise helps maintain mood and enhances cognitive function (Sheldon & Lyubomirsky, 2006).","Category":"Fitness","Goal":"Prevent","Focus":"Physical","Activity_type":"Exercise","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Sunny","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Limit your engagement in gratitude practices to once a week to avoid loss of effectiveness; reflect deeply on what you are thankful for during that session.","Information":"Sheldon & Lyubomirsky (2006) emphasized that the frequency of gratitude practice should align with personal motivation and context for greater benefits.","Category":"Awareness","Goal":"Prevent","Focus":"Mental","Activity_type":"Cognitive","Daytime":"Evening","Weekday":"Weekend","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Motivation","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Start each day with a 5-minute meditation or mindfulness exercise to enhance focus and productivity throughout the day.","Information":"Sheldon & Lyubomirsky (2006) highlighted the importance of mental practices in sustaining positive emotions and improving focus, leading to better productivity.","Category":"Focus","Goal":"Augment","Focus":"Mental","Activity_type":"Relax","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"Kennon M. Sheldon(279, 41912); S. Lyubomirsky(191, 40403)","citationCount":884,"fieldsOfStudy":"Psychology","influentialCitationCount":64,"publicationDate":"2006-04-01 00:00:00","publicationTypes":"Review","publicationVenue":null,"referenceCount":48,"title":"How to increase and sustain positive emotion: The effects of expressing gratitude and visualizing best possible selves","tldr":null,"url":"https://www.semanticscholar.org/paper/cafa01012974dc87e8f260e05c8e1201939d2859"},{"Tip":"Adopt a positive perspective on anxiety by viewing it as a source of energy that can enhance performance. Before an important task, remind yourself that feeling anxious can be beneficial.","Information":"Research by Shannon T. Brady and colleagues at Stanford University indicates that reshaping one’s interpretation of anxiety can significantly reduce worry and improve performance, especially for first-year students facing new academic challenges.","Category":"Well-being, Performance","Goal":"Augment","Focus":"Mental","Activity_type":"Cognitive","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Motivation","Authors(PaperCount, CitationCount)":"Shannon T. Brady(20, 7745); B. Hard(35, 1047); J. Gross(649, 126909)","citationCount":123,"fieldsOfStudy":"Psychology","influentialCitationCount":5,"publicationDate":"2017-12-21 00:00:00","publicationTypes":null,"publicationVenue":null,"referenceCount":60,"title":"Reappraising Test Anxiety Increases Academic Performance of First-Year College Students","tldr":null,"url":"https://www.semanticscholar.org/paper/1aabd0d972dd9ecbbe537bc3e325232275cf3486"},{"Tip":"Send an encouragement email or message before significant exams, incorporating the idea that anxiety can be helpful for performance. For instance, remind students that arousal can enhance their focus and performance.","Information":"The study found that an email including a reappraisal message helped first-year college students reduce worry and increase academic performance, suggesting practical applications of psychological research in educational settings.","Category":"Work, Focus","Goal":"Augment","Focus":"Social","Activity_type":"Social","Daytime":"Not relevant","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Direction","Authors(PaperCount, CitationCount)":"Shannon T. Brady(20, 7745); B. Hard(35, 1047); J. Gross(649, 126909)","citationCount":123,"fieldsOfStudy":"Psychology","influentialCitationCount":5,"publicationDate":"2017-12-21 00:00:00","publicationTypes":null,"publicationVenue":null,"referenceCount":60,"title":"Reappraising Test Anxiety Increases Academic Performance of First-Year College Students","tldr":null,"url":"https://www.semanticscholar.org/paper/1aabd0d972dd9ecbbe537bc3e325232275cf3486"},{"Tip":"Before studying for exams, engage in a quick physical activity like stretching or jogging for 10-15 minutes. This boosts energy levels and aids in focus.","Information":"Engaging in brief exercise boosts energy and concentration, which can enhance cognitive performance, supported by findings on the importance of physical activity for mental and emotional health.","Category":"Health, Performance","Goal":"Recover","Focus":"Physical","Activity_type":"Exercise","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Sunny","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"Shannon T. Brady(20, 7745); B. Hard(35, 1047); J. Gross(649, 126909)","citationCount":123,"fieldsOfStudy":"Psychology","influentialCitationCount":5,"publicationDate":"2017-12-21 00:00:00","publicationTypes":null,"publicationVenue":null,"referenceCount":60,"title":"Reappraising Test Anxiety Increases Academic Performance of First-Year College Students","tldr":null,"url":"https://www.semanticscholar.org/paper/1aabd0d972dd9ecbbe537bc3e325232275cf3486"},{"Tip":"Practice mindfulness or breathing exercises for 5-10 minutes daily to manage stress and improve focus.","Information":"Mindfulness practices have been shown to reduce anxiety and enhance cognitive performance, which is crucial during academically demanding times, as highlighted by psychological studies.","Category":"Well-being, Focus","Goal":"Prevent","Focus":"Mental","Activity_type":"Relax","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Stress Management","Authors(PaperCount, CitationCount)":"Shannon T. Brady(20, 7745); B. Hard(35, 1047); J. Gross(649, 126909)","citationCount":123,"fieldsOfStudy":"Psychology","influentialCitationCount":5,"publicationDate":"2017-12-21 00:00:00","publicationTypes":null,"publicationVenue":null,"referenceCount":60,"title":"Reappraising Test Anxiety Increases Academic Performance of First-Year College Students","tldr":null,"url":"https://www.semanticscholar.org/paper/1aabd0d972dd9ecbbe537bc3e325232275cf3486"},{"Tip":"Set aside 30 minutes each week for reflective journaling about your study sessions, noting feelings of anxiety and how they could be interpreted positively.","Information":"Reflective practices can help students reframe their experiences and reduce anxiety, potentially leading to better academic outcomes, as shown in recent educational psychology research.","Category":"Active Reflection, Performance","Goal":"Augment","Focus":"Mental","Activity_type":"Cognitive","Daytime":"Evening","Weekday":"Weekend","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Goal-Setting","Authors(PaperCount, CitationCount)":"Shannon T. Brady(20, 7745); B. Hard(35, 1047); J. Gross(649, 126909)","citationCount":123,"fieldsOfStudy":"Psychology","influentialCitationCount":5,"publicationDate":"2017-12-21 00:00:00","publicationTypes":null,"publicationVenue":null,"referenceCount":60,"title":"Reappraising Test Anxiety Increases Academic Performance of First-Year College Students","tldr":null,"url":"https://www.semanticscholar.org/paper/1aabd0d972dd9ecbbe537bc3e325232275cf3486"},{"Tip":"Set aside at least 2 hours each day for focused work without distractions. This can boost your productivity by enhancing concentration on tasks like writing or data analysis.","Information":"Researchers Aczel et al. found that while some academics achieved better focus and efficiency at home, many experienced a decline during lockdown periods due to distractions. Prioritizing dedicated, distraction-free time can help mitigate these effects.","Category":"Productivity","Goal":"Augment","Focus":"Work","Activity_type":"Cognitive","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Time Management","Authors(PaperCount, CitationCount)":"B. Aczel(143, 2494); Márton Kovács(48, 570); Tanja van der Lippe(88, 3590); B. Szaszi(73, 1414)","citationCount":105,"fieldsOfStudy":"Medicine","influentialCitationCount":9,"publicationDate":"2020-09-23 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"PLoS ONE","referenceCount":63,"title":"Researchers working from home: Benefits and challenges","tldr":"It is found that the pandemic lockdown decreased the work efficiency for almost half of the researchers but around a quarter of them were more efficient during this time compared to the time before, and that working from home is becoming a major element of researchers’ life.","url":"https://www.semanticscholar.org/paper/ddf073a6a2c349bf1b77568ffb2eb17bbd3a27e9"},{"Tip":"Incorporate at least 30 minutes of physical exercise daily to support both mental and physical well-being and enhance productivity.","Information":"The study highlights the importance of physical well-being for effective work performance. Regular exercise has been shown to improve mood and cognitive function, directly impacting productivity.","Category":"Health","Goal":"Augment","Focus":"Physical","Activity_type":"Exercise","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Sunny","Concerns":"Stress Management","Authors(PaperCount, CitationCount)":"B. Aczel(143, 2494); Márton Kovács(48, 570); Tanja van der Lippe(88, 3590); B. Szaszi(73, 1414)","citationCount":105,"fieldsOfStudy":"Medicine","influentialCitationCount":9,"publicationDate":"2020-09-23 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"PLoS ONE","referenceCount":63,"title":"Researchers working from home: Benefits and challenges","tldr":"It is found that the pandemic lockdown decreased the work efficiency for almost half of the researchers but around a quarter of them were more efficient during this time compared to the time before, and that working from home is becoming a major element of researchers’ life.","url":"https://www.semanticscholar.org/paper/ddf073a6a2c349bf1b77568ffb2eb17bbd3a27e9"},{"Tip":"Establish a clear start and end time for your workday to create better boundaries between work and personal life. Aim for a defined schedule each day during your work-from-home period.","Information":"Aczel and colleagues emphasized the need for individuals to control their work-life boundaries, which can blur during remote work. Setting specific work hours can help maintain a healthy balance and improve productivity.","Category":"Well-being","Goal":"Prevent","Focus":"Non-Work","Activity_type":"Time Management","Daytime":"Not relevant","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Work-Life Balance","Authors(PaperCount, CitationCount)":"B. Aczel(143, 2494); Márton Kovács(48, 570); Tanja van der Lippe(88, 3590); B. Szaszi(73, 1414)","citationCount":105,"fieldsOfStudy":"Medicine","influentialCitationCount":9,"publicationDate":"2020-09-23 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"PLoS ONE","referenceCount":63,"title":"Researchers working from home: Benefits and challenges","tldr":"It is found that the pandemic lockdown decreased the work efficiency for almost half of the researchers but around a quarter of them were more efficient during this time compared to the time before, and that working from home is becoming a major element of researchers’ life.","url":"https://www.semanticscholar.org/paper/ddf073a6a2c349bf1b77568ffb2eb17bbd3a27e9"},{"Tip":"Engage in a 5-minute mindfulness or breathing exercise at the start and end of your work sessions to enhance focus and reduce stress.","Information":"As detailed by Aczel et al., increased stress and distraction at home can hinder productivity. Mindfulness techniques can improve concentration and mental health during work hours.","Category":"Focus","Goal":"Recover","Focus":"Mental","Activity_type":"Relax","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Motivation","Authors(PaperCount, CitationCount)":"B. Aczel(143, 2494); Márton Kovács(48, 570); Tanja van der Lippe(88, 3590); B. Szaszi(73, 1414)","citationCount":105,"fieldsOfStudy":"Medicine","influentialCitationCount":9,"publicationDate":"2020-09-23 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"PLoS ONE","referenceCount":63,"title":"Researchers working from home: Benefits and challenges","tldr":"It is found that the pandemic lockdown decreased the work efficiency for almost half of the researchers but around a quarter of them were more efficient during this time compared to the time before, and that working from home is becoming a major element of researchers’ life.","url":"https://www.semanticscholar.org/paper/ddf073a6a2c349bf1b77568ffb2eb17bbd3a27e9"},{"Tip":"Maintain regular social interactions with colleagues at least twice a week, either through video calls or group chats, to combat feelings of isolation.","Information":"The findings from Aczel et al. noted that many researchers felt disconnected when working from home. Regular social support can improve morale and promote a sense of connection.","Category":"Social","Goal":"Recover","Focus":"Social","Activity_type":"Social","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"B. Aczel(143, 2494); Márton Kovács(48, 570); Tanja van der Lippe(88, 3590); B. Szaszi(73, 1414)","citationCount":105,"fieldsOfStudy":"Medicine","influentialCitationCount":9,"publicationDate":"2020-09-23 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"PLoS ONE","referenceCount":63,"title":"Researchers working from home: Benefits and challenges","tldr":"It is found that the pandemic lockdown decreased the work efficiency for almost half of the researchers but around a quarter of them were more efficient during this time compared to the time before, and that working from home is becoming a major element of researchers’ life.","url":"https://www.semanticscholar.org/paper/ddf073a6a2c349bf1b77568ffb2eb17bbd3a27e9"},{"Tip":"Limit multitasking and set specific goals for each work session. For example, aim to complete one major task before switching to another.","Information":"Aczel and colleagues noted that multitasking can blur work-life boundaries and reduce efficiency. Focusing on one task at a time can improve outcomes and time management.","Category":"Time Management","Goal":"Prevent","Focus":"Work","Activity_type":"Cognitive","Daytime":"Not relevant","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Procrastination","Authors(PaperCount, CitationCount)":"B. Aczel(143, 2494); Márton Kovács(48, 570); Tanja van der Lippe(88, 3590); B. Szaszi(73, 1414)","citationCount":105,"fieldsOfStudy":"Medicine","influentialCitationCount":9,"publicationDate":"2020-09-23 00:00:00","publicationTypes":"JournalArticle, Review","publicationVenue":"PLoS ONE","referenceCount":63,"title":"Researchers working from home: Benefits and challenges","tldr":"It is found that the pandemic lockdown decreased the work efficiency for almost half of the researchers but around a quarter of them were more efficient during this time compared to the time before, and that working from home is becoming a major element of researchers’ life.","url":"https://www.semanticscholar.org/paper/ddf073a6a2c349bf1b77568ffb2eb17bbd3a27e9"},{"Tip":"Allow yourself short breaks for personal activities, such as browsing the internet or watching a funny video, every hour for 5-10 minutes. This helps replenish your concentration and can improve productivity afterward.","Information":"Research by Bucciol, Houser, and Piovesan (2013) indicates that briefly engaging in enjoyable activities can enhance performance on subsequent tasks by preventing willpower depletion.","Category":"Productivity, Health","Goal":"Augment","Focus":"Work, Mental","Activity_type":"Relax","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Procrastination, Self-Discipline","Authors(PaperCount, CitationCount)":"A. Bucciol(122, 1851); Daniel Houser(196, 7802); M. Piovesan(46, 1770)","citationCount":27,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2011-02-21 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"PLoS ONE","referenceCount":17,"title":"Temptation at Work","tldr":"It is shown that resisting the temptation to join others in watching a humorous video for 10 minutes detrimentally impacts economic productivity on a subsequent task.","url":"https://www.semanticscholar.org/paper/dd67f96f5961ec2dfde812408e9f25be7627ec38"},{"Tip":"Take regular breaks during work. Aim for a 5-minute break for every 25 minutes of focused work to sustain your energy and attention levels throughout the day.","Information":"The findings of Bucciol et al. (2013) highlight that resisting temporary distractions consumes energy, negatively impacting later performance. Short breaks are essential for maintaining productivity levels.","Category":"Productivity, Health","Goal":"Augment","Focus":"Work, Mental","Activity_type":"Relax","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Time Management, Stress Management","Authors(PaperCount, CitationCount)":"A. Bucciol(122, 1851); Daniel Houser(196, 7802); M. Piovesan(46, 1770)","citationCount":27,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2011-02-21 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"PLoS ONE","referenceCount":17,"title":"Temptation at Work","tldr":"It is shown that resisting the temptation to join others in watching a humorous video for 10 minutes detrimentally impacts economic productivity on a subsequent task.","url":"https://www.semanticscholar.org/paper/dd67f96f5961ec2dfde812408e9f25be7627ec38"},{"Tip":"Implement a 'no-temptation' zone in your workspace, limiting distractions, and if possible, organize work tasks around times when you can allow yourself indulgences after productive phases.","Information":"The study suggests that the increase in productivity can occur after engaging positively with temptations, making it beneficial to work alongside periods of relaxation.","Category":"Productivity, Health","Goal":"Prevent","Focus":"Work, Mental","Activity_type":"Time Management","Daytime":"Not relevant","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Workspace Management, Self-Motivation","Authors(PaperCount, CitationCount)":"A. Bucciol(122, 1851); Daniel Houser(196, 7802); M. Piovesan(46, 1770)","citationCount":27,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2011-02-21 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"PLoS ONE","referenceCount":17,"title":"Temptation at Work","tldr":"It is shown that resisting the temptation to join others in watching a humorous video for 10 minutes detrimentally impacts economic productivity on a subsequent task.","url":"https://www.semanticscholar.org/paper/dd67f96f5961ec2dfde812408e9f25be7627ec38"},{"Tip":"Practice self-compassion after making a mistake at work, such as acknowledging that mistakes are a part of the learning process rather than a failure. This approach might help in recovering from minor productivity dips due to temptation.","Information":"As shown in the research by Bucciol et al. (2013), the mental state following temptation affects productivity, thus promoting a supportive attitude can enhance future performance.","Category":"Well-being, Health","Goal":"Recover","Focus":"Mental","Activity_type":"Cognitive","Daytime":"End of the day","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Mindset, Self-Discipline","Authors(PaperCount, CitationCount)":"A. Bucciol(122, 1851); Daniel Houser(196, 7802); M. Piovesan(46, 1770)","citationCount":27,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2011-02-21 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"PLoS ONE","referenceCount":17,"title":"Temptation at Work","tldr":"It is shown that resisting the temptation to join others in watching a humorous video for 10 minutes detrimentally impacts economic productivity on a subsequent task.","url":"https://www.semanticscholar.org/paper/dd67f96f5961ec2dfde812408e9f25be7627ec38"},{"Tip":"Engage in light physical activity, such as a 10-minute walk every hour, to reduce mental fatigue and increase overall productivity during work hours.","Information":"The research emphasizes that willpower depletion from avoiding temptations can impair focus, hence physical movement helps in refreshing mental capacities.","Category":"Fitness, Productivity","Goal":"Recover","Focus":"Physical, Mental","Activity_type":"Exercise","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Sunny, Overcast","Concerns":null,"Authors(PaperCount, CitationCount)":"A. Bucciol(122, 1851); Daniel Houser(196, 7802); M. Piovesan(46, 1770)","citationCount":27,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2011-02-21 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"PLoS ONE","referenceCount":17,"title":"Temptation at Work","tldr":"It is shown that resisting the temptation to join others in watching a humorous video for 10 minutes detrimentally impacts economic productivity on a subsequent task.","url":"https://www.semanticscholar.org/paper/dd67f96f5961ec2dfde812408e9f25be7627ec38"},{"Tip":"Establish a consistent work interval (WI) by maintaining a regular start and end time for your workday. Aim for a WI duration that does not vary more than 30 minutes each day.","Information":"A study by Ikeda and Kubo (2024) found that irregular work intervals are linked to irregular sleep patterns, impacting worker health. Keeping consistent work hours helps stabilize sleep schedules.","Category":"Health","Goal":"Prevent","Focus":"Work","Activity_type":"Time Management","Daytime":"Morning","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Work-Life Balance","Authors(PaperCount, CitationCount)":"Hiroki Ikeda(39, 162); T. Kubo(72, 760)","citationCount":1,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-02-14 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"Journal of Occupational Health","referenceCount":26,"title":"The association between work interval regularity and sleep regularity: a 2-week observational study in daytime employees","tldr":"Regularity of WI was associated with regularity of sleep, and workers should have regular WI, and if they are exposed to irregular WI, they should make every effort to maintain regular sleep.","url":"https://www.semanticscholar.org/paper/70589afd914917e0b3fa3ddbbec7d0f437065934"},{"Tip":"Aim to get at least 7-9 hours of sleep per night. Create a sleep schedule that includes a consistent bedtime and wake-up time, avoiding shifts larger than 30 minutes.","Information":"Research indicates that sleep regularity is crucial for health and productivity. Irregular sleep patterns increase the risk of cardiovascular and mental health issues, as found by Ikeda and Kubo (2024).","Category":"Health","Goal":"Prevent","Focus":"Mental","Activity_type":"Relax","Daytime":"Evening","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Sleep Quality","Authors(PaperCount, CitationCount)":"Hiroki Ikeda(39, 162); T. Kubo(72, 760)","citationCount":1,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-02-14 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"Journal of Occupational Health","referenceCount":26,"title":"The association between work interval regularity and sleep regularity: a 2-week observational study in daytime employees","tldr":"Regularity of WI was associated with regularity of sleep, and workers should have regular WI, and if they are exposed to irregular WI, they should make every effort to maintain regular sleep.","url":"https://www.semanticscholar.org/paper/70589afd914917e0b3fa3ddbbec7d0f437065934"},{"Tip":"If you have irregular work intervals due to job demands, plan a wind-down routine before bed, including activities like reading or meditation for at least 30 minutes to signal your body to prepare for sleep.","Information":"According to the findings by Ikeda and Kubo (2024), irregular work intervals can disturb sleep regularity. A calming pre-sleep routine might help counteract this issue.","Category":"Well-being","Goal":"Recover","Focus":"Mental","Activity_type":"Relax","Daytime":"Evening","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Stress Management","Authors(PaperCount, CitationCount)":"Hiroki Ikeda(39, 162); T. Kubo(72, 760)","citationCount":1,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-02-14 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"Journal of Occupational Health","referenceCount":26,"title":"The association between work interval regularity and sleep regularity: a 2-week observational study in daytime employees","tldr":"Regularity of WI was associated with regularity of sleep, and workers should have regular WI, and if they are exposed to irregular WI, they should make every effort to maintain regular sleep.","url":"https://www.semanticscholar.org/paper/70589afd914917e0b3fa3ddbbec7d0f437065934"},{"Tip":"Limit caffeine and screen time at least one hour before bedtime to improve your chances of a restful night’s sleep. Aim for no screens in the hour leading up to sleep.","Information":"Ikeda and Kubo (2024) found irregular sleep can heighten health risks. Reducing stimulants and screens helps promote better sleep quality.","Category":"Health","Goal":"Prevent","Focus":"Mental","Activity_type":"Relax","Daytime":"Evening","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Sleep Quality","Authors(PaperCount, CitationCount)":"Hiroki Ikeda(39, 162); T. Kubo(72, 760)","citationCount":1,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-02-14 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"Journal of Occupational Health","referenceCount":26,"title":"The association between work interval regularity and sleep regularity: a 2-week observational study in daytime employees","tldr":"Regularity of WI was associated with regularity of sleep, and workers should have regular WI, and if they are exposed to irregular WI, they should make every effort to maintain regular sleep.","url":"https://www.semanticscholar.org/paper/70589afd914917e0b3fa3ddbbec7d0f437065934"},{"Tip":"Incorporate short breaks throughout your workday. Every 60-90 minutes, take a 5-10 minute break to stretch and move around, enhancing your productivity.","Information":"Regular breaks can mitigate fatigue and improve focus, as seen in the study by Ikeda and Kubo (2024) that addressed the impact of work patterns on health.","Category":"Performance","Goal":"Augment","Focus":"Work","Activity_type":"Time Management","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Discipline","Authors(PaperCount, CitationCount)":"Hiroki Ikeda(39, 162); T. Kubo(72, 760)","citationCount":1,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-02-14 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"Journal of Occupational Health","referenceCount":26,"title":"The association between work interval regularity and sleep regularity: a 2-week observational study in daytime employees","tldr":"Regularity of WI was associated with regularity of sleep, and workers should have regular WI, and if they are exposed to irregular WI, they should make every effort to maintain regular sleep.","url":"https://www.semanticscholar.org/paper/70589afd914917e0b3fa3ddbbec7d0f437065934"},{"Tip":"Encourage open communication in your workplace about work intervals and stress management. Aim to have regular check-ins with your team every two weeks.","Information":"Engaging in regular discussions can reduce anxiety about work expectations which can stabilize both work intervals and sleep habits, based on insights from Ikeda and Kubo (2024).","Category":"Social","Goal":"Recover","Focus":"Social","Activity_type":"Social","Daytime":"Noon","Weekday":"Workdays","Validity_Flag":true,"Weather":"Not relevant","Concerns":"Self-Motivation","Authors(PaperCount, CitationCount)":"Hiroki Ikeda(39, 162); T. Kubo(72, 760)","citationCount":1,"fieldsOfStudy":"Medicine","influentialCitationCount":0,"publicationDate":"2024-02-14 00:00:00","publicationTypes":"JournalArticle","publicationVenue":"Journal of Occupational Health","referenceCount":26,"title":"The association between work interval regularity and sleep regularity: a 2-week observational study in daytime employees","tldr":"Regularity of WI was associated with regularity of sleep, and workers should have regular WI, and if they are exposed to irregular WI, they should make every effort to maintain regular sleep.","url":"https://www.semanticscholar.org/paper/70589afd914917e0b3fa3ddbbec7d0f437065934"}] + } + + + + + + + + + + + + + + + diff --git a/tests/test_chat_agent.py b/tests/test_chat_agent.py new file mode 100644 index 0000000..717defc --- /dev/null +++ b/tests/test_chat_agent.py @@ -0,0 +1,65 @@ +from dotenv import load_dotenv +from just_agents.base_agent import ChatAgent +from just_agents.patterns.chain_of_throught import ChainOfThoughtAgent +import just_agents.llm_options + +from just_agents.tools.db import sqlite_query +import pytest +import requests +import os +from pathlib import Path +from pycomfort.logging import to_nice_stdout +to_nice_stdout() +db_path = Path("tests/data/open_genes.sqlite") + +@pytest.fixture(scope="session") +def open_genes_db() -> Path: + """Downloads the open_genes.sqlite database if not present and returns the path""" + # Define the database path + db_path = Path("tests/data/open_genes.sqlite").absolute().resolve() + + + # Create directories if they don't exist + db_path.parent.mkdir(parents=True, exist_ok=True) + + # Download file if it doesn't exist + if not db_path.exists(): + url = "https://github.com/longevity-genie/longevity_gpts/raw/main/open_genes/data/open_genes.sqlite" + print(f"Downloading database from {url}") + + response = requests.get(url) + response.raise_for_status() # Raise an error for bad status codes + + # Save the file + with open(db_path, "wb") as f: + f.write(response.content) + + print(f"Database saved to {db_path}") + + return db_path + + +def test_quering(open_genes_db): + load_dotenv(override = True) + + agent = ChatAgent(role="helpful agent which knows how operate with databases", + goal=f"help users by using SQL syntax to form comands to work with the {open_genes_db} sqlite database", + task="formulate appropriate comands to operate in the given database.", + tools=[sqlite_query], + llm_options=just_agents.llm_options.LLAMA3_3) + + + response = agent.query("Show me all tables in the database") + agent.memory.pretty_print_all_messages() + assert response is not None, "Response should not be None" + + # Add specific table checks + expected_tables = [ + 'lifespan_change', + 'gene_criteria', + 'gene_hallmarks', + 'longevity_associations' + ] + + for table in expected_tables: + assert table.lower() in response.lower(), f"Expected table '{table}' not found in response" \ No newline at end of file diff --git a/tools/just_agents/tools/db.py b/tools/just_agents/tools/db.py index e69de29..1bc08a0 100644 --- a/tools/just_agents/tools/db.py +++ b/tools/just_agents/tools/db.py @@ -0,0 +1,49 @@ +import sqlite3 +from eliot import start_action +from pathlib import Path +def sqlite_query(database: str, sql: str) -> str: + """Execute a SQL query and return results as formatted text. + + Args: + database (Path | str): Path to the SQLite database file + sql (str): SQL query to execute + + Returns: + str: Query results formatted as semicolon-separated text. + First line contains column names, followed by rows of data. + Returns empty string if no results found. + """ + # Log the query execution using eliot + start_action(action_type="sqlite_query", database=database, sql=sql) + + # Convert string path to Path object if needed + if isinstance(database, str): + database = Path(database).absolute() + + # Establish database connection + conn = sqlite3.connect(database) + cursor = conn.cursor() + + cursor.execute(sql) + try: + # Fetch and format query results + rows = cursor.fetchall() + if rows is None or len(rows) == 0: + conn.close() + return "" + + # Extract column names from cursor description + names = [description[0] for description in cursor.description] + + # Format output with column names as first line + text = "; ".join(names) + "\n" + + # Add data rows, converting all values to strings + for row in rows: + row = [str(i) for i in row] + text += "; ".join(row) + "\n" + finally: + # Ensure connection is closed even if an error occurs + conn.close() + + return text \ No newline at end of file