spezichat
Spezi Module to Handle and Display User Interfaces for Chat-based Interactions
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.0%) to scientific vocabulary
Repository
Spezi Module to Handle and Display User Interfaces for Chat-based Interactions
Basic Info
- Host: GitHub
- Owner: StanfordSpezi
- License: mit
- Language: Swift
- Default Branch: main
- Homepage: https://swiftpackageindex.com/StanfordSpezi/SpeziChat/documentation/spezichat
- Size: 385 KB
Statistics
- Stars: 9
- Watchers: 10
- Forks: 6
- Open Issues: 5
- Releases: 15
Metadata Files
README.md
Spezi Chat
Provides UI components for building chat-based applications.
Overview
The SpeziChat module provides views that can be used to implement chat-based use cases, such as a message view or a voice input field.
|
|
|
|:--:|:--:|:--:|
|ChatView|ChatView|ChatView|
Setup
1. Add Spezi Chat as a Dependency
You need to add the Spezi Chat Swift package to your app in Xcode or Swift package.
[!IMPORTANT]
If your application is not yet configured to use Spezi, follow the Spezi setup article to setup the core Spezi infrastructure.
2. Configure target properties
As SpeziChat is utilizing the SpeziSpeech module under the hood for speech interaction capabilities, one needs to ensure that your application has the necessary permissions for microphone access and speech recognition. Follow the steps below to configure the target properties within your Xcode project:
- Open your project settings in Xcode by selecting PROJECTNAME > TARGETNAME > Info tab.
- You will need to add two entries to the
Custom iOS Target Properties(so theInfo.plistfile) to provide descriptions for why your app requires these permissions:- Add a key named
Privacy - Microphone Usage Descriptionand provide a string value that describes why your application needs access to the microphone. This description will be displayed to the user when the app first requests microphone access. - Add another key named
Privacy - Speech Recognition Usage Descriptionwith a string value that explains why your app requires the speech recognition capability. This will be presented to the user when the app first attempts to perform speech recognition.
- Add a key named
These entries are mandatory for apps that utilize microphone and speech recognition features. Failing to provide them will result in your app being unable to access these features.
Usage
The underlying data model of SpeziChat is a Chat. It represents the content of a typical text-based chat between user and system(s). A Chat is nothing more than an ordered array of ChatEntitys which contain the content of the individual messages.
A ChatEntity consists of a ChatEntity/Role, a unique identifier, a timestamp as well as an String-based content which can contain Markdown-formatted text. In addition, a flag indicates if the ChatEntity is complete and no further content will be added.
[!NOTE]
TheChatEntityis able to store Markdown-based content which in turn is rendered as styled text in theChatView,MessagesView, andMessageView.
Chat View
The ChatView provides a basic reusable chat view which includes a message input field. The input can be either typed out via the iOS keyboard or provided as voice input and transcribed into written text. It accepts an additional messagePendingAnimation parameter to control whether a chat bubble animation is shown for a message that is currently being composed. By default, messagePendingAnimation has a value of nil and does not show.
In addition, the ChatView provides functionality to export the visualized Chat as a PDF document, JSON representation, or textual UTF-8 file (see ChatView/ChatExportFormat) via a Share Sheet (or Activity View).
```swift struct ChatTestView: View { @State private var chat: Chat = [ ChatEntity(role: .assistant, content: "Assistant Message!") ]
var body: some View {
ChatView($chat, exportFormat: .pdf)
.navigationTitle("SpeziChat")
}
} ```
[!NOTE] The
ChatViewprovides speech-to-text (recognition) as well as text-to-speech (synthesize) accessibility capabilities out-of-the-box via theSpeziSpeechmodule, facilitating seamless interaction with the content of theChatView.
Messages View
The MessagesView displays a Chat containing multiple ChatEntitys with different ChatEntity/Roles in a typical chat-like fashion.
The View automatically scrolls down to the newest message that is added to the passed Chat SwiftUI Binding.
The typingIndicator parameter controls when a typing indicator is shown onscreen for incoming messages to Chat.
```swift struct MessagesViewTestView: View { @State private var chat: Chat = [ ChatEntity(role: .user, content: "User Message!"), ChatEntity(role: .assistant, content: "Assistant Message!") ]
var body: some View {
MessagesView($chat)
}
} ```
Message View
The MessageView is a reusable SwiftUI View to display the contents of a ChatEntity within a typical chat message bubble. This bubble is properly aligned according to the associated ChatEntity/Role.
swift
struct MessageViewTestView: View {
var body: some View {
VStack {
MessageView(ChatEntity(role: .user, content: "User Message!"))
MessageView(ChatEntity(role: .assistant, content: "Assistant Message!"))
MessageView(ChatEntity(role: .hidden(type: .unknown), content: "System Message (hidden)!"))
}
.padding()
}
}
MessageInput View
The MessageInputView is a reusable SwiftUI View to handle text-based or speech-based user input. The provided message is attached to the passed Chat via a SwiftUI Binding.
```swift struct MessageInputTestView: View { @State private var chat: Chat = [] @State private var disableInput = false
var body: some View {
VStack {
Spacer()
MessageInputView($chat, messagePlaceholder: "TestMessage")
.disabled(disableInput)
/// Get the height of the `MessageInputView` via a SwiftUI `PreferenceKey`
.onPreferenceChange(MessageInputViewHeightKey.self) { newValue in
let messageInputHeight: CGFloat = newValue
// ...
}
}
}
} ```
For more information, please refer to the API documentation.
Applications using Spezi Chat
HealthGPT and LLMonFHIR provide a great starting points and examples using the SpeziChat module.
Contributing
Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.
License
This project is licensed under the MIT License. See Licenses for more information.

