Repository navigation
Expand file tree
/
Copy pathwrapper.ps1
More file actions
94 lines (81 loc) · 3.05 KB
/
Copy pathwrapper.ps1
File metadata and controls
94 lines (81 loc) · 3.05 KB
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
# GamerX AI - Wrapper Script
# This script receives the query and calls the main chatbot
param([string]$Query)
# Configuration
$API_KEY = "AIzaSyA1tszcr-fKZNCotwm3Xt8yoyupBB2np6E"
$MODEL = "gemini-2.0-flash"
function Show-Help {
Write-Host @"
╔════════════════════════════════════════════════════════════════╗
║ GamerX AI - Stateless Chatbot ║
║ ║
║ No installation • No storage • Direct API calls ║
╚════════════════════════════════════════════════════════════════╝
USAGE:
ai "your question" # Single query
ai -help # Show this help
EXAMPLES:
ai "write a python function to reverse a string"
ai "write javascript code to fetch API"
ai "C# code to read file"
FEATURES:
✓ No installation needed
✓ No data stored locally
✓ Direct Google Gemini API
✓ Code-only output
✓ Works on any Windows device
✓ No admin required
"@
}
function Invoke-GeminiAPI {
param([string]$UserMessage)
try {
# Prepare API request
$body = @{
contents = @(
@{
role = "user"
parts = @(
@{
text = "You are a code generation assistant. Output ONLY code, NO explanations, NO comments, NO markdown formatting, NO extra text. For code requests: output ONLY the code itself."
}
)
},
@{
role = "user"
parts = @(
@{
text = $UserMessage
}
)
}
)
generationConfig = @{
temperature = 0.5
maxOutputTokens = 2048
}
} | ConvertTo-Json -Depth 10
# Call Gemini API
$uri = "https://generativelanguage.googleapis.com/v1beta/models/${MODEL}:generateContent?key=${API_KEY}"
$response = Invoke-RestMethod -Uri $uri -Method Post -Body $body -ContentType "application/json" -ErrorAction Stop
if ($response.candidates -and $response.candidates[0].content.parts) {
$responseText = $response.candidates[0].content.parts[0].text
return $responseText
}
else {
return "Error: No response from API"
}
}
catch {
return "Error: $($_.Exception.Message)"
}
}
# Main logic
if ($Query -eq "-help" -or $Query -eq "help" -or $Query -eq "-h" -or [string]::IsNullOrWhiteSpace($Query)) {
Show-Help
}
else {
Write-Host "Thinking..." -ForegroundColor Yellow
$response = Invoke-GeminiAPI $Query
Write-Host $response
}