-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump deps, fix browing by swapping to firefox.
- Loading branch information
Showing
6 changed files
with
232 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
(ns ie.simm.processes.build-accounting | ||
(:require [clojure.core.async :as async :refer [timeout]] | ||
[superv.async :refer [go-try go-loop-try <? S]] | ||
[clojure.string :as str] | ||
[ie.simm.runtimes.openai :as openai] | ||
[ie.simm.runtimes.brave :as brave] | ||
[ie.simm.runtimes.etaoin :as etaoin] | ||
[anglican.core :as anglican] | ||
[clojure.java.io :as io] | ||
[hiccup2.core :as h] | ||
[datahike.api :as d] | ||
[morse.polling :as p])) | ||
|
||
(-> "accounting system" | ||
brave/search-brave | ||
brave/extract-url | ||
etaoin/extract-body) | ||
|
||
(etaoin/extract-body "https://en.wikipedia.org/wiki/Accounting") | ||
|
||
|
||
(defn interleave-with-delimiters | ||
([coll] (interleave-with-delimiters coll "=========================================\n")) | ||
([coll delimiter] | ||
(str/join "\n" (interleave coll (repeat delimiter))))) | ||
|
||
|
||
(defn feedback [question] | ||
(println question) | ||
(read-line)) | ||
|
||
(defn expert [type question] | ||
(openai/chat "gpt-4o" (interleave-with-delimiters [(format "You are an %s." type) question]))) | ||
|
||
(defn critic [type question answer] | ||
(Integer/parseInt | ||
(openai/chat "gpt-4o" (interleave-with-delimiters [(format "You are a critic for a %s." type) | ||
"We gave the expert this question:" question | ||
"The expert replied with this answer:" answer | ||
"Rate the expert's answer on a scale from 1 to 10. Only reply with a number."])))) | ||
|
||
|
||
;; a building process loop with a fixed point, it is given an environmental context | ||
;; in every loop we first gather and refine requirements | ||
;; we derive subgoals to currently pursue | ||
;; we define tests and progress metrics | ||
;; then we do an iteration given the system so far | ||
;; and measure the progress | ||
;; we then check if we have reached a fixed point | ||
|
||
subgoals (expert expert-role (str "You have this goal: " goal "\nWith these requirements: " requirements "\nAnd these subgoals derived so far:" subgoals "\nUpdate the subgoals if reasonable and enumerate them as a comma separated list: ")) | ||
tests (expert expert-role (str "You have this goal: " goal "\nWith these requirements: " requirements "\nAnd these subgoals: " subgoals "\nAnd these tests derived so far: " tests "\n Update the tests if reasonable and return them as Clojure code string that can be passed to eval: ")) | ||
progress-metrics (expert expert-role (str "You have this goal: " goal "\nWith these requirements: " requirements "\nAnd these subgoals: " subgoals "\nAnd these tests: " tests "\nAnd these progress metrics derived so far: " progress-metrics "\n Update the progress metrics if reasonable and return them only as a single Clojure code string that can be passed to eval directly: ")) | ||
iteration (expert expert-role (str "You have this goal: " goal "\nWith these requirements: " requirements "\nAnd these subgoals: " subgoals "\nAnd these tests: " tests "\nAnd these progress metrics: " progress-metrics "\nAnd this iteration derived so far: " iteration "\n Update the iteration if reasonable and return it as a single Clojure code string that can be passed to eval: ")) | ||
progress (expert expert-role (str "You have this goal: " goal "\nWith these requirements: " requirements "\nAnd these subgoals: " subgoals "\nAnd these tests: " tests "\nAnd these progress metrics: " progress-metrics "\nAnd this iteration: " iteration "\nAnd this progress derived so far: " progress "\n Update the progress metric if reasonable and return it as Clojure code. The progress metric function needs to return a real number: ")) | ||
|
||
|
||
(defn build [ctx goal] | ||
(let [expert-role (openai/chat "gpt-4o" | ||
(interleave-with-delimiters | ||
["Given this context:" ctx | ||
"What expert would you hire to pursue this goal:" goal | ||
"Answer a descriptive job title."]))] | ||
(loop [requirements "" | ||
subgoals "" | ||
tests "" | ||
progress-metrics "" | ||
iteration "" | ||
progress "" ] | ||
(let [requirements (expert expert-role (interleave-with-delimiters ["You have this goal:" goal | ||
"With these requirements derived so far:" requirements | ||
"What are the requirements?"])) | ||
subgoals (expert expert-role (interleave-with-delimiters ["You have this goal:" goal | ||
"With these requirements:" requirements | ||
"And these subgoals derived so far:" subgoals | ||
"Update the subgoals if reasonable and enumerate them as a comma separated list: "])) | ||
tests (expert expert-role (interleave-with-delimiters ["You have this goal:" goal | ||
"With these requirements:" requirements | ||
"And these subgoals:" subgoals | ||
"And these tests derived so far:" tests | ||
" Update the tests if reasonable and return them as Clojure code string that can be passed to eval: "])) | ||
progress-metrics (expert expert-role (interleave-with-delimiters ["You have this goal:" goal | ||
"With these requirements:" requirements | ||
"And these subgoals:" subgoals | ||
"And these tests:" tests | ||
"And these progress metrics derived so far:" progress-metrics | ||
" Update the progress metrics if reasonable and return them only as a single Clojure code string that can be passed to eval directly: "])) | ||
iteration (expert expert-role (interleave-with-delimiters ["You have this goal:" goal | ||
"With these requirements:" requirements | ||
"And these subgoals:" subgoals | ||
"And these tests:" tests | ||
"And these progress metrics:" progress-metrics | ||
"And this iteration derived so far:" iteration | ||
" Update the iteration if reasonable and return it as a single Clojure code string that can be passed to eval: "])) | ||
progress (expert expert-role (interleave-with-delimiters ["You have this goal:" goal | ||
"With these requirements:" requirements | ||
"And these subgoals:" subgoals | ||
"And these tests:" tests | ||
"And these progress metrics:" progress-metrics | ||
"And this iteration:" iteration | ||
"And this progress derived so far:" progress | ||
" Update the progress metric if reasonable and return it as Clojure code. The progress metric function needs to return a real number: "]))] | ||
(println "Requirements: " requirements) | ||
(println "Subgoals: " subgoals) | ||
(println "Tests: " tests) | ||
(println "Progress Metrics: " progress-metrics) | ||
(println "Iteration: " iteration) | ||
(println "Progress: " progress) | ||
[expert-role requirements subgoals tests progress-metrics iteration progress])))) | ||
|
||
|
||
(comment | ||
|
||
(def build-result (build "exploring games" "Build a Snake game in Clojure without any external libraries. You have clojure.core, core.async and Datahike available.")) | ||
|
||
(let [[expert-role requirements subgoals tests progress-metrics iteration progress] build-result] | ||
(println iteration)) | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
(ns ie.simm.processes.thesis | ||
(:require [clojure.core.async :as async :refer [timeout]] | ||
[superv.async :refer [go-try go-loop-try <? S]] | ||
[ie.simm.runtimes.openai :as openai])) | ||
|
||
(require '[ie.simm.runtimes.openai :as openai]) | ||
|
||
(require '[datahike.api :as d]) | ||
|
||
(openai/chat "gpt-4o" "Hello, I am a chatbot. I am here to help you with your thesis. What do you need help with?") | ||
|
||
;; define process and used languages | ||
(comment | ||
(defprocess conversation [chat gen-ai core-async] | ||
(go-try S | ||
|
||
)) | ||
|
||
|
||
) | ||
|
||
;; objective: have a complete process description that can be simulated | ||
|
||
(defn purchase [system & args] | ||
(println "Purchasing" system args) | ||
(last args)) | ||
|
||
(defn sale [system & args] | ||
(println "Selling" system args)) | ||
|
||
(def minutes (* 60 1000)) | ||
|
||
(defn write [] | ||
(let [topics ["structure inversion" "structure learning" "structure prediction" "structure analysis"] | ||
topic (rand-nth topics) | ||
writing-time (purchase "ch_weil@topiq.es" ::writing-time ::minutes 25) | ||
topic (purchase "Thesis" ::writing-issue ::issue topic)] | ||
(go-try S | ||
(when topic | ||
(println "Working on topic" topic) | ||
(<? S (timeout (* writing-time minutes))))))) | ||
|
||
(defn pause [] | ||
(let [recovery-time (purchase "ch_weil@topiq.es" ::recovery-time ::minutes 5)] | ||
(timeout (* recovery-time minutes)))) | ||
|
||
|
||
(defn yesno [question] | ||
(println question) | ||
(go-loop-try S [answer (read-line)] | ||
(if-not ({"yes" "no"} answer) | ||
(do | ||
(println "Please answer yes or no") | ||
(recur (read-line))) | ||
(if (= "yes" answer) true false)))) | ||
|
||
(defn read-integer [question] | ||
(println question) | ||
(go-loop-try S [answer (read-line)] | ||
(if-not (try (Integer/parseInt answer) (catch Exception e nil)) | ||
(do | ||
(println "Please enter an integer") | ||
(recur (read-line))) | ||
answer))) | ||
|
||
(comment | ||
(read-integer "How many pages did you write today?") | ||
|
||
) | ||
|
||
(defn workday [] | ||
(go-try S | ||
(purchase "ch_weil@topiq.es" ::simmie-fee ::usd 0.01) | ||
(purchase "Household Toronto Rd." ::coffee ::usd 0.5) | ||
(<? S (go-loop-try S [] | ||
(<? S (write)) | ||
(<? S (pause)) | ||
(when (<? S (yesno "Do you want to continue writing?")) | ||
(recur)))) | ||
(sale "PhD program" ::pages ::written (read-integer "How many pages did you write today?")))) | ||
|
||
(comment | ||
|
||
(read-line) | ||
|
||
(workday) | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters