초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
32
chatbot/test_embedding.php
Normal file
32
chatbot/test_embedding.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// Test script for Google Vertex AI Embedding API
|
||||
$apiKeyPath = '../apikey/google_vertex_api.txt';
|
||||
if (!file_exists($apiKeyPath)) {
|
||||
die("API Key file not found");
|
||||
}
|
||||
$apiKey = trim(file_get_contents($apiKeyPath));
|
||||
|
||||
$url = "https://generativelanguage.googleapis.com/v1beta/models/text-embedding-004:embedContent?key=" . $apiKey;
|
||||
|
||||
$data = [
|
||||
'model' => 'models/text-embedding-004',
|
||||
'content' => [
|
||||
'parts' => [
|
||||
['text' => 'Hello, this is a test for embedding.']
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
echo "HTTP Code: $httpCode\n";
|
||||
echo "Response: $response\n";
|
||||
?>
|
||||
Reference in New Issue
Block a user