지도크기오류 수정
This commit is contained in:
@@ -3,6 +3,7 @@ import { GoogleGenAI, Type } from "@google/genai";
|
||||
|
||||
const apiKey = import.meta.env.VITE_GEMINI_API_KEY || process.env.GEMINI_API_KEY || process.env.API_KEY || '';
|
||||
if (!apiKey) console.error("API Key is missing!");
|
||||
const isDebug = import.meta.env.DEV;
|
||||
const ai = new GoogleGenAI({ apiKey });
|
||||
|
||||
export interface DetailedSearchResult {
|
||||
@@ -15,7 +16,7 @@ export interface DetailedSearchResult {
|
||||
export const geminiService = {
|
||||
async searchNearbyWiFi(query: string, location: { lat: number, lng: number }) {
|
||||
try {
|
||||
console.log("Stage 1: 정보 검색 시작...");
|
||||
if (isDebug) console.log("Stage 1: 정보 검색 시작...");
|
||||
|
||||
// Stage 1: Google Search/Maps Grounding을 통해 원시 데이터 확보
|
||||
const searchResponse = await ai.models.generateContent({
|
||||
@@ -36,13 +37,13 @@ export const geminiService = {
|
||||
});
|
||||
|
||||
const rawText = searchResponse.text || "";
|
||||
console.log("Stage 1 원문 결과:", rawText);
|
||||
if (isDebug) console.log("Stage 1 원문 결과:", rawText);
|
||||
|
||||
if (!rawText) {
|
||||
return { text: "검색 결과를 가져오지 못했습니다.", results: [] };
|
||||
}
|
||||
|
||||
console.log("Stage 2: 데이터 구조화 추출 시작...");
|
||||
if (isDebug) console.log("Stage 2: 데이터 구조화 추출 시작...");
|
||||
|
||||
// Stage 2: 획득한 텍스트에서 JSON 형태로 좌표 및 정보 정밀 추출
|
||||
const parseResponse = await ai.models.generateContent({
|
||||
@@ -74,7 +75,7 @@ export const geminiService = {
|
||||
let results: DetailedSearchResult[] = [];
|
||||
try {
|
||||
results = JSON.parse(parseResponse.text || "[]");
|
||||
console.log("Stage 2 추출 성공:", results);
|
||||
if (isDebug) console.log("Stage 2 추출 성공:", results);
|
||||
} catch (e) {
|
||||
console.error("JSON 파싱 실패:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user