Owner
- Name: Stanford Spezi
- Login: StanfordSpezi
- Kind: organization
- Repositories: 1
- Profile: https://github.com/StanfordSpezi
Citation (CITATION.cff)
# # This source file is part of the Stanford Spezi open source project # # SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT # cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Schmiedmayer" given-names: "Paul" orcid: "https://orcid.org/0000-0002-8607-9148" - family-names: "Philipp" given-names: "Zagar" orcid: "https://orcid.org/0009-0001-5934-2078" - family-names: "Adrit" given-names: "Rao" orcid: "https://orcid.org/0000-0002-0780-033X" title: "SpeziChat" doi: 10.5281/zenodo.10161087 url: "https://github.com/StanfordSpezi/SpeziChat"
GitHub Events
Total
- Create event: 8
- Release event: 3
- Issues event: 5
- Watch event: 3
- Delete event: 4
- Member event: 1
- Issue comment event: 12
- Push event: 18
- Pull request review comment event: 25
- Pull request review event: 26
- Pull request event: 11
- Fork event: 5
Last Year
- Create event: 8
- Release event: 3
- Issues event: 5
- Watch event: 3
- Delete event: 4
- Member event: 1
- Issue comment event: 12
- Push event: 18
- Pull request review comment event: 25
- Pull request review event: 26
- Pull request event: 11
- Fork event: 5
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 2
- Total pull requests: 19
- Average time to close issues: 10 months
- Average time to close pull requests: 18 days
- Total issue authors: 2
- Total pull request authors: 4
- Average comments per issue: 0.5
- Average comments per pull request: 2.47
- Merged pull requests: 17
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 3
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 1.33
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- PSchmiedmayer (1)
- philippzagar (1)
- jdisho (1)
Pull Request Authors
- philippzagar (23)
- PSchmiedmayer (3)
- MatthewTurk247 (2)
- LeonNissen (2)
- vishnuravi (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 15
swiftpackageindex.com: github.com/StanfordSpezi/SpeziChat
Spezi Module to Handle and Display User Interfaces for Chat-based Interactions
- Homepage: https://swiftpackageindex.com/StanfordSpezi/SpeziChat/documentation/spezichat
- Documentation: https://swiftpackageindex.com/StanfordSpezi/SpeziChat/documentation
- License: mit
-
Latest release: 0.2.4
published over 1 year ago