Claude.ai
A clean & intuitive,
Anthropic Claude API wrapper for Arturo
What does this package do?
This package provides a clean wrapper around Anthropic's Claude API, allowing you to easily integrate Claude's capabilities into your Arturo applications. It handles all the API communication, message formatting, and response parsing, providing both low-level access to the full API and convenient high-level methods for common use cases.
How do I use it?
First, make sure you have an API key from Anthropic. Then simply import
the package and initialize a client:
import "claude"!
; Initialize with your API key
claude: to :claudeAPI @["sk-your-api-key"]!
; Ask a simple question
answer: claude\ask "What is the capital of France?"
print answer
; Have a more complex conversation
response: claude\chat [
createMessage "user" "What's quantum computing?"
createMessage "assistant" "Quantum computing uses quantum mechanics..."
createMessage "user" "Can you explain qubits?"
]
; Use custom parameters
response: claude\chat
.temperature: 0.9
.maxTokens: 2000
.system: "You are a creative writing expert"
[
createMessage "user" "Write a creative story"
]
API Reference
claudeAPI
Description
The main client class for interacting with Claude's API.
Methods
chat
Send messages to Claude and get responses.
chat messages :block
Attributes
Option | Type | Description |
---|---|---|
model | :string | Specify Claude model to use (default: claude-3-sonnet) |
system | :string | Specify system message |
temperature | :floating | Set temperature (0.0-1.0) |
maxTokens | :integer | Set max tokens for response |
topP | :floating | Set top_p value (0.0-1.0) |
topK | :integer | Set top_k value |
Returns
- :dictionary - The complete API response
ask
Simplified method for single-turn questions.
ask question :string
Returns
- :string - Claude's response text
Configuration Methods
setModel [model :string]
- Set default modelsetMaxTokens [tokens :integer]
- Set default max tokenssetTemperature [temp :floating]
- Set default temperaturesetTopP [topP :floating]
- Set default top_p
Type Reference
message
Description
Represents a single message in a conversation.
Usage
msg: createMessage "user" "Hello, Claude!"
or
msg: to :message ["user" "This is my message"]
Fields
role
- Either "user" or "assistant"content
- The message content
License
MIT License
Copyright (c) 2024 Yanis Zafirópulos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
0.0.1 | 6 November 2024 | 10532 / 5 files |
No dependencies.