Skip to content

Commit

Permalink
Support vision models and tool use
Browse files Browse the repository at this point in the history
  • Loading branch information
DePasqualeOrg committed Jan 7, 2025
1 parent 9f5bb2c commit 890b975
Show file tree
Hide file tree
Showing 21 changed files with 6,919 additions and 832 deletions.
14 changes: 14 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
"version" : "1.1.4"
}
}
],
"version" : 2
}
10 changes: 9 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@ let package = Package(
targets: ["Jinja"]
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "Jinja",
dependencies: [
.product(name: "OrderedCollections", package: "swift-collections")
],
path: "Sources",
swiftSettings: [.enableUpcomingFeature("BareSlashRegexLiterals")]
),
.testTarget(
name: "JinjaTests",
dependencies: ["Jinja"],
dependencies: [
"Jinja"
],
path: "Tests",
swiftSettings: [.enableUpcomingFeature("BareSlashRegexLiterals")]
),
Expand Down
37 changes: 31 additions & 6 deletions Sources/Ast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import OrderedCollections

protocol Statement {}

Expand Down Expand Up @@ -41,15 +42,15 @@ struct TupleLiteral: Literal {
}

struct ObjectLiteral: Literal {
var value: [(Expression, Expression)]
var value: OrderedDictionary<String, Expression>
}

struct Set: Statement {
var assignee: Expression
var value: Expression
}

struct If: Statement {
struct If: Statement, Expression {
var test: Expression
var body: [Statement]
var alternate: [Statement]
Expand All @@ -59,14 +60,14 @@ struct Identifier: Expression {
var value: String
}

protocol Loopvar {}
extension Identifier: Loopvar {}
extension TupleLiteral: Loopvar {}
typealias Loopvar = Expression

struct For: Statement {
var loopvar: Loopvar
var iterable: Expression
var body: [Statement]
var defaultBlock: [Statement]
var ifCondition: Expression?
}

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

struct FilterExpression: Expression {
var operand: Expression
var filter: Filter
var filter: Identifier
var args: [Expression]
var kwargs: [KeywordArgumentExpression]
var dyn_args: Expression?
var dyn_kwargs: Expression?
}

struct TestExpression: Expression {
Expand Down Expand Up @@ -124,3 +129,23 @@ struct KeywordArgumentExpression: Expression {
struct NullLiteral: Literal {
var value: Any? = nil
}

struct SelectExpression: Expression {
var iterable: Expression
var test: Expression
}

struct Macro: Statement {
var name: Identifier
var args: [Expression]
var body: [Statement]
}

struct KeywordArgumentsValue: RuntimeValue {
var value: [String: any RuntimeValue]
var builtins: [String: any RuntimeValue] = [:]

func bool() -> Bool {
!value.isEmpty
}
}
Loading

0 comments on commit 890b975

Please sign in to comment.