-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from tghamm/feature/function-calling
v3.0.0 - Tools and More
- Loading branch information
Showing
33 changed files
with
2,590 additions
and
65,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Anthropic.SDK.Constants; | ||
using Anthropic.SDK.Messaging; | ||
|
||
namespace Anthropic.SDK.Tests | ||
{ | ||
[TestClass] | ||
public class HttpClientTests | ||
{ | ||
public HttpClient CustomHttpClientFail() | ||
{ | ||
var client = new HttpClient | ||
{ | ||
Timeout = TimeSpan.FromSeconds(3) // Set timeout to 120 seconds | ||
}; | ||
|
||
// Additional customization of the HttpClient can be done here | ||
|
||
return client; | ||
} | ||
|
||
public HttpClient CustomHttpClientPass() | ||
{ | ||
var client = new HttpClient | ||
{ | ||
Timeout = TimeSpan.FromSeconds(120) // Set timeout to 120 seconds | ||
}; | ||
|
||
// Additional customization of the HttpClient can be done here | ||
|
||
return client; | ||
} | ||
|
||
[TestMethod] | ||
public async Task TestBasicHttpClientFailure() | ||
{ | ||
var client = new AnthropicClient(); | ||
client.HttpClient = CustomHttpClientFail(); | ||
var messages = new List<Message>(); | ||
messages.Add(new Message() | ||
{ | ||
Role = RoleType.User, | ||
Content = "Write me a sonnet about the Statue of Liberty" | ||
}); | ||
var parameters = new MessageParameters() | ||
{ | ||
Messages = messages, | ||
MaxTokens = 512, | ||
Model = AnthropicModels.Claude3Opus, | ||
Stream = false, | ||
Temperature = 1.0m, | ||
}; | ||
await Assert.ThrowsExceptionAsync<TaskCanceledException>(async () => | ||
{ | ||
var res = await client.Messages.GetClaudeMessageAsync(parameters); | ||
}); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public async Task TestBasicHttpClientPass() | ||
{ | ||
var client = new AnthropicClient(); | ||
client.HttpClient = CustomHttpClientPass(); | ||
var messages = new List<Message>(); | ||
messages.Add(new Message() | ||
{ | ||
Role = RoleType.User, | ||
Content = "Write me a sonnet about the Statue of Liberty" | ||
}); | ||
var parameters = new MessageParameters() | ||
{ | ||
Messages = messages, | ||
MaxTokens = 512, | ||
Model = AnthropicModels.Claude3Opus, | ||
Stream = false, | ||
Temperature = 1.0m, | ||
}; | ||
var res = await client.Messages.GetClaudeMessageAsync(parameters); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.