Skip to content

Commit

Permalink
Added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wkok committed Jan 14, 2024
1 parent 95f8d76 commit f391cfc
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions doc/04-debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Debugging

When supplying a `trace` function in `:options` it will be called with the raw maps of the request and response for allowing capturing tracing information like the raw messages sent/received:

```clojure
(create-chat-completion {:model "gpt-3.5-turbo"
:messages [{:role "system" :content "You are a helpful assistant."}
{:role "user" :content "Who won the world series in 2020?"}
{:role "assistant" :content "The Los Angeles Dodgers won the World Series in 2020."}
{:role "user" :content "Where was it played?"}]}
{:trace (fn [request response]
(println (:body response)))})
```

Prints:

```json
{
"id": "chatcmpl-8gHB7Il500UxZPChGAZHtklLWTS8T",
"object": "chat.completion",
"created": 1705086501,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The 2020 World Series was played at Globe Life Field in Arlington, Texas."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 53,
"completion_tokens": 17,
"total_tokens": 70
},
"system_fingerprint": null
}

```

0 comments on commit f391cfc

Please sign in to comment.