Blue Ridge Ruby 2024

Lightning Talk: ChatGPT Landscape Assistant

Lightning Talk: ChatGPT Landscape Assistant

by Daniel Nolan

In this lightning talk titled "ChatGPT Landscape Assistant," Daniel Nolan discusses a custom application he developed using the ChatGPT API to assist with lawn and landscape management.

Key Points:

- Introduction to Function Calling:

- Daniel explains that the app utilizes the ChatGPT Assistant API, particularly focusing on the function calling feature.

- Application Functionality:

- The app is designed in Python, with specific instruction sets that guide the assistant's functions.

- Personalization:

- The assistant is customized for Daniel's gardening needs. It knows his gardening preferences, like avoiding invasive or poisonous plants, and can identify specific details such as latitude and longitude relevant to his location, despite that information being altered for demonstration.

- Gardening Recommendations:

- Daniel shares that the assistant provided advice on plants suitable for creating a bee and butterfly sanctuary, as well as recommendations for growing various types of peppers.

- Live Demonstration:

- During the talk, he demonstrates how the assistant can answer questions about the garden’s needs by executing function calls.

- A live interaction shows that the assistant retrieves weather information, such as whether watering is needed based on upcoming forecast data.

- Function Execution:

- The application has functions like 'save thread' and 'get weather' which the assistant utilizes to process user queries effectively. For instance, the 'save thread' function stores conversation context in SQLite, while the weather function accesses relevant weather API parameters.

- Conclusion:

- Daniel emphasizes that function calling enhances user interaction by allowing specific inputs and executing the right functionalities directly, showcasing the potential of AI in personal gardening tasks.

This talk highlights innovative uses of AI technology in practical applications like landscape management, illustrating how users can leverage APIs for tailored solutions.

00:00:12.679 All right, so I'm going to give my first ever lightning talk. I'm also going to run the lightning talks. My name is Daniel Nolan, and I'm a senior developer at Thoughtbot. I'm going to tell you about my Lawn and Landscape Assistant that I've been building using the ChatGPT API, focusing particularly on function calling.
00:00:20.439 I'm not sure how many of you are familiar with function calling in ChatGPT, or if any of you have worked with ChatGPT Assistant via the API. It seems like most people use the app and not the API. So, this is an app that I built in Python. This application utilizes the Assistant API to provide functionalities guided by specific instructions.
00:00:47.360 Here we have an assistant that I've given instruction sets. It knows some of the data has been replaced; for example, I don't actually live in Asheville, and that’s not my latitude and longitude. We replaced that this morning. The assistant is aware of relevant details such as latitude and longitude, date formats, and it also understands that I don't want anything invasive, difficult to grow, or poisonous to dogs. My lawn consists of fescue grass, and we've planted a bee and butterfly sanctuary based on its recommendations. It suggested all of the plants for the sanctuary, and then we communicated back to it about what we have planted. It also recommended various types of peppers for our three different raised bed gardens.
00:01:39.000 Now, the interesting part is that I want to utilize this assistant to take care of my yard, so I’m able to ask it questions. Let’s see if this works live. The assistant already knows what I have planted, for example, whether carrots can grow in our garden. This ties into function calling, which I will demonstrate next.
00:02:05.600 I’m going to start with a simple example. I asked the assistant to save the thread for me. It should gleam some context from our previous conversation. However, it seems that didn’t update right now, but no worries. What happens is that as we receive messages back, we stream them through this function at the top. Once it detects a specific type of event that requires action, it triggers a function call. In my code, I have two functions: one called 'save thread' and another called 'get weather'.
00:02:54.239 Let’s try to execute the weather function. Here we go. The assistant processed my request and listed the information. For example, I asked whether I need to water the garden based on the forecast, and it replied ‘no’ because it knows how to interpret weather data. I've defined this function within the assistant, and it retrieves all the necessary parameters to call the weather API effectively. It understands to check the location, return the units in imperial, and fill in the fields required to complete the weather forecast request.
00:05:30.160 So, function calling allows the assistant to know about the functions I've described, such as the 'save thread' function, which saves the thread ID to an SQLite database. It’s a powerful feature that enables users to input various parameters and execute the appropriate function directly. That’s my talk, thank you!