forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgentTool.swift
More file actions
32 lines (27 loc) · 804 Bytes
/
AgentTool.swift
File metadata and controls
32 lines (27 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import Foundation
public protocol AgentTool {
var name: String { get }
var description: String { get }
var returnDirectly: Bool { get }
func run(input: String) async throws -> String
}
public struct SimpleAgentTool: AgentTool {
public let name: String
public let description: String
public let returnDirectly: Bool
public let run: (String) async throws -> String
public init(
name: String,
description: String,
returnDirectly: Bool = false,
run: @escaping (String) async throws -> String
) {
self.name = name
self.description = description
self.returnDirectly = returnDirectly
self.run = run
}
public func run(input: String) async throws -> String {
try await run(input)
}
}