Si has llegado hasta aquí, puedes:
- Suscribirte Youtube
- Seguirme en Twitter
- Únete con esta invitación a la comunidad de Discord
- QUIZ semanal con preguntas sobre Swift
OpenAI API build with Swift ❤️
Home Page: https://www.swiftbeta.com
License: MIT License
Si has llegado hasta aquí, puedes:
The parameter temperature
in ChatCompletionsOptionalParameters is Int
. However, accepted values range from 0.0 to 1.0, so it should be a Double instead.
Firstly - thank you for a great library. It has made it really easy to get streaming chat completions.
One issue though; I can't see a way to terminate the stream once it has started. Am I missing something?
thank you.
I am trying to use the gpt-3.5-turbo-16k model for chat completions but I am not sure how to use this in the createChatCompletions method.
Looking at the options provided in the OpenAIModelType there is no such option to add my fine tuned model. Is it possible to create this feature?
Hi,
I host one of these OpenAI-API compatible inference servers for academics ( just like https://chat.lmsys.org ), and I was thinking about making an IOS app which would talk to such a server.
Turns out I'm a zero on swift, and Xcode is overwhelming from the first sight, to say the least.
The examples in the README lead me to nowhere. I have absolutely no idea how to transform this repo into a useful app.
A minimal example which one could clone and try would be amazingly welcome.
A second thing is that this repo is hardcoded to talk to OpenAI, but not to openai-compatible servers. This is something you might have some interest in. Check the example of https://Continue.dev - they allow you also to point to private inference servers.
Thanks!
需要支持带图片而且是数据流的chat,这样方便使用gpt-4o
Custom domain not allowed
I got error on createChatCompletionsStream.
Error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character ':' after top-level value around line 1, column 16." UserInfo={NSDebugDescription=Unexpected character ':' after top-level value around line 1, column 16., NSJSONSerializationErrorIndex=15})))
Sample data response
it seem the data is invalid
data: {"id":"chatcmpl-9lxsJJyn7dKbdXR6ZL0gKjmjata8b","object":"chat.completion.chunk","created":1721218603,"model":"gpt-3.5-turbo-0125","system_f
I was checking and I think that at the moment, the parameter for the function call feature is not yet included, since developers interact with the model and retrieve structured data.
Function calling in the OpenAI API is a mechanism that allows models to detect when a specific function needs to be invoked based on user input. Once detected, the model responds with JSON that adheres to the function signature.
I'd like to migrate to use this package, but I get the following error when I attempt to import SwiftOpenAI:
Compiling for iOS 15.0, but module 'SwiftOpenAI' has a minimum deployment target of iOS 16.0
My app is committed to supporting iOS 15.0+ so this is currently preventing me from switching to this package.
Hello,
I am trying to use the library of a M1 Max, but i am getting the following error:
Plug-in ended with uncaught signal: 5)
Any idea how to solve it? I have been investigating a little and It seems that some of the dependences are not compatible with the apple SoC.
Thanks in advance
As an optional param, an array of stop Strings is passed to OpenAI, not just a single stop String. This kills my main use case so hopefully it gets fixed soon!
TopP should be a double, not Int in Chat Completion
See OpenAI doc: https://platform.openai.com/docs/api-reference/chat/create#chat-create-top_p
I've added my API Key to the SwiftOpenAI.plist
file. The app launches, but all requests are failing. E.g., when creating an image:
Error creating Images with DALL·E: The operation couldn’t be completed. (SwiftOpenAI.OpenAIAPIError error 1.)
Am I missing any other requirements? Thanks
Sample code (adapted from the example given):
var openAI = SwiftOpenAI(apiKey: "sk-...")
for try await newMessage in try! await openAI.createChatCompletionsStream(model: .gpt3_5(.turbo),
messages: [.init(text: "Hello, how are you?", role: "user")],
optionalParameters: .init(stream: true))
{
dump(newMessage)
let newToken = newMessage.choices.first?.delta?.content
print("New Message Received: \(newToken) ")
}
While the code works and does stream all responses properly, it always fails with:
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around line 1, column 1." UserInfo={NSDebugDescription=Invalid value around line 1, column 1., NSJSONSerializationErrorIndex=1})))
Wrapping the calls in do {.. } catch DecodingError.dataCorrupted(let context)
works fine however, but should be handled by your framework.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.