Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ import SwiftOpenAI
struct AIProxyIntroView: View {

@State private var partialKey = ""
@State private var serviceURL = ""

var body: some View {
NavigationStack {
VStack {
Spacer()
VStack(spacing: 24) {
TextField("Enter partial key", text: $partialKey)
TextField("Enter your service's URL", text: $serviceURL)
}
.padding()
.textFieldStyle(.roundedBorder)

Text("You receive a partial key when you configure an app in the AIProxy dashboard")
Text("You receive a partial key and service URL when you configure an app in the AIProxy dashboard")
.font(.caption)

NavigationLink(destination: OptionsListView(openAIService: aiproxyService, options: OptionsListView.APIOption.allCases.filter({ $0 != .localChat }))) {
Expand All @@ -47,7 +49,10 @@ struct AIProxyIntroView: View {
}

private var aiproxyService: some OpenAIService {
OpenAIServiceFactory.service(aiproxyPartialKey: partialKey)
OpenAIServiceFactory.service(
aiproxyPartialKey: partialKey,
aiproxyServiceURL: serviceURL != "" ? serviceURL : nil
)
}
}

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ To configure AIProxy, see the instructions [here](#aiproxy).
1. Open your Swift project in Xcode.
2. Go to `File` -> `Add Package Dependency`.
3. In the search bar, enter [this URL](https://github.com/jamesrochabrun/SwiftOpenAI).
4. Choose the version you'd like to install.
4. Choose the version you'd like to install (see the note below).
5. Click `Add Package`.

Note: Xcode has a quirk where it defaults an SPM package's upper limit to 2.0.0. This package is beyond that
limit, so you should not accept the defaults that Xcode proposes. Instead, enter the lower bound of the
[release version](https://github.com/jamesrochabrun/SwiftOpenAI/releases) that you'd like to support, and then
tab out of the input box for Xcode to adjust the upper bound. Alternatively, you may select `branch` -> `main`
to stay on the bleeding edge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jamesrochabrun I snuck this note in, per the discussion here: #60 . Please let me know if you'd like to keep it

## Usage

To use SwiftOpenAI in your project, first import the package:
Expand Down Expand Up @@ -3022,10 +3028,11 @@ SwiftOpenAI supports proxying requests through AIProxy with two changes to your
Use:

let service = OpenAIServiceFactory.service(
aiproxyPartialKey: "hardcode_partial_key_here",
aiproxyPartialKey: "your_partial_key_goes_here",
aiproxyServiceURL: "your_service_url_goes_here"
)

The `aiproxyPartialKey` value is provided to you on the [AIProxy developer dashboard](https://developer.aiproxy.pro)
The `aiproxyPartialKey` and `aiproxyServiceURL` values are provided to you on the [AIProxy developer dashboard](https://developer.aiproxy.pro)

2. Add an `AIPROXY_DEVICE_CHECK_BYPASS' env variable to Xcode. This token is provided to you in the AIProxy
developer dashboard, and is necessary for the iOS simulator to communicate with the AIProxy backend.
Expand Down
Loading