-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlacTec_Anthropic_WalkThrough2.txt
111 lines (82 loc) · 4.22 KB
/
BlacTec_Anthropic_WalkThrough2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#Update line 43 with your api key from https://console.anthropic.com/settings/keys
#Just ctrl+A this entire code block
# Ensure you're running PowerShell 5.1 or later
$PSVersionTable.PSVersion
# If needed, update PowerShell:
# Visit https://github.com/PowerShell/PowerShell/releases and download the latest stable version
# Install or update NuGet (package provider for PowerShell)
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
# Install or update PowerShellGet (PowerShell module for managing packages)
Install-Module -Name PowerShellGet -Force -AllowClobber -Scope CurrentUser
# Install the required modules
Install-Module -Name Microsoft.PowerShell.SecretManagement -Scope CurrentUser
Install-Module -Name Microsoft.PowerShell.SecretStore -Scope CurrentUser
#######
write-host "Developed By BlacTec, 0700 07192024" -foregroundcolor blue
Start-Sleep 5
write-host "Developed By BlacTec, 0700 07192024" -foregroundcolor Yellow
Start-Sleep 4
write-host "Developed By BlacTec, 0700 07192024" -foregroundcolor Green
Start-Sleep 3
write-host "Developed By BlacTec, 0700 07192024" -foregroundcolor Red
Start-Sleep 2
write-host "Developed By BlacTec, 0700 07192024" -foregroundcolor White
Start-Sleep 1
write-host "Developed By BlacTec, 0700 07192024" -foregroundcolor cyan
Start-Sleep 0
write-host "Developed By BlacTec, _____________________________________________________________________________________________________________________________________________________________" -foregroundcolor Green
Start-Sleep 1
write-host "Developed By BlacTec, _____________________________________________________________________________________________________________________________________________________________" -foregroundcolor Green
Start-Sleep 1
write-host "Developed By BlacTec, _____________________________________________________________________________________________________________________________________________________________" -foregroundcolor Green
write-host "Developed By BlacTec, Restarting" -foregroundcolor Green
Start-Sleep 6
# Initialize the SecretStore vault
Register-SecretVault -Name AnthropicVault -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
# Store your Anthropic API key securely
$apiKey = Read-Host "ENTER_YOUR_ANTHROPIC_API_KEY" -AsSecureString
Set-Secret -Name AnthropicApiKey -SecureStringSecret $apiKey -Vault AnthropicVault
#######
function Invoke-AnthropicAPI {
param (
[Parameter(Mandatory=$true)]
[string]$Prompt,
[Parameter(Mandatory=$false)]
[string]$Model = "claude-3-sonnet-20240229",
[Parameter(Mandatory=$false)]
[int]$MaxTokens = 1000
)
$apiKey = Get-Secret -Name AnthropicApiKey -AsPlainText -Vault AnthropicVault
$headers = @{
"Content-Type" = "application/json"
"x-api-key" = $apiKey
"anthropic-version" = "2023-06-01"
}
$body = @{
"model" = $Model
"max_tokens_to_sample" = $MaxTokens
"prompt" = $Prompt
} | ConvertTo-Json
$response = Invoke-RestMethod -Uri "https://api.anthropic.com/v1/complete" -Method Post -Headers $headers -Body $body
return $response.completion
}
####### Update API credits /// Check Update the Prompt for Testing
$prompt = "Human: What is the capital of France?
Assistant:"
$response = Invoke-AnthropicAPI -Prompt $prompt
Write-Output $response
####### Start My Interaction:
function Start-ClaudeChat {
$conversation = "Human: Hello, Claude. Let's have a conversation.
BlacTec_Ai-BOT: Hello! Let's Collab! What would you like to talk about?"
while ($true) {
$userInput = Read-Host "You (Input Inquiry)"
if ($userInput -eq "exit") { break }
$conversation += "`n`nHuman: $userInput`n`nAssistant:"
$response = Invoke-AnthropicAPI -Prompt $conversation -MaxTokens 5000
Write-Output "Claude: $response"
$conversation += $response
}
}
# Start the interactive chat
Start-ClaudeChat