Skip to content

Fix luacheck warnings and small README addition #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ Constructor for the OpenAI client.
local openai = require("openai")
local api_key = "your-api-key"
local client = openai.new(api_key)

--optionally provide an alternate API URL
client.api_base = "http://my_llama_cpp.local/v1"
```

##### `client:new_chat_session(...)`
Expand Down
4 changes: 2 additions & 2 deletions examples/example2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ print(chat:send("List your top 5 favorite colors"))
print(chat:send("Excluding the colors you just listed, tell me your favorite color"))

-- the entire chat history is stored in the messages field
for idx, message in ipairs(chat.messages) do
for _, message in ipairs(chat.messages) do
print(message.role, message.content)
end

-- You can stream the output by providing a callback as the second argument
-- the full response concatenated is also returned by the function
local response = chat:send("What's the most boring color?", function(chunk)
local _ = chat:send("What's the most boring color?", function(chunk)
io.stdout:write(chunk.content)
io.stdout:flush()
end)
3 changes: 2 additions & 1 deletion examples/example5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ local chat = client:new_chat_session({
messages = {
{
role = "system",
content = "You are a calculator with access to specified set of functions. All computation should be done with the functions"
content =
"You are a calculator with access to specified set of functions. All computation should be done with the functions"
}
},
functions = {
Expand Down
2 changes: 1 addition & 1 deletion openai/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ do
new_chat_session = function(self, ...)
return ChatSession(self, ...)
end,
create_stream_filter = function(self, chunk_callback)
create_stream_filter = function(_, chunk_callback)
assert(types["function"](chunk_callback), "Must provide chunk_callback function when streaming response")
local accumulation_buffer = ""
return function(...)
Expand Down