brainlid / langchain

Elixir implementation of an AI focused LangChain style framework.
https://hexdocs.pm/langchain/
Other
571 stars 68 forks source link

Explore/add Anthropic API support (Claude AI) #83

Closed brainlid closed 6 months ago

brainlid commented 6 months ago
brainlid commented 6 months ago

Basic Anthropic support added. They don't have an official API for tools, so functions are not implemented at this point.

youfun commented 5 months ago

anthropic releases the tools ,is that what you say “an official API for tools”:

see the doc: https://docs.anthropic.com/claude/docs/tool-use

Tool use (function calling) Claude is capable of interacting with external client-side tools and functions, allowing you to equip Claude with your own custom tools to perform a wider variety of tasks.

🎉 Tool use public beta

We're excited to announce that tool use is now in public beta! To access this feature, you'll need to include the anthropic-beta: tools-2024-04-04 header in your API requests.

We'll be iterating on this open beta over the coming weeks, so we appreciate all your feedback. Please share your ideas and suggestions using this form.

Here's an example of how to provide tools to Claude using the Messages API:

Shell Python

curl https://api.anthropic.com/v1/messages \ -H "content-type: application/json" \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "anthropic-beta: tools-2024-04-04" \ -d '{ "model": "claude-3-opus-20240229", "max_tokens": 1024, "tools": [ { "name": "get_weather", "description": "Get the current weather in a given location", "input_schema": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" } }, "required": ["location"] } } ], "messages": [ { "role": "user", "content": "What is the weather like in San Francisco?" } ] }' Please note that during the beta period:

Streaming (stream=true) is not yet supported. We plan to add streaming support in a future beta version. While the feature is production-ready, we may introduce multiple beta versions before the final release. Tool use is not yet available on third-party platforms like Vertex AI or AWS Bedrock, but is coming soon.

brainlid commented 5 months ago

Correct. See issue #94