Skip to content
/ aimee Public

Clojure core.async-first client/runtime for AI model + agent protocols (streaming, structured responses, helpers)

License

Notifications You must be signed in to change notification settings

jhancock/aimee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aimee

Core.async-first streaming client for OpenAI-compatible chat completions.

Install

{jhancock/aimee {:mvn/version "0.1.0-SNAPSHOT"}}

Quick Start

(require '[aimee.chat.client :as chat]
         '[clojure.core.async :as async])

(def ch (async/chan 64))
(def result (chat/start-request!
             {:url "https://api.openai.com/v1/chat/completions"
              :api-key "sk-..."
              :channel ch
              :model "gpt-4o-mini"
              :stream? true
              :messages [{:role "user" :content "Hello!"}]}))

(async/go-loop []
  (when-let [event (async/<! ch)]
    (case (:event event)
      :chunk (println "Chunk" (get-in event [:data :parsed :content]))
      :complete (println "Done" (:data event))
      :error (println "Error" (:data event)))
    (recur))

((:stop! result))

Docs

Build

clojure -T:build jar

Publish

clojure -T:build deploy

Validation

REPL-first via (comment ...) blocks in src/aimee/example/.

Example Chat Server

Bare-bones HTTP example app that serves a one-page Deep Chat client at /chat and streams responses through aimee.chat.client.

Requirements

  • OPENAI_API_KEY must be set
  • OPENAI_API_URL is optional (defaults to https://api.openai.com/v1/chat/completions)
  • Model default is gpt-4o-mini

Run

clojure -M:chat-server

Then open:

http://localhost:8080/chat

Optional custom port:

clojure -M:chat-server -- 8090

Simple SSE Test Endpoint (No Deep Chat Client)

Use POST /chat/simple to test streaming with a simple input string.

Send plain text:

curl -N -X POST http://localhost:8080/chat/simple \
  -H "content-type: text/plain" \
  --data "Say hello in five words."

Or send JSON:

curl -N -X POST http://localhost:8080/chat/simple \
  -H "content-type: application/json" \
  --data '{"input":"Say hello in five words."}'

The endpoint streams SSE frames and ends with data: [DONE].

Verify Streaming In Browser

Open:

http://localhost:8080/chat

Send a prompt and watch the assistant response stream in.

Implementation lives in src/aimee/example/chat_server.clj.

About

Clojure core.async-first client/runtime for AI model + agent protocols (streaming, structured responses, helpers)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published