File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ A developer-friendly Lua interface for working with various generative AI provid
15
15
- Structured JSON response abstraction layer
16
16
- Token usage tracking with cost calculation
17
17
- Open-source models via OpenAI compatibility
18
+ - Async non-blocking requests via copas
18
19
19
20
### Providers
20
21
@@ -44,6 +45,8 @@ luarocks install lua-genai
44
45
45
46
- [ luasec] ( https://github.com/brunoos/luasec )
46
47
48
+ - [ copas] ( https://github.com/lunarmodules/copas )
49
+
47
50
## Usage
48
51
49
52
``` lua
@@ -75,6 +78,20 @@ chat:say("Tell me a very short story.")
75
78
print ()
76
79
```
77
80
81
+ ### Async
82
+
83
+ ``` lua
84
+ local copas = require (" copas" )
85
+
86
+ local chat = client :chat (" gpt-4o-mini" , { settings = { async = true } })
87
+
88
+ copas .addthread (function ()
89
+ print (chat :say (" test" ))
90
+ end )
91
+
92
+ copas .loop ()
93
+ ```
94
+
78
95
### JSON Response
79
96
80
97
``` lua
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ description = {
12
12
dependencies = {
13
13
" lua >= 5.1" ,
14
14
" lua-cjson" ,
15
- " luasec"
15
+ " luasec" ,
16
+ " copas" ,
16
17
}
17
18
build = {
18
19
type = " builtin" ,
You can’t perform that action at this time.
0 commit comments