patterns-ai-core / langchainrb

Build LLM-powered applications in Ruby
https://rubydoc.info/gems/langchainrb
MIT License
1.18k stars 156 forks source link

OpenAI response with tools #645

Closed agomezcampero closed 4 weeks ago

agomezcampero commented 1 month ago

Currently if you call llm.chat with tools and streaming the tool_calls don't show up in the raw_response. I'm adding the tool_calls to the response_from_chunks so the final response when using streaming is almost the same as when not using streaming.

With this solution

response = llm.chat(messages:, tools:) { |chunk| do_something(chunk) }
response.tool_calls # will return the tool_calls and not an empty array

image