Skip to content
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

update api to "tools" concept #105

Merged
merged 51 commits into from
Apr 27, 2024
Merged

update api to "tools" concept #105

merged 51 commits into from
Apr 27, 2024

Conversation

brainlid
Copy link
Owner

All tests are passing, but I expect there to be some issues.

This is a breaking change for the message structures. It now supports LLMs that take multi-modal inputs. Meaning we can mix text and images together in a prompt and use the LLM to analyze the images.

Adds:

  • LangChain.Message.ContentPart - used for User messages and multi-modal support. Google's AI assistant can return multiple parts as well.
  • LangChain.Message.ToolCall - an assistant can request multiple tool calls in the same message.
  • LangChain.Message.ToolResult - the system's answer to a ToolCall. It adds an is_error boolean flag. This an be helpful in the UI, but Anthropic specifically wants it.

Changes:

  • The roles of :function and :function_call are removed. The equivalent of a function_call is expressed by an :assistant role making one or more ToolCall requests. The :function was the system's answer to a function call. This is now in the :tool role.
  • Role :tool was added. A tool message contains one or more ToolResult messages.

Changes:

  • 2024-04-26 updated data extraction for for changes
  • 2024-04-26 fix minor change
  • 2024-04-26 updated ChatGoogleAI for new message structures
  • 2024-04-26 renamed UserContentPart to ContentPart
    • applies to how Google uses content
  • 2024-04-26 refactored ChatGoogleAI tests to use pattern matching more
  • 2024-04-26 add ToolResult support for Anthropic
    • test fixes and cleanup
  • 2024-04-20 implemented combined tool result message
  • 2024-04-19 tool call fixes
  • 2024-04-17 added markdown file MODEL_BEHAVIORS
    • track behavior differences between LLMs
  • 2024-04-17 fixed OpenAI assistant message
    • restoring a conversation should not include empty tool_calls for an assistant
  • 2024-04-17 fixed anthropic system message support
  • 2024-04-17 updates to message deltas for tool usage
  • 2024-04-17 function param raises error
    • helps identify incorrect developer usage much quicker
  • 2024-04-17 updated function example in doc

* main:
  test tag updates - add more specific tags for enabling/disabling certain live tests
  fixes for example and CI
  refactor streamed response handling for anthropic - buffers incomplete streamed data - more tests - refactored decode logic - refactored Utils.handle_stream_fn to have discrete function steps - REMAINING: Refactor ChatGPT decoding to follow the Anthropic approach
  cleanup
  Changes from feedback
  Minor tweaks
  Add support for Anthropic
- added MessagePart
- updated message docs
- implemented ChatGPT support for "gpt-4-vision-preview" model passing image data for user messages
- refactored Anthropic to use for_api/1 functions for LangChain structs
- added "options" to MessagePart. Anthropic requires media type to be sent with image parts.
- Anthropic raises exception on multiple system messages
* main:
  remove message wrap to list for Anthropic
  update Utils.fire_callback - allow for a single message. Don't assume a list. - added live full-stack tests to anthropic
  Revert "mix format"
  mix format
  wrap message
  support sending the auth api key differently - sends it both ways - Azure OpenAI requires an "api-key" header - Standard OpenAI requires auth bearer header
- before refactor for new design
- working on tool_calls message changes
- adding "name" to message for assistant and user. New OpenAI feature.
- message structure fixes
- test updates
- OpenAI API support improved
- ToolCall "complete" function
- removed early tool_call support from UserContentPart

Working on OpenAI support
- rescues errors
- wraps return values in :ok/:error tuples
- Function.new validates that an Elixir function is assigned and validates it is  arity 2
- execute async functions together
- execute sync-only functions
- return tool_call hallucination errors
- updated tests and added new tests
- updated anthropic for parsing to ToolCall structs
- still need more tests
- function support tested
- function parameters
- multiple tool_result messages get collapsed into a single user too_result message
- much expanded test coverage
- helps identify incorrect developer usage much quicker
- restoring a conversation should not include empty tool_calls for an assistant
- track behavior differences between LLMs
- test fixes and cleanup
* main:
  refactored ChatGoogleAI tests to use pattern matching more
  Add llama-3 chat template
* me-update-api-to-tools:
  refactored ChatGoogleAI tests to use pattern matching more
  Add llama-3 chat template
- applies to how Google uses content
@brainlid brainlid merged commit 96aa9f7 into main Apr 27, 2024
1 check passed
@brainlid brainlid deleted the me-update-api-to-tools branch April 27, 2024 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant