@umituz/react-native-ai-gemini-provider 3.0.19 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain/entities/gemini.types.d.ts +43 -0
- package/dist/domain/entities/models.d.ts +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/infrastructure/services/ChatSession.d.ts +24 -0
- package/dist/infrastructure/services/GeminiClient.d.ts +6 -2
- package/dist/infrastructure/services/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -88,3 +88,46 @@ export interface GeminiUsageMetadata {
|
|
|
88
88
|
/** Total number of tokens used */
|
|
89
89
|
totalTokenCount?: number;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Safety setting for a single harm category
|
|
93
|
+
*/
|
|
94
|
+
export interface GeminiSafetySetting {
|
|
95
|
+
category: GeminiHarmCategory;
|
|
96
|
+
threshold: GeminiHarmBlockThreshold;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Inline data part for binary content (images, audio)
|
|
100
|
+
*/
|
|
101
|
+
export interface GeminiInlineDataPart {
|
|
102
|
+
inlineData: {
|
|
103
|
+
mimeType: string;
|
|
104
|
+
data: string;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A message part that can be text or inline data
|
|
109
|
+
*/
|
|
110
|
+
export type GeminiMessagePart = GeminiPart | GeminiInlineDataPart;
|
|
111
|
+
/**
|
|
112
|
+
* Options for creating a generative model instance
|
|
113
|
+
*/
|
|
114
|
+
export interface GeminiModelOptions {
|
|
115
|
+
model?: string;
|
|
116
|
+
systemInstruction?: string;
|
|
117
|
+
safetySettings?: GeminiSafetySetting[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Configuration for a chat session
|
|
121
|
+
*/
|
|
122
|
+
export interface GeminiChatConfig {
|
|
123
|
+
/** Model name override */
|
|
124
|
+
model?: string;
|
|
125
|
+
/** System instruction for the model */
|
|
126
|
+
systemInstruction?: string;
|
|
127
|
+
/** Safety settings (defaults to BLOCK_NONE for all categories) */
|
|
128
|
+
safetySettings?: GeminiSafetySetting[];
|
|
129
|
+
/** Generation config (temperature, maxOutputTokens, etc.) */
|
|
130
|
+
generationConfig?: GeminiGenerationConfig;
|
|
131
|
+
/** Initial conversation history */
|
|
132
|
+
history?: GeminiContent[];
|
|
133
|
+
}
|
|
@@ -6,6 +6,10 @@ export declare const GEMINI_MODELS: {
|
|
|
6
6
|
readonly TEXT: {
|
|
7
7
|
/** Lightweight flash model for fast text generation */
|
|
8
8
|
readonly FLASH_LITE: "gemini-2.5-flash-lite";
|
|
9
|
+
/** Balanced flash model for general use */
|
|
10
|
+
readonly FLASH: "gemini-2.5-flash";
|
|
11
|
+
/** Premium model for complex tasks */
|
|
12
|
+
readonly PRO: "gemini-2.5-pro";
|
|
9
13
|
};
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
@@ -14,4 +18,6 @@ export declare const GEMINI_MODELS: {
|
|
|
14
18
|
export declare const DEFAULT_MODELS: {
|
|
15
19
|
/** Default model for text generation */
|
|
16
20
|
readonly TEXT: "gemini-2.5-flash-lite";
|
|
21
|
+
/** Default model for chat sessions */
|
|
22
|
+
readonly CHAT: "gemini-2.5-flash";
|
|
17
23
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* @umituz/react-native-ai-gemini-provider
|
|
3
3
|
* Google Gemini AI provider for React Native applications
|
|
4
4
|
*/
|
|
5
|
-
export type { GeminiConfig, GeminiGenerationConfig, GeminiHarmCategory, GeminiHarmBlockThreshold, GeminiContent, GeminiPart, GeminiResponse, GeminiCandidate, GeminiFinishReason, GeminiSafetyRating, GeminiUsageMetadata, GeminiErrorInfo, GeminiApiError, } from "./domain/entities";
|
|
5
|
+
export type { GeminiConfig, GeminiGenerationConfig, GeminiHarmCategory, GeminiHarmBlockThreshold, GeminiContent, GeminiPart, GeminiInlineDataPart, GeminiMessagePart, GeminiSafetySetting, GeminiModelOptions, GeminiChatConfig, GeminiResponse, GeminiCandidate, GeminiFinishReason, GeminiSafetyRating, GeminiUsageMetadata, GeminiErrorInfo, GeminiApiError, } from "./domain/entities";
|
|
6
6
|
export { GeminiErrorType, GeminiError, GEMINI_MODELS, DEFAULT_MODELS } from "./domain/entities";
|
|
7
7
|
export { geminiClient } from "./infrastructure/services/GeminiClient";
|
|
8
|
+
export { createChatSession } from "./infrastructure/services/ChatSession";
|
|
8
9
|
export { textGeneration } from "./infrastructure/services/TextGeneration";
|
|
9
10
|
export { structuredText } from "./infrastructure/services/StructuredText";
|
|
10
11
|
export { streaming } from "./infrastructure/services/Streaming";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GeminiChatConfig, GeminiMessagePart } from "../../domain/entities";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Gemini chat session with full support for system instructions,
|
|
4
|
+
* safety settings, generation config, and multi-turn conversation history.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ```ts
|
|
8
|
+
* const session = createChatSession({
|
|
9
|
+
* model: "gemini-2.5-flash",
|
|
10
|
+
* systemInstruction: "You are a helpful assistant.",
|
|
11
|
+
* generationConfig: { temperature: 0.7, maxOutputTokens: 512 },
|
|
12
|
+
* history: geminiHistory,
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* const text = await session.send([{ text: "Hello" }]);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function createChatSession(config?: GeminiChatConfig): {
|
|
19
|
+
/**
|
|
20
|
+
* Send a message and return the full response text.
|
|
21
|
+
* Accepts text parts and/or inline data parts (images, audio).
|
|
22
|
+
*/
|
|
23
|
+
send(parts: GeminiMessagePart[]): Promise<string>;
|
|
24
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GoogleGenerativeAI, type GenerativeModel } from "@google/generative-ai";
|
|
2
|
-
import type { GeminiConfig } from "../../domain/entities";
|
|
2
|
+
import type { GeminiConfig, GeminiModelOptions } from "../../domain/entities";
|
|
3
3
|
declare class GeminiClient {
|
|
4
4
|
private client;
|
|
5
5
|
private config;
|
|
@@ -8,7 +8,11 @@ declare class GeminiClient {
|
|
|
8
8
|
isInitialized(): boolean;
|
|
9
9
|
getConfig(): GeminiConfig | null;
|
|
10
10
|
getClient(): GoogleGenerativeAI | null;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Returns a GenerativeModel configured with optional safety settings and system instruction.
|
|
13
|
+
* When no safety settings are provided, defaults to BLOCK_NONE for all categories.
|
|
14
|
+
*/
|
|
15
|
+
getModel(modelNameOrOptions?: string | GeminiModelOptions): GenerativeModel;
|
|
12
16
|
reset(): void;
|
|
13
17
|
}
|
|
14
18
|
export declare const geminiClient: GeminiClient;
|
package/package.json
CHANGED