Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

AI Reward Cards #1129

Merged
merged 12 commits into from
Mar 27, 2024
Merged

AI Reward Cards #1129

merged 12 commits into from
Mar 27, 2024

Conversation

bfollington
Copy link
Collaborator

@bfollington bfollington commented Mar 11, 2024

  • OpenAI integration and developer settings
  • Gated behind a flag (default off)

I introduced a dependency on a keychain interfacing library, I was tempted to avoid it but the direct interface to keychain immediately made me understand why everyone is using a library.

AI features can be enabled from the Developer Settings menu:
image

Screen.Recording.2024-03-19.at.3.58.54.pm.mov

@bfollington bfollington changed the title Prototype: Reward Cards Prototype: OpenAI Reward Cards Mar 19, 2024
@bfollington bfollington changed the title Prototype: OpenAI Reward Cards AI Reward Cards Mar 19, 2024
@bfollington bfollington marked this pull request as ready for review March 20, 2024 05:07
@@ -254,6 +255,7 @@ struct DeckDetailStackCursor: CursorProtocol {
// MARK: Model
struct DeckModel: ModelProtocol {
public static let backlinksToDraw = 1
public static let maxRewardCardBufferSize = 4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3, 4 and 5 all feel good in different ways

Copy link
Collaborator

@gordonbrander gordonbrander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Two requests for followup, but in another PR.

import Foundation
import KeychainSwift

actor KeychainService {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

public let instruction: String
}

actor OpenAIService {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A followup I'd like us to do:

  • I'd like to think about how to "protocolize" this API surface to avoid getting two entangled with the specifics of one model.
  • The chat API is a natural fit here. Most of the API vendors have converged on something nearly exactly the same shape as OpenAI's chat API.
  • The service should probably talk back and forth in a Codable AIChat type that can be serialized/deserialized to JSON. Similar shape to the chat API request/response, with an array of messages with system, assistant, and user roles, but free of model specifics.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more consideration. Let's think about how this might route through our PromptService. In principle, I like the idea of routing everything through it as a dispatcher.

@bfollington bfollington merged commit c5761ec into main Mar 27, 2024
1 check passed
@bfollington bfollington deleted the 2024-03-06-reward-cards branch March 27, 2024 06:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants