Implementing ChatGPT in an iOS App

Introduction I haven’t had the opportunity to build a chatbot before. This topic was trending some time ago, and I always wanted to implement it myself. In this article, I will focus on the steps you need to know to successfully build and run a chatbot application. First Step The first step is to add the OpenAI dependency to your project: .package(url: "https://github.com/MacPaw/OpenAI.git", branch: "main") dependencies: [ .byNameItem( name: "OpenAI", condition: ....

July 21, 2024 · 2 min · Dmytro Chumakov

Combine practical usage examples

Introduction When working in a large codebase with a significant number of async events, I often found myself in situations where I couldn’t combine events effectively. This resulted in optimization problems and inefficient consumption of OS resources. The codebase contained closures and async/await, so it wasn’t possible to use operators like merge or combineLatest. After discovering this limitation, I decided to add new methods using Combine. I will be demonstrating this with a simple NetworkService responsible only for executing and validating requests using Combine....

June 22, 2024 · 2 min · Dmytro Chumakov

Combine — Basics

What is Combine? Combine Framework provides an API for processing async events over time such as user-input, network response, and other dynamic data. What is the purpose of Combine? The purpose of Combine is to simplify the management of async events and data streams. Publishers Publisher declares that a type can transit a sequence of values over time. A publisher delivers elements to one or more Subscriber instances. class PostService { func fetchPosts() -> AnyPublisher<[Post], Error> { guard let url = URL(string: "https://jsonplaceholder....

February 7, 2024 · 4 min · Dmytro Chumakov