Skip to content

Commit 9c0bbbc

Browse files
authored
Merge pull request #8 from DePasqualeOrg/add-functionality
Support vision models and function calling
2 parents 10cf426 + 30edf9f commit 9c0bbbc

24 files changed

+6594
-838
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,8 @@ iOSInjectionProject/
9494
/Packages
9595
.netrc
9696
.idea
97-
.swiftpm
97+
.swiftpm
98+
99+
# Specific to this package
100+
101+
*.code-workspace

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/slessans/pre-commit-swift-format
3-
rev: ""
3+
rev: "fd627de92bdf84a75c924ed95691336d14e94cf1"
44
hooks:
55
- id: swift-format
66
args: ["--configuration", ".swift-format"]

.swift-format

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
"respectsExistingLineBreaks": true,
99
"lineBreakBeforeEachArgument": true,
1010
"multiElementCollectionTrailingCommas": true,
11-
"spacesAroundRangeFormationOperators": true
11+
"spacesAroundRangeFormationOperators": true,
12+
"rules": {
13+
"AlwaysUseLowerCamelCase": false
14+
}
1215
}

Package.resolved

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"pins" : [
3+
{
4+
"identity" : "swift-collections",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/apple/swift-collections.git",
7+
"state" : {
8+
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
9+
"version" : "1.1.4"
10+
}
11+
}
12+
],
13+
"version" : 2
14+
}

Package.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,25 @@ let package = Package(
1313
targets: ["Jinja"]
1414
)
1515
],
16+
dependencies: [
17+
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4")
18+
],
1619
targets: [
1720
// Targets are the basic building blocks of a package, defining a module or a test suite.
1821
// Targets can depend on other targets in this package and products from dependencies.
1922
.target(
2023
name: "Jinja",
24+
dependencies: [
25+
.product(name: "OrderedCollections", package: "swift-collections")
26+
],
2127
path: "Sources",
2228
swiftSettings: [.enableUpcomingFeature("BareSlashRegexLiterals")]
2329
),
2430
.testTarget(
2531
name: "JinjaTests",
26-
dependencies: ["Jinja"],
32+
dependencies: [
33+
"Jinja"
34+
],
2735
path: "Tests",
2836
swiftSettings: [.enableUpcomingFeature("BareSlashRegexLiterals")]
2937
),

Sources/Ast.swift

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Foundation
9+
import OrderedCollections
910

1011
protocol Statement {}
1112

@@ -41,15 +42,15 @@ struct TupleLiteral: Literal {
4142
}
4243

4344
struct ObjectLiteral: Literal {
44-
var value: [(Expression, Expression)]
45+
var value: OrderedDictionary<String, Expression>
4546
}
4647

4748
struct Set: Statement {
4849
var assignee: Expression
4950
var value: Expression
5051
}
5152

52-
struct If: Statement {
53+
struct If: Statement, Expression {
5354
var test: Expression
5455
var body: [Statement]
5556
var alternate: [Statement]
@@ -59,14 +60,14 @@ struct Identifier: Expression {
5960
var value: String
6061
}
6162

62-
protocol Loopvar {}
63-
extension Identifier: Loopvar {}
64-
extension TupleLiteral: Loopvar {}
63+
typealias Loopvar = Expression
6564

6665
struct For: Statement {
6766
var loopvar: Loopvar
6867
var iterable: Expression
6968
var body: [Statement]
69+
var defaultBlock: [Statement]
70+
var test: Expression?
7071
}
7172

7273
struct MemberExpression: Expression {
@@ -92,7 +93,11 @@ extension CallExpression: Filter {}
9293

9394
struct FilterExpression: Expression {
9495
var operand: Expression
95-
var filter: Filter
96+
var filter: Identifier
97+
var args: [Expression]
98+
var kwargs: [KeywordArgumentExpression]
99+
var dyn_args: Expression?
100+
var dyn_kwargs: Expression?
96101
}
97102

98103
struct TestExpression: Expression {
@@ -124,3 +129,23 @@ struct KeywordArgumentExpression: Expression {
124129
struct NullLiteral: Literal {
125130
var value: Any? = nil
126131
}
132+
133+
struct SelectExpression: Expression {
134+
var iterable: Expression
135+
var test: Expression
136+
}
137+
138+
struct Macro: Statement {
139+
var name: Identifier
140+
var args: [Expression]
141+
var body: [Statement]
142+
}
143+
144+
struct KeywordArgumentsValue: RuntimeValue {
145+
var value: [String: any RuntimeValue]
146+
var builtins: [String: any RuntimeValue] = [:]
147+
148+
func bool() -> Bool {
149+
!value.isEmpty
150+
}
151+
}

0 commit comments

Comments
 (0)