Skip to content

Commit ecd2b9f

Browse files
committed
Embed the project in a workspace so the playground can work properly
1 parent 265c3c7 commit ecd2b9f

8 files changed

Lines changed: 140 additions & 5 deletions

File tree

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@
151151
C8216B772980370100AD38C7 /* ReloadLaunchAgent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReloadLaunchAgent.swift; sourceTree = "<group>"; };
152152
C82E38492A1F025F00D4EADF /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
153153
C83E3F3E2A38C66D0071506D /* Python */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Python; sourceTree = "<group>"; };
154-
C83E5DE92A38CD000071506D /* site-packages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "site-packages"; path = "Python/site-packages"; sourceTree = "<group>"; };
155-
C83E5DEA2A38CD000071506D /* python-stdlib */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "python-stdlib"; path = "Python/python-stdlib"; sourceTree = "<group>"; };
156154
C83E5DED2A38CD8C0071506D /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
157155
C8520300293C4D9000460097 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
158156
C8520308293D805800460097 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@@ -263,8 +261,6 @@
263261
C81458922939EFDC00135263 /* EditorExtension */,
264262
C8216B71298036EC00AD38C7 /* Helper */,
265263
C861E60F2994F6070056CB02 /* ExtensionService */,
266-
C83E5DEA2A38CD000071506D /* python-stdlib */,
267-
C83E5DE92A38CD000071506D /* site-packages */,
268264
C814588D2939EFDC00135263 /* Frameworks */,
269265
C8189B172938972F00C9DCDA /* Products */,
270266
);

Copilot for Xcode.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
var greeting = "Hello, playground"
4+
5+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import LangChain
2+
import OpenAIService
3+
import PlaygroundSupport
4+
import SwiftUI
5+
6+
let memory = ConversationChatGPTMemory(systemPrompt: "")
7+
let chatGPTConfiguration = UserPreferenceChatGPTConfiguration().overriding {
8+
$0.temperature = 0.2
9+
}
10+
11+
let embeddingConfiguration = UserPreferenceEmbeddingConfiguration().overriding()
12+
13+
struct FakeVectorStore: VectorStore {
14+
func add(_: [EmbeddedDocument]) async throws {}
15+
func set(_: [EmbeddedDocument]) async throws {}
16+
func clear() async throws {}
17+
func searchWithDistance(embeddings: [Float], count: Int) async throws
18+
-> [(document: Document, distance: Float)]
19+
{
20+
return [
21+
(
22+
document: .init(
23+
pageContent: """
24+
Snoopy is an anthropomorphic beagle[5] in the comic strip Peanuts by Charles M. Schulz. He can also be found in all of the Peanuts films and television specials. Since his debut on October 4, 1950, Snoopy has become one of the most recognizable and iconic characters in the comic strip and is considered more famous than Charlie Brown in some countries. The original drawings of Snoopy were inspired by Spike, one of Schulz's childhood dogs.
25+
""",
26+
metadata: [:]
27+
),
28+
distance: 0.2
29+
),
30+
(
31+
document: .init(
32+
pageContent: """
33+
Snoopy is a loyal, imaginative, and good-natured beagle who is prone to imagining fantasy lives, including being an author, a college student known as "Joe Cool", an attorney, and a World War I flying ace. He is perhaps best known in this last persona, wearing an aviator's helmet and goggles and a scarf while carrying a swagger stick (like a stereotypical British Army officer of World War I and II).
34+
""",
35+
metadata: [:]
36+
),
37+
distance: 0.2
38+
),
39+
(
40+
document: .init(
41+
pageContent: """
42+
Snoopy can be selfish, gluttonous and lazy at times, and occasionally mocks his owner, Charlie Brown. But on the whole, he shows great love, care, and loyalty for his owner (even though he cannot even remember his name and always refers to him as "the round-headed kid"). In the 1990s comic strips, he is obsessed with cookies, particularly the chocolate-chip variety. This, and other instances in which he indulges in large chocolate-based meals and snacks, shows resistance to theobromine unheard of in other dogs.
43+
""",
44+
metadata: [:]
45+
),
46+
distance: 0.2
47+
),
48+
(
49+
document: .init(
50+
pageContent: """
51+
First appearance October 4, 1950 (comic strip)
52+
Last appearance February 13, 2000 (comic strip)
53+
Created by Charles M. Schulz
54+
Voiced by
55+
- Bill Melendez (1959–2008; 2015 archival recordings used in Peanuts Motion Comics, Snoopy's Grand Adventure,[1] and The Peanuts Movie)
56+
- Bill Hinnant (1966; You're a Good Man, Charlie Brown)[2]
57+
- Jim Campbell (1967; You're a Good Man, Charlie Brown)[3]
58+
- Robert Towers (1985)
59+
- Cam Clarke (1986–1989)
60+
- Gerald Paradies (2002)[4]
61+
- Andy Beall (2011)
62+
- Dylan Jones (2018–present)
63+
- Terry McGurrin (2019–present)
64+
Aliases
65+
- Joe Cool
66+
- World Famous World War I Flying Ace
67+
- The World's Greatest Writer
68+
- The World Famous Attorney
69+
- The World Famous Tennis Pro
70+
Species Dog (Beagle)
71+
Gender Male
72+
Family
73+
- Brothers: Spike, Andy, Olaf, Marbles, Rover
74+
- Sisters: Belle, Molly
75+
- Owner: Charlie Brown
76+
- Sally Brown
77+
- Lila (previously)
78+
- Clara ("the annoying girl")
79+
""",
80+
metadata: [:]
81+
),
82+
distance: 0.2
83+
),
84+
]
85+
}
86+
}
87+
88+
let qa = RetrievalQAChain(
89+
vectorStore: FakeVectorStore(),
90+
embedding: OpenAIEmbedding(configuration: embeddingConfiguration),
91+
chatModelFactory: { OpenAIChat(configuration: chatGPTConfiguration, stream: false) }
92+
)
93+
94+
let answer = try await qa.run("Who is the creator of Snoopy?")
95+
96+
PlaygroundPage.current.needsIndefiniteExecution = true
97+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Timeline
3+
version = "3.0">
4+
<TimelineItems>
5+
</TimelineItems>
6+
<TimelineItems>
7+
<LoggerValueHistoryTimelineItem
8+
documentLocation = "documentLocation"
9+
selectedRepresentationIndex = "selectedRepresentationIndex">
10+
</LoggerValueHistoryTimelineItem>
11+
</TimelineItems>
12+
</Timeline>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='6.0' target-platform='macos' buildActiveScheme='true' importAppTypes='true'>
3+
<pages>
4+
<page name='Untitled Page 2'/>
5+
<page name='RetrievalQAChain'/>
6+
</pages>
7+
</playground>

Tool/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let package = Package(
1919
.package(url: "https://github.com/intitni/Tiktoken", branch: "main"),
2020
.package(url: "https://github.com/apple/swift-async-algorithms", from: "0.1.0"),
2121
.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.12.1"),
22-
.package(url: "https://github.com/ChimeHQ/JSONRPC", from: "0.6.0"),
22+
.package(url: "https://github.com/ChimeHQ/JSONRPC", exact: "0.6.0"),
2323
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.6.0"),
2424
.package(url: "https://github.com/unum-cloud/usearch", from: "0.19.1"),
2525
],

0 commit comments

Comments
 (0)