We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
override init() { super.init() service = OpenAIServiceFactory.service(apiKey: Constants.apiKey, organizationID: Constants.orgId) imagesProvider = ImagesProvider(service: service) provider = AssistantConfigurationProvider(service: service) if Constants.isAssistantCreated == false { Task { parameters.tools.append(AssistantFunctionCallDefinition.createImage.functionTool) parameters.tools.append(AssistantObject.Tool(type: .codeInterpreter)) parameters.name = "Personal Assistant" parameters.description = "My personal AI assistant to answer my questions" parameters.instructions = Constants.aiDescription try await provider.createAssistant(parameters: parameters) Constants.isAssistantCreated = true Constants.assistantId = provider.assistant!.id assistant = provider.assistant! threadProvider = AssistantThreadConfigurationProvider(service: service) try await threadProvider.createThread() if let threadID = threadProvider.thread?.id { tutorialStage = .showStream(threadID: threadID) Constants.isThreadCreated = true Constants.threadId = threadID } } }else { Task { try await provider.getAssistantById(assistantId:Constants.assistantId) assistant = provider.assistant! threadProvider = AssistantThreadConfigurationProvider(service: service) try await threadProvider.createThread() if let threadID = threadProvider.thread?.id { tutorialStage = .showStream(threadID: threadID) Constants.isThreadCreated = true Constants.threadId = threadID } } }
}
This is my sendMessage Function the is function call output without image url and after that not any new message return same response.
func sendMessage(strMessage : String ,handler : @escaping (_ succuss : Bool, _ chatModel : ChatModel?) -> Void) { Task { try await threadProvider.createMessage(threadID: Constants.threadId, parameters: .init(role: .user, content: strMessage)) threadProvider.messageText = "" threadProvider.toolOuptutMessage = "" try await threadProvider.createRunAndStreamMessage( threadID: Constants.threadId, parameters: .init(assistantID: assistant.id)) if let message = threadProvider.message { if !threadProvider.toolOuptutMessage.isEmpty { let senderType = SenderType.assistant let model = ChatModel(strUserName : Constants.username , strMessage: threadProvider.toolOuptutMessage,senderType: senderType) handler(true,model) }else if !threadProvider.messageText.isEmpty { let senderType = SenderType.assistant let model = ChatModel(strUserName : Constants.username , strMessage: threadProvider.messageText,senderType: senderType) handler(true,model) }else if !threadProvider.functionCallOutput.isEmpty { let senderType = SenderType.assistant let model = ChatModel(strUserName : Constants.username , strMessage: threadProvider.functionCallOutput,senderType: senderType) handler(true,model) } } } }
The text was updated successfully, but these errors were encountered:
Can you share the netwrok request and response? thanks
Sorry, something went wrong.
No branches or pull requests
override init() {
super.init()
service = OpenAIServiceFactory.service(apiKey: Constants.apiKey, organizationID: Constants.orgId)
imagesProvider = ImagesProvider(service: service)
provider = AssistantConfigurationProvider(service: service)
if Constants.isAssistantCreated == false {
Task {
parameters.tools.append(AssistantFunctionCallDefinition.createImage.functionTool)
parameters.tools.append(AssistantObject.Tool(type: .codeInterpreter))
parameters.name = "Personal Assistant"
parameters.description = "My personal AI assistant to answer my questions"
parameters.instructions = Constants.aiDescription
try await provider.createAssistant(parameters: parameters)
Constants.isAssistantCreated = true
Constants.assistantId = provider.assistant!.id
assistant = provider.assistant!
threadProvider = AssistantThreadConfigurationProvider(service: service)
try await threadProvider.createThread()
if let threadID = threadProvider.thread?.id {
tutorialStage = .showStream(threadID: threadID)
Constants.isThreadCreated = true
Constants.threadId = threadID
}
}
}else {
Task {
try await provider.getAssistantById(assistantId:Constants.assistantId)
assistant = provider.assistant!
threadProvider = AssistantThreadConfigurationProvider(service: service)
try await threadProvider.createThread()
if let threadID = threadProvider.thread?.id {
tutorialStage = .showStream(threadID: threadID)
Constants.isThreadCreated = true
Constants.threadId = threadID
}
}
}
This is my sendMessage Function the is function call output without image url and after that not any new message return same response.
func sendMessage(strMessage : String ,handler : @escaping (_ succuss : Bool, _ chatModel : ChatModel?) -> Void) {
Task {
try await threadProvider.createMessage(threadID: Constants.threadId, parameters: .init(role: .user, content: strMessage))
threadProvider.messageText = ""
threadProvider.toolOuptutMessage = ""
try await threadProvider.createRunAndStreamMessage(
threadID: Constants.threadId,
parameters: .init(assistantID: assistant.id))
if let message = threadProvider.message {
if !threadProvider.toolOuptutMessage.isEmpty {
let senderType = SenderType.assistant
let model = ChatModel(strUserName : Constants.username , strMessage: threadProvider.toolOuptutMessage,senderType: senderType)
handler(true,model)
}else if !threadProvider.messageText.isEmpty {
let senderType = SenderType.assistant
let model = ChatModel(strUserName : Constants.username , strMessage: threadProvider.messageText,senderType: senderType)
handler(true,model)
}else if !threadProvider.functionCallOutput.isEmpty {
let senderType = SenderType.assistant
let model = ChatModel(strUserName : Constants.username , strMessage: threadProvider.functionCallOutput,senderType: senderType)
handler(true,model)
}
}
}
}
The text was updated successfully, but these errors were encountered: