forked from copilot-community-sdk/copilot-sdk-clojure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_integration.clj
More file actions
43 lines (38 loc) · 2.47 KB
/
tool_integration.clj
File metadata and controls
43 lines (38 loc) · 2.47 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
(ns tool-integration
(:require [github.copilot-sdk :as copilot]
[github.copilot-sdk.helpers :as h]))
;; See examples/README.md for usage
;; Define a knowledge base for our tool
(def ^:private knowledge-base
{"clojure" "Clojure is a dynamic, functional programming language that runs on the JVM. Created by Rich Hickey in 2007. It emphasizes immutability and functional programming."
"rust" "Rust is a systems programming language focused on safety, speed, and concurrency. Created by Mozilla. Known for its ownership model and zero-cost abstractions."
"python" "Python is a high-level, interpreted programming language known for its readability. Created by Guido van Rossum in 1991. Popular for data science and web development."
"javascript" "JavaScript is a dynamic scripting language primarily used for web development. Created by Brendan Eich in 1995. The language of the web browser."
"haskell" "Haskell is a purely functional programming language. Named after Haskell Curry. Known for its strong static typing and lazy evaluation."})
;; Define a lookup tool
(def lookup-tool
(copilot/define-tool "lookup_language"
{:description "Look up information about a programming language from our knowledge base. Available languages: clojure, rust, python, javascript, haskell."
:parameters {:type "object"
:properties {:language {:type "string"
:description "The programming language to look up (e.g., 'clojure', 'rust', 'python')"}}
:required ["language"]}
:handler (fn [args _invocation]
(let [lang (-> args :language str clojure.string/lower-case)
info (get knowledge-base lang)]
(if info
(copilot/result-success info)
(copilot/result-failure
(str "No information found for language: " lang ". Available: clojure, rust, python, javascript, haskell")
"language not in knowledge base"))))}))
(def defaults
{:languages ["clojure" "python" "rust"]})
(defn run
[{:keys [languages] :or {languages (:languages defaults)}}]
(copilot/with-client-session [session {:model "gpt-5.2"
:tools [lookup-tool]}]
(doseq [lang languages]
(println (str "Looking up: " lang))
(println (h/query (str "What is " lang "? Use the lookup_language tool to find out.")
:session session))
(println))))