Skip to content

Commit

Permalink
Claude 1 Deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
WillMatthews authored Nov 6, 2024
2 parents c538633 + 86f77b8 commit c96c8c6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
func main() {
client := anthropic.NewClient("your anthropic api key")
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand Down Expand Up @@ -75,7 +75,7 @@ func main() {
client := anthropic.NewClient("your anthropic api key")
resp, err := client.CreateMessagesStream(context.Background(), anthropic.MessagesStreamRequest{
MessagesRequest: anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand Down
1 change: 0 additions & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package anthropic
type Model string

const (
ModelClaudeInstant1Dot2 Model = "claude-instant-1.2"
ModelClaude2Dot0 Model = "claude-2.0"
ModelClaude2Dot1 Model = "claude-2.1"
ModelClaude3Opus20240229 Model = "claude-3-opus-20240229"
Expand Down
8 changes: 4 additions & 4 deletions complete_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestCompleteStream(t *testing.T) {
var receivedContent string
resp, err := client.CreateCompleteStream(context.Background(), anthropic.CompleteStreamRequest{
CompleteRequest: anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
},
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestCompleteStreamError(t *testing.T) {
var receivedContent string
param := anthropic.CompleteStreamRequest{
CompleteRequest: anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
//Temperature: &temperature,
Expand Down Expand Up @@ -135,7 +135,7 @@ func handlerCompleteStream(w http.ResponseWriter, r *http.Request) {
dataBytes,
[]byte(
fmt.Sprintf(
`data: {"type":"completion","id":"compl_01GatBXF5t5K51mYzbVgRJfZ","completion":"%s","stop_reason":null,"model":"claude-instant-1.2","stop":null,"log_id":"compl_01GatBXF5t5K51mYzbVgRJfZ"}`,
`data: {"type":"completion","id":"compl_01GatBXF5t5K51mYzbVgRJfZ","completion":"%s","stop_reason":null,"model":"claude-3-haiku-20240307","stop":null,"log_id":"compl_01GatBXF5t5K51mYzbVgRJfZ"}`,
t,
)+"\n\n",
)...)
Expand All @@ -145,7 +145,7 @@ func handlerCompleteStream(w http.ResponseWriter, r *http.Request) {
dataBytes = append(
dataBytes,
[]byte(
`data: {"type":"completion","id":"compl_01GatBXF5t5K51mYzbVgRJfZ","completion":"","stop_reason":"stop_sequence","model":"claude-instant-1.2","stop":null,"log_id":"compl_01GatBXF5t5K51mYzbVgRJfZ"}`+"\n\n",
`data: {"type":"completion","id":"compl_01GatBXF5t5K51mYzbVgRJfZ","completion":"","stop_reason":"stop_sequence","model":"claude-3-haiku-20240307","stop":null,"log_id":"compl_01GatBXF5t5K51mYzbVgRJfZ"}`+"\n\n",
)...)

_, _ = w.Write(dataBytes)
Expand Down
10 changes: 5 additions & 5 deletions complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestComplete(t *testing.T) {
t.Run("create complete success", func(t *testing.T) {
client := anthropic.NewClient(test.GetTestToken(), anthropic.WithBaseURL(baseUrl))
resp, err := client.CreateComplete(context.Background(), anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
})
Expand All @@ -39,7 +39,7 @@ func TestComplete(t *testing.T) {
t.Run("create complete failure", func(t *testing.T) {
client := anthropic.NewClient("invalid token", anthropic.WithBaseURL(baseUrl))
_, err := client.CreateComplete(context.Background(), anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
})
Expand All @@ -51,7 +51,7 @@ func TestComplete(t *testing.T) {

func TestSetTemperature(t *testing.T) {
cr := anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
}
Expand All @@ -66,7 +66,7 @@ func TestSetTemperature(t *testing.T) {

func TestSetTopP(t *testing.T) {
cr := anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
}
Expand All @@ -81,7 +81,7 @@ func TestSetTopP(t *testing.T) {

func TestSetTopK(t *testing.T) {
cr := anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 1000,
}
Expand Down
2 changes: 1 addition & 1 deletion integrationtest/complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestIntegrationComplete(t *testing.T) {
ctx := context.Background()

request := anthropic.CompleteRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude2Dot1,
Prompt: "\n\nHuman: What is your name?\n\nAssistant:",
MaxTokensToSample: 10,
}
Expand Down
10 changes: 5 additions & 5 deletions message_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMessagesStream(t *testing.T) {
var received string
resp, err := client.CreateMessagesStream(context.Background(), anthropic.MessagesStreamRequest{
MessagesRequest: anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestMessagesStreamError(t *testing.T) {
)
param := anthropic.MessagesStreamRequest{
MessagesRequest: anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestCreateMessagesStream(t *testing.T) {
)
_, err := client.CreateMessagesStream(context.Background(), anthropic.MessagesStreamRequest{
MessagesRequest: anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{},
MaxTokens: 1000,
},
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestCreateMessagesStream(t *testing.T) {
)
_, err := client.CreateMessagesStream(context.Background(), anthropic.MessagesStreamRequest{
MessagesRequest: anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What's the weather like?"),
},
Expand Down Expand Up @@ -320,7 +320,7 @@ func handlerMessagesStream(w http.ResponseWriter, r *http.Request) {
dataBytes = append(
dataBytes,
[]byte(
`data: {"type":"message_start","message":{"id":"1","type":"message","role":"assistant","content":[],"model":"claude-instant-1.2","stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":14,"output_tokens":1}}}`+"\n\n",
`data: {"type":"message_start","message":{"id":"1","type":"message","role":"assistant","content":[],"model":"claude-3-haiku-20240307","stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":14,"output_tokens":1}}}`+"\n\n",
)...)

dataBytes = append(dataBytes, []byte("event: content_block_start\n")...)
Expand Down
14 changes: 7 additions & 7 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestMessages(t *testing.T) {

t.Run("create messages success", func(t *testing.T) {
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand All @@ -65,7 +65,7 @@ func TestMessages(t *testing.T) {

t.Run("create messages success with single system message", func(t *testing.T) {
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand All @@ -81,7 +81,7 @@ func TestMessages(t *testing.T) {

t.Run("create messages success with single multi-system message", func(t *testing.T) {
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand All @@ -97,7 +97,7 @@ func TestMessages(t *testing.T) {

t.Run("create messages success with multi-system messages", func(t *testing.T) {
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand Down Expand Up @@ -281,7 +281,7 @@ func TestMessagesTokenError(t *testing.T) {
anthropic.WithBaseURL(baseUrl),
)
_, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
anthropic.NewUserTextMessage("What is your name?"),
},
Expand Down Expand Up @@ -562,7 +562,7 @@ func TestMessagesWithCaching(t *testing.T) {

t.Run("caches single message", func(t *testing.T) {
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
Messages: []anthropic.Message{
{
Role: anthropic.RoleUser,
Expand All @@ -588,7 +588,7 @@ func TestMessagesWithCaching(t *testing.T) {

t.Run("caches a multi-system message", func(t *testing.T) {
resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{
Model: anthropic.ModelClaudeInstant1Dot2,
Model: anthropic.ModelClaude3Haiku20240307,
MultiSystem: []anthropic.MessageSystemPart{
{
Type: "text",
Expand Down

0 comments on commit c96c8c6

Please sign in to comment.