SwiftOpenAI
SwiftOpenAI copied to clipboard
`baseURL` does not work for services that has the OpenAI compatible API under a sub-path
For example, https://api.groq.com/openai does not work as a baseURL. The openai parts gets replaced and the URL ends up as https://api.groq.com/v1/chat/completions instead.
It's what Groq uses to access their OpenAI compatible API: https://console.groq.com/docs/openai
@jamesrochabrun feel free to borrow my approach in AIProxySwift to solve this:
https://github.com/lzell/AIProxySwift/blob/main/Sources/AIProxy/AIProxyURLRequest.swift#L23-L30
Basically, create two URLComponents (one for the baseURL, and one for the completions path), then concatenate their paths. Remember to put the query params back in (line 31)
@jamesrochabrun Would you accept a pull request for this?
@sindresorhus yes!
support for Groq is now available https://github.com/jamesrochabrun/SwiftOpenAI/releases/tag/v3.8.2 @sindresorhus