@micdrop/gemini 1.0.0 → 1.1.0
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/README.md +1 -1
- package/dist/index.d.mts +43 -16
- package/dist/index.d.ts +43 -16
- package/dist/index.js +383 -313
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -305
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ new MicdropServer(socket, {
|
|
|
66
66
|
})
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
The Micdrop client detects when the user speaks, so the automatic activity detection of Gemini is turned off. Tools are added with `addTool()` right after creating the model, since Gemini reads them when the session opens.
|
|
69
|
+
The Micdrop client detects when the user speaks, so the automatic activity detection of Gemini is turned off. Tools are added with `addTool()` right after creating the model, since Gemini reads them when the session opens. When the user interrupts the answer while a tool runs, its result goes in the conversation and reaches the model silently, so it keeps quiet about it.
|
|
70
70
|
|
|
71
71
|
### Events
|
|
72
72
|
|
package/dist/index.d.mts
CHANGED
|
@@ -25,11 +25,20 @@ type GeminiOptions = {
|
|
|
25
25
|
};
|
|
26
26
|
declare class GeminiAgent extends Agent<GeminiAgentOptions> {
|
|
27
27
|
private genai;
|
|
28
|
-
private abortController?;
|
|
29
28
|
private signatures;
|
|
30
29
|
constructor(options: GeminiAgentOptions);
|
|
31
|
-
protected generateAnswer(stream: PassThrough,
|
|
32
|
-
|
|
30
|
+
protected generateAnswer(stream: PassThrough, signal: AbortSignal): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Generates one step of the answer, retried on error.
|
|
33
|
+
*
|
|
34
|
+
* A retry starts the step over, so it only happens while nothing of the
|
|
35
|
+
* step reached the stream: what was said cannot be taken back, and saying
|
|
36
|
+
* it twice is worse than stopping there.
|
|
37
|
+
*/
|
|
38
|
+
private generateStep;
|
|
39
|
+
/** Streams one request, writing the text of the answer as it comes */
|
|
40
|
+
private streamStep;
|
|
41
|
+
private recordAnswer;
|
|
33
42
|
private buildSystemInstruction;
|
|
34
43
|
private buildInput;
|
|
35
44
|
private buildTools;
|
|
@@ -57,16 +66,19 @@ declare class GeminiLive extends Realtime<GeminiLiveOptions> {
|
|
|
57
66
|
private socket;
|
|
58
67
|
private everConnected;
|
|
59
68
|
private resumptionHandle?;
|
|
60
|
-
private resuming;
|
|
61
69
|
private goingAway;
|
|
62
70
|
private outputResampler;
|
|
63
71
|
private hasTranscribedTurn;
|
|
64
72
|
private ignoreUserTranscript;
|
|
65
73
|
private cancelledToolCalls;
|
|
66
|
-
private
|
|
67
|
-
private
|
|
68
|
-
private answerEndDeferred;
|
|
74
|
+
private session;
|
|
75
|
+
private toolRound;
|
|
69
76
|
constructor(options: GeminiLiveOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Stops the answer. The tools it is waiting for still send their results,
|
|
79
|
+
* silently, since a blocking call left unanswered would stall the model.
|
|
80
|
+
*/
|
|
81
|
+
cancel(): void;
|
|
70
82
|
destroy(): void;
|
|
71
83
|
protected openTurn(): void;
|
|
72
84
|
protected appendAudio(chunk: Buffer): void;
|
|
@@ -84,6 +96,14 @@ declare class GeminiLive extends Realtime<GeminiLiveOptions> {
|
|
|
84
96
|
private buildSetup;
|
|
85
97
|
private onReady;
|
|
86
98
|
private onReconnecting;
|
|
99
|
+
/** Forgets what belonged to the previous session */
|
|
100
|
+
private startFreshSession;
|
|
101
|
+
/**
|
|
102
|
+
* Starts a new round of tools. The tools still running belong to the old
|
|
103
|
+
* one: their results go out silently, and nothing waits for the model to
|
|
104
|
+
* talk about them.
|
|
105
|
+
*/
|
|
106
|
+
private resetToolRound;
|
|
87
107
|
/** Moves to a new connection before Gemini closes this one */
|
|
88
108
|
private renewIfGoingAway;
|
|
89
109
|
private onMessage;
|
|
@@ -91,7 +111,6 @@ declare class GeminiLive extends Realtime<GeminiLiveOptions> {
|
|
|
91
111
|
private onModelOutput;
|
|
92
112
|
/** Ends the answer the model stopped giving to wait for a tool */
|
|
93
113
|
private endDeferredAnswer;
|
|
94
|
-
private clearToolFollowUp;
|
|
95
114
|
/**
|
|
96
115
|
* The transcript of the turn comes before the answer, so the first piece of
|
|
97
116
|
* the answer closes it.
|
|
@@ -124,22 +143,30 @@ declare class GeminiSTT extends STT {
|
|
|
124
143
|
private readonly options;
|
|
125
144
|
private socket;
|
|
126
145
|
private goingAway;
|
|
127
|
-
private
|
|
128
|
-
private utteranceOpen;
|
|
129
|
-
private utteranceEnded;
|
|
130
|
-
private transcript;
|
|
131
|
-
private transcriptionTimeout?;
|
|
146
|
+
private utterances;
|
|
132
147
|
constructor(options: GeminiSTTOptions);
|
|
133
148
|
transcribe(audioStream: Readable): void;
|
|
134
149
|
destroy(): void;
|
|
135
150
|
private buildSetup;
|
|
136
151
|
private openUtterance;
|
|
152
|
+
private endUtterance;
|
|
153
|
+
/** Sends the first utterance to Gemini, with the audio it held meanwhile */
|
|
154
|
+
private sendFirst;
|
|
155
|
+
private sendEnd;
|
|
137
156
|
private sendAudio;
|
|
138
|
-
/**
|
|
139
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Emits what was transcribed of an utterance, possibly nothing, and keeps
|
|
159
|
+
* it in line for what Gemini still sends about it
|
|
160
|
+
*/
|
|
161
|
+
private give;
|
|
162
|
+
private remove;
|
|
163
|
+
/** Moves to a new connection once no utterance waits on this one */
|
|
164
|
+
private renewIfGoingAway;
|
|
165
|
+
private onReady;
|
|
140
166
|
private onMessage;
|
|
141
167
|
private onReconnecting;
|
|
142
|
-
private
|
|
168
|
+
private onFailed;
|
|
169
|
+
private dropUtterances;
|
|
143
170
|
}
|
|
144
171
|
|
|
145
172
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -25,11 +25,20 @@ type GeminiOptions = {
|
|
|
25
25
|
};
|
|
26
26
|
declare class GeminiAgent extends Agent<GeminiAgentOptions> {
|
|
27
27
|
private genai;
|
|
28
|
-
private abortController?;
|
|
29
28
|
private signatures;
|
|
30
29
|
constructor(options: GeminiAgentOptions);
|
|
31
|
-
protected generateAnswer(stream: PassThrough,
|
|
32
|
-
|
|
30
|
+
protected generateAnswer(stream: PassThrough, signal: AbortSignal): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Generates one step of the answer, retried on error.
|
|
33
|
+
*
|
|
34
|
+
* A retry starts the step over, so it only happens while nothing of the
|
|
35
|
+
* step reached the stream: what was said cannot be taken back, and saying
|
|
36
|
+
* it twice is worse than stopping there.
|
|
37
|
+
*/
|
|
38
|
+
private generateStep;
|
|
39
|
+
/** Streams one request, writing the text of the answer as it comes */
|
|
40
|
+
private streamStep;
|
|
41
|
+
private recordAnswer;
|
|
33
42
|
private buildSystemInstruction;
|
|
34
43
|
private buildInput;
|
|
35
44
|
private buildTools;
|
|
@@ -57,16 +66,19 @@ declare class GeminiLive extends Realtime<GeminiLiveOptions> {
|
|
|
57
66
|
private socket;
|
|
58
67
|
private everConnected;
|
|
59
68
|
private resumptionHandle?;
|
|
60
|
-
private resuming;
|
|
61
69
|
private goingAway;
|
|
62
70
|
private outputResampler;
|
|
63
71
|
private hasTranscribedTurn;
|
|
64
72
|
private ignoreUserTranscript;
|
|
65
73
|
private cancelledToolCalls;
|
|
66
|
-
private
|
|
67
|
-
private
|
|
68
|
-
private answerEndDeferred;
|
|
74
|
+
private session;
|
|
75
|
+
private toolRound;
|
|
69
76
|
constructor(options: GeminiLiveOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Stops the answer. The tools it is waiting for still send their results,
|
|
79
|
+
* silently, since a blocking call left unanswered would stall the model.
|
|
80
|
+
*/
|
|
81
|
+
cancel(): void;
|
|
70
82
|
destroy(): void;
|
|
71
83
|
protected openTurn(): void;
|
|
72
84
|
protected appendAudio(chunk: Buffer): void;
|
|
@@ -84,6 +96,14 @@ declare class GeminiLive extends Realtime<GeminiLiveOptions> {
|
|
|
84
96
|
private buildSetup;
|
|
85
97
|
private onReady;
|
|
86
98
|
private onReconnecting;
|
|
99
|
+
/** Forgets what belonged to the previous session */
|
|
100
|
+
private startFreshSession;
|
|
101
|
+
/**
|
|
102
|
+
* Starts a new round of tools. The tools still running belong to the old
|
|
103
|
+
* one: their results go out silently, and nothing waits for the model to
|
|
104
|
+
* talk about them.
|
|
105
|
+
*/
|
|
106
|
+
private resetToolRound;
|
|
87
107
|
/** Moves to a new connection before Gemini closes this one */
|
|
88
108
|
private renewIfGoingAway;
|
|
89
109
|
private onMessage;
|
|
@@ -91,7 +111,6 @@ declare class GeminiLive extends Realtime<GeminiLiveOptions> {
|
|
|
91
111
|
private onModelOutput;
|
|
92
112
|
/** Ends the answer the model stopped giving to wait for a tool */
|
|
93
113
|
private endDeferredAnswer;
|
|
94
|
-
private clearToolFollowUp;
|
|
95
114
|
/**
|
|
96
115
|
* The transcript of the turn comes before the answer, so the first piece of
|
|
97
116
|
* the answer closes it.
|
|
@@ -124,22 +143,30 @@ declare class GeminiSTT extends STT {
|
|
|
124
143
|
private readonly options;
|
|
125
144
|
private socket;
|
|
126
145
|
private goingAway;
|
|
127
|
-
private
|
|
128
|
-
private utteranceOpen;
|
|
129
|
-
private utteranceEnded;
|
|
130
|
-
private transcript;
|
|
131
|
-
private transcriptionTimeout?;
|
|
146
|
+
private utterances;
|
|
132
147
|
constructor(options: GeminiSTTOptions);
|
|
133
148
|
transcribe(audioStream: Readable): void;
|
|
134
149
|
destroy(): void;
|
|
135
150
|
private buildSetup;
|
|
136
151
|
private openUtterance;
|
|
152
|
+
private endUtterance;
|
|
153
|
+
/** Sends the first utterance to Gemini, with the audio it held meanwhile */
|
|
154
|
+
private sendFirst;
|
|
155
|
+
private sendEnd;
|
|
137
156
|
private sendAudio;
|
|
138
|
-
/**
|
|
139
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Emits what was transcribed of an utterance, possibly nothing, and keeps
|
|
159
|
+
* it in line for what Gemini still sends about it
|
|
160
|
+
*/
|
|
161
|
+
private give;
|
|
162
|
+
private remove;
|
|
163
|
+
/** Moves to a new connection once no utterance waits on this one */
|
|
164
|
+
private renewIfGoingAway;
|
|
165
|
+
private onReady;
|
|
140
166
|
private onMessage;
|
|
141
167
|
private onReconnecting;
|
|
142
|
-
private
|
|
168
|
+
private onFailed;
|
|
169
|
+
private dropUtterances;
|
|
143
170
|
}
|
|
144
171
|
|
|
145
172
|
/**
|