Skip to content

This project is an example of a LangChain agent for managing tasks. The agent can add tasks, search for tasks based on their status, and delete tasks.

License

Notifications You must be signed in to change notification settings

itallonardi/AI-task-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-task-manager

This project is an example of a LangChain agent for task management. The agent can add tasks, search for tasks based on their status, and delete tasks. This example does not use a real database, only simulated data for demonstration purposes.

Setup

  1. Clone the repository.
  2. Create a .env file in the root directory with your OpenAI API key:
    OPENAI_API_KEY=your_openai_api_key_here
    
  3. Install the required dependencies:
    pip install -r requirements.txt
    
  4. Run the FastAPI server:
    uvicorn main:app --reload
    

Usage

The agent provides three main functions:

  • add_task: Adds a new task with a description and due date.
  • search_tasks: Searches for tasks with a specified status (e.g., pending, completed).
  • delete_task: Deletes a task.

Interacting with the Agent

Interaction with the agent is done through the /chat route. Send a POST request to this route with the following body:

{
  "text": "Request content here"
}

Example Request with curl

To add a new task, you can send:

curl -X POST "http://localhost:8000/chat" -H "Content-Type: application/json" -d '{"text": "I need to buy bread tomorrow"}'

The agent will invoke a function that will create the task and return a response like this:

{
  "status": "success",
  "operation": "add",
  "task_description": "buy bread",
  "due_date": "2024-07-15"
}

The agent will then return a natural language response to the user, such as:

{
  "response": "I have added your task to buy bread tomorrow. If there is anything else I can help with, please let me know."
}

Interaction Example

You can interact with the agent informally. For example, to add a task, you can send a text like:

{
  "text": "I need to buy bread tomorrow"
}

Or to search for pending tasks, you can send:

{
  "text": "What are my pending tasks?"
}

And to delete a task, you can send:

{
  "text": "Delete the task to buy bread"
}

The agent will process the request and return the appropriate response in natural language.

About

This project is an example of a LangChain agent for managing tasks. The agent can add tasks, search for tasks based on their status, and delete tasks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages