feat: Refactor Gemini integration and build process
This commit centralizes Gemini API interaction into a new `server.ts` file and removes it from the client-side `geminiService.ts`. It also updates the build process in `package.json` to use `esbuild` for bundling the server code, enabling a more robust build pipeline. The `index.html` has been cleaned up by removing unnecessary OneSignal SDK initialization. Additionally, dev dependencies have been updated, including `esbuild` to version `0.28.0`. A new `test2.ts` file is added for testing Gemini API connectivity.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { GoogleGenAI } from "@google/genai";
|
||||
import * as dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const test = async () => {
|
||||
const ai = new GoogleGenAI({});
|
||||
try {
|
||||
const response = await ai.models.generateContent({
|
||||
model: "gemini-3.1-pro-preview",
|
||||
contents: "Tell me a joke"
|
||||
});
|
||||
console.log("Success:", response.text);
|
||||
} catch (err: any) {
|
||||
console.error("Error:", err.message);
|
||||
}
|
||||
}
|
||||
|
||||
test();
|
||||
Reference in New Issue
Block a user