Skip to content

Commit 4ee17f0

Browse files
authored
Merge pull request #21 from emilrueh/dev
Update documentation with async features
2 parents f8aa102 + ade54c9 commit 4ee17f0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ A developer-friendly Lua interface for working with various generative AI provid
1515
- Structured JSON response abstraction layer
1616
- Token usage tracking with cost calculation
1717
- Open-source models via OpenAI compatibility
18+
- Async non-blocking requests via copas
1819

1920
### Providers
2021

@@ -44,6 +45,8 @@ luarocks install lua-genai
4445

4546
- [luasec](https://github.com/brunoos/luasec)
4647

48+
- [copas](https://github.com/lunarmodules/copas)
49+
4750
## Usage
4851

4952
```lua
@@ -75,6 +78,20 @@ chat:say("Tell me a very short story.")
7578
print()
7679
```
7780

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+
7895
### JSON Response
7996

8097
```lua

rockspecs/lua-genai-0.3-1.rockspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ description = {
1212
dependencies = {
1313
"lua >= 5.1",
1414
"lua-cjson",
15-
"luasec"
15+
"luasec",
16+
"copas",
1617
}
1718
build = {
1819
type = "builtin",

0 commit comments

Comments
 (0)