Skip to content

Commit 82f22ab

Browse files
committed
examples: add basic Anthropic API demo
Demonstrates basic Anthropic Claude API usage: - Simple text completion - Complex reasoning tasks - System messages for context setting - Token usage tracking
1 parent bc181f1 commit 82f22ab

7 files changed

Lines changed: 1217 additions & 0 deletions

File tree

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# Migration Guides
2+
3+
This document provides migration guides for major changes in LangChainGo.
4+
5+
## OpenAI Default Model Change (v0.1.14+)
6+
7+
### What Changed
8+
9+
Starting with LangChainGo v0.1.14+, the default OpenAI model has changed from **`gpt-3.5-turbo`** to **`gpt-4o-mini`**.
10+
11+
### Why This Change
12+
13+
- `gpt-4o-mini` offers better performance and capabilities than `gpt-3.5-turbo`
14+
- It's more cost-effective and faster than full GPT-4 models
15+
- Provides better reasoning and instruction-following capabilities
16+
17+
### Impact Assessment
18+
19+
**If you're not explicitly setting a model:**
20+
```go
21+
// This will now use gpt-4o-mini instead of gpt-3.5-turbo
22+
llm, err := openai.New()
23+
```
24+
25+
**Your code will continue to work**, but responses might be:
26+
- Slightly different in style or format
27+
- More accurate and detailed
28+
- Potentially use slightly more tokens
29+
30+
### Migration Options
31+
32+
#### Option 1: Accept the new default (Recommended)
33+
Most applications will benefit from the improved capabilities. No code changes needed.
34+
35+
#### Option 2: Explicitly use the old model
36+
If you need exact compatibility with previous behavior:
37+
38+
```go
39+
// Before (implicit)
40+
llm, err := openai.New()
41+
42+
// After (explicit)
43+
llm, err := openai.New(openai.WithModel("gpt-3.5-turbo"))
44+
```
45+
46+
#### Option 3: Upgrade to a better model
47+
Take this opportunity to upgrade to an even better model:
48+
49+
```go
50+
// Upgrade to full GPT-4o for best quality
51+
llm, err := openai.New(openai.WithModel("gpt-4o"))
52+
53+
// Or use GPT-4o-mini explicitly
54+
llm, err := openai.New(openai.WithModel("gpt-4o-mini"))
55+
```
56+
57+
### Testing Your Application
58+
59+
1. **Test with default model**: Run your application without specifying a model
60+
2. **Compare outputs**: Check if the new outputs meet your requirements
61+
3. **Monitor token usage**: `gpt-4o-mini` usage should be similar to `gpt-3.5-turbo`
62+
4. **Update tests**: If you have tests that depend on specific response formats
63+
64+
### Example Migration
65+
66+
```go
67+
package main
68+
69+
import (
70+
"context"
71+
"fmt"
72+
"log"
73+
74+
"github.com/tmc/langchaingo/llms/openai"
75+
)
76+
77+
func main() {
78+
ctx := context.Background()
79+
80+
// ✅ Modern approach - uses gpt-4o-mini by default
81+
llm, err := openai.New()
82+
if err != nil {
83+
log.Fatal(err)
84+
}
85+
86+
// ✅ If you need the old behavior
87+
// llm, err := openai.New(openai.WithModel("gpt-3.5-turbo"))
88+
89+
// ✅ If you want the best available model
90+
// llm, err := openai.New(openai.WithModel("gpt-4o"))
91+
92+
response, err := llm.Call(ctx, "What is the capital of France?")
93+
if err != nil {
94+
log.Fatal(err)
95+
}
96+
97+
fmt.Println(response)
98+
}
99+
```
100+
101+
---
102+
103+
## Milvus SDK Migration
104+
105+
### What Changed
106+
107+
The official Milvus Go SDK repository has been deprecated and archived. The new SDK is now part of the main Milvus repository.
108+
109+
### Migration Steps
110+
111+
#### 1. Update Dependencies
112+
113+
In your `go.mod`:
114+
115+
```diff
116+
- github.com/milvus-io/milvus-sdk-go/v2 v2.4.0
117+
+ github.com/milvus-io/milvus/client/v2 v2.4.2
118+
```
119+
120+
#### 2. Update Import Statements
121+
122+
```diff
123+
- import "github.com/milvus-io/milvus-sdk-go/v2/client"
124+
- import "github.com/milvus-io/milvus-sdk-go/v2/entity"
125+
+ import "github.com/milvus-io/milvus/client/v2/client"
126+
+ import "github.com/milvus-io/milvus/client/v2/entity"
127+
```
128+
129+
#### 3. Run Migration Commands
130+
131+
```bash
132+
# Update dependencies
133+
go get github.com/milvus-io/milvus/client/v2@latest
134+
go mod tidy
135+
136+
# Test the changes
137+
go test ./vectorstores/milvus/...
138+
```
139+
140+
### Files That Need Updates
141+
142+
If you're using Milvus vector store directly:
143+
- Any files importing the old SDK
144+
- Integration tests
145+
- Example applications
146+
147+
The API remains largely compatible, so most code should work without changes.
148+
149+
---
150+
151+
## Breaking Changes Checklist
152+
153+
When migrating between versions, check for these common breaking changes:
154+
155+
### v0.1.14+
156+
- [ ] Default OpenAI model changed to `gpt-4o-mini`
157+
- [ ] Review any hardcoded model assumptions
158+
- [ ] Test applications with new default behavior
159+
160+
### v0.1.13+
161+
- [ ] Check Milvus vector store imports
162+
- [ ] Update deprecated Milvus SDK references
163+
164+
### General Migration Tips
165+
166+
1. **Pin your versions**: Use specific versions in production
167+
```go
168+
// go.mod
169+
github.com/tmc/langchaingo v0.1.13
170+
```
171+
172+
2. **Test thoroughly**: Always test migrations in a staging environment
173+
174+
3. **Monitor changes**: Subscribe to the [GitHub releases](https://github.com/tmc/langchaingo/releases)
175+
176+
4. **Update incrementally**: Don't skip major versions if possible
177+
178+
5. **Read release notes**: Check the changelog for each version
179+
180+
---
181+
182+
## Getting Help
183+
184+
If you encounter issues during migration:
185+
186+
1. Check the [GitHub Issues](https://github.com/tmc/langchaingo/issues)
187+
2. Search for existing solutions
188+
3. Create a new issue with:
189+
- Your current version
190+
- Target version
191+
- Specific error messages
192+
- Minimal reproduction code
193+
194+
---
195+
196+
## Version Compatibility Matrix
197+
198+
| LangChainGo Version | OpenAI Default Model | Milvus SDK | Go Version |
199+
|-------------------|---------------------|------------|------------|
200+
| v0.1.14+ | gpt-4o-mini | New SDK | 1.21+ |
201+
| v0.1.13 | gpt-3.5-turbo | New SDK | 1.21+ |
202+
| v0.1.12 | gpt-3.5-turbo | Old SDK | 1.21+ |
203+
204+
---
205+
206+
*This migration guide is updated regularly. Last updated: 2025-08-29*

0 commit comments

Comments
 (0)