Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
buhe committed Jan 17, 2024
2 parents a209cfe + d27a320 commit f3ede69
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ let package = Package(
name: "langchain-swift",
platforms: [
.iOS(.v15),
.macOS(.v12)
.macOS(.v12),
.watchOS(.v8),
.visionOS(.v1)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
Expand Down Expand Up @@ -37,7 +39,7 @@ let package = Package(
.product(name: "SWXMLHash", package: "SWXMLHash"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
.product(name: "SwiftFileStore", package: "swift-filestore"),
.product(name: "SimilaritySearchKit", package: "similarity-search-kit"),
.product(name: "SimilaritySearchKit", package: "similarity-search-kit", condition: .when(platforms: [.macOS, .iOS, .visionOS])),
.product(name: "GoogleGenerativeAI", package: "generative-ai-swift"),
]

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 🐇 LangChain Swift
[![Swift](https://github.com/buhe/langchain-swift/actions/workflows/swift.yml/badge.svg)](https://github.com/buhe/langchain-swift/actions/workflows/swift.yml) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Swift Package Manager](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg) [![Twitter](https://img.shields.io/badge/twitter-@buhe1986-blue.svg?style=flat)](http://twitter.com/buhe1986)

🚀 LangChain for Swift. Optimized for iOS, macOS and visionOS.(beta)
🚀 LangChain for Swift. Optimized for iOS, macOS, watchOS (part) and visionOS.(beta)


## Setup
Expand Down Expand Up @@ -434,7 +434,7 @@ Task(priority: .background) {
## 👍 Got Ideas?
Open an issue, and let's discuss!

Join Slack: https://join.slack.com/t/langchain-mobile/shared_invite/zt-26tzdzb2u-8RnP7hDQz~MWMg8EeIu0lQ

Join Slack: [https://join.slack.com/t/langchain-mobile/shared_invite/zt-26tzdzb2u-8RnP7hDQz~MWMg8EeIu0lQ
](https://join.slack.com/t/langchain-mobile/shared_invite/zt-2ajo39zxx-db9e_nbJcADTkGeB33PF7g)
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
3 changes: 2 additions & 1 deletion Sources/LangChain/document_loaders/AudioLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by 顾艳华 on 2023/9/3.
//


#if os(macOS) || os(iOS) || os(visionOS) || os(iPadOS)
import Foundation
import NIOPosix
import AsyncHTTPClient
Expand Down Expand Up @@ -115,3 +115,4 @@ public class AudioLoader: BaseLoader {
"Audio"
}
}
#endif
3 changes: 3 additions & 0 deletions Sources/LangChain/document_loaders/PDFLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import Foundation

#if os(macOS) || os(iOS) || os(visionOS) || os(iPadOS)
import PDFKit


Expand Down Expand Up @@ -50,3 +52,4 @@ public class PDFLoader: BaseLoader {
"PDF"
}
}
#endif
4 changes: 2 additions & 2 deletions Sources/LangChain/llms/Gemini.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class Gemini: LLM {
let response = try await model.generateContent(text)
return LLMResult(llm_output: response.text)
} else {
print("Please set openai api key.")
return LLMResult(llm_output: "Please set openai api key.")
print("Please set googleai api key.")
return LLMResult(llm_output: "Please set googleai api key.")
}
}
}
3 changes: 3 additions & 0 deletions Sources/LangChain/tools/JavascriptREPLTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import Foundation

#if os(macOS) || os(iOS) || os(visionOS) || os(iPadOS)
import JavaScriptCore


Expand Down Expand Up @@ -38,3 +40,4 @@ public class JavascriptREPLTool: BaseTool {


}
#endif
3 changes: 3 additions & 0 deletions Sources/LangChain/vectorstores/SimilaritySearchKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import Foundation

#if os(macOS) || os(iOS) || os(visionOS) || os(iPadOS)
import SimilaritySearchKit

private struct LangChainEmbeddingBridge: EmbeddingsProtocol {
Expand Down Expand Up @@ -53,3 +55,4 @@ public class SimilaritySearchKit: VectorStore {
await vs.addItem(id: UUID().uuidString, text: text, metadata: metadata)
}
}
#endif

0 comments on commit f3ede69

Please sign in to comment.