Skip to content

Commit

Permalink
Updated README and unit tests to properly reflect builder syntax appr…
Browse files Browse the repository at this point in the history
…oach.
  • Loading branch information
btfranklin committed Apr 18, 2023
1 parent 7d7803b commit 75132a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ Initialize an OpenAIAPIConnection with your API key:
let openAIAPIConnection = OpenAIAPIConnection(apiKey: "your_api_key_here")
```

Create an OpenAIChatThread instance with the connection:
Create an OpenAIChatThread instance with the connection, and
add system, user, or assistant messages to the chat thread:

```swift
let chatThread = OpenAIChatThread(connection: openAIAPIConnection)
```

Add system, user, or assistant messages to the chat thread:

```swift
chatThread.addSystemMessage(content: "You are a helpful assistant.")
.addUserMessage(content: "Who won the world series in 2020?")
.addSystemMessage(content: "You are a helpful assistant.")
.addUserMessage(content: "Who won the world series in 2020?")
```

Generate a completion using the chat thread:
Expand Down
9 changes: 4 additions & 5 deletions Tests/CleverBirdTests/OpenAIChatThreadTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class OpenAIChatThreadTests: XCTestCase {

let openAIAPIConnection = OpenAIAPIConnection(apiKey: "fake_api_key", urlRequester: mockURLRequester)
let chatThread = OpenAIChatThread(connection: openAIAPIConnection)
.addSystemMessage(content: "You are a helpful assistant.")
.addUserMessage(content: "Who won the world series in 2020?")

chatThread.addSystemMessage(content: "You are a helpful assistant.")
chatThread.addUserMessage(content: "Who won the world series in 2020?")

let completionResponse = await chatThread.complete()

Expand All @@ -69,9 +69,8 @@ class OpenAIChatThreadTests: XCTestCase {
func testTokenCount() {
let openAIAPIConnection = OpenAIAPIConnection(apiKey: "fake_api_key", urlRequester: MockURLRequester(response: ""))
let chatThread = OpenAIChatThread(connection: openAIAPIConnection)

chatThread.addSystemMessage(content: "You are a helpful assistant.")
chatThread.addUserMessage(content: "Who won the world series in 2020?")
.addSystemMessage(content: "You are a helpful assistant.")
.addUserMessage(content: "Who won the world series in 2020?")

let tokenCount = chatThread.tokenCount()

Expand Down

0 comments on commit 75132a3

Please sign in to comment.