@ibgib/web-gib 0.0.5 → 0.0.7

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.
@@ -1,8 +1,37 @@
1
- import { Content, } from "@google/generative-ai";
2
- import type { StartChatParams, ChatSession, FunctionCallingMode, } from "@google/generative-ai";
1
+ import { Content, FunctionCallingConfigMode, GoogleGenAI, } from "@google/genai";
3
2
  import { PromptInfo, } from "../agent-types.mjs";
4
3
  import { TextSource } from "../agent-constants.mjs";
5
4
 
5
+ // #region @google/generative-ai to @google/genai shims
6
+ // the changes in @google/genai are a little bassackwards, in that they no
7
+ // longer expose the ability to constrain parts at compile time. these shims
8
+ // enable this.
9
+
10
+ import { type Part } from '@google/genai';
11
+
12
+ /** Utility type to make a specific key required, without using 'never' for others. */
13
+ type AssertRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
14
+
15
+ // Define your shims:
16
+
17
+ /** Represents a Part where the 'text' property is guaranteed to be a string. */
18
+ export type TextPart = AssertRequired<Part, 'text'>;
19
+
20
+ /** Represents a Part where the 'functionCall' property is guaranteed to be present. */
21
+ export type FunctionCallPart = AssertRequired<Part, 'functionCall'>;
22
+
23
+ /** Represents a Part where the 'functionResponse' property is guaranteed to be present. */
24
+ export type FunctionResponsePart = AssertRequired<Part, 'functionResponse'>;
25
+
26
+ // // If you need the other top-level types:
27
+ // export type GenerateContentResult = Parameters<NonNullable<ConstructorParameters<typeof GoogleGenAI>[0]>['generateContent']>['0'];
28
+
29
+ // The EnhancedGenerateContentResponse maps directly to the main response type now
30
+ import { type GenerateContentResponse } from '@google/genai';
31
+ export type EnhancedGenerateContentResponse = GenerateContentResponse;
32
+
33
+ // #endregion @google/generative-ai to @google/genai shims
34
+
6
35
  export interface PromptInfoEntryGemini {
7
36
  /**
8
37
  * The source of the text, in terms of our code definition.
@@ -36,23 +65,19 @@ export interface PromptInfoGemini extends PromptInfo {
36
65
  * recent.
37
66
  *
38
67
  * NOTE: We will be using this for the gemini api's "chat" function.
39
- *
40
- * @see {@link StartChatParams.history}
41
68
  */
42
69
  chatPromptHistoryParts: PromptInfoEntryGemini[];
43
70
  /**
44
71
  * The most recent chat message
45
- *
46
- * @see {@link ChatSession.sendMessage}
47
72
  */
48
73
  chatPromptCurrent: PromptInfoEntryGemini;
49
74
  /**
50
75
  * if truthy, this will override the default function calling mode when
51
76
  * prompting the LLM.
52
77
  *
53
- * if falsy, will use the default (FunctionCallingMode.ANY)
78
+ * if falsy, will use the default (FunctionCallingConfigMode.ANY)
54
79
  *
55
- * @see {@link FunctionCallingMode}
80
+ * @see {@link FunctionCallingConfigMode}
56
81
  *
57
82
  * ## notes
58
83
  *
@@ -61,7 +86,7 @@ export interface PromptInfoGemini extends PromptInfo {
61
86
  * to just ask the model a "normal" chat llm question (for translating some
62
87
  * text).
63
88
  */
64
- overrideFunctionCallingMode?: FunctionCallingMode;
89
+ overrideFunctionCallingMode?: FunctionCallingConfigMode;
65
90
  }
66
91
 
67
92
  /**
@@ -79,10 +104,11 @@ export type PromptAPIResult_Gemini =
79
104
 
80
105
  /**
81
106
  * This is a "kluge" IMO because it wraps the response part to be able to handle
82
- * all responses of functions. This is a limitation of the Gemini API which requires an
83
- * object as the response part's value. So if a function returns "undefined" or an array,
84
- * it throws an error. So this is a wrapper.
107
+ * all responses of functions. This is a limitation of the Gemini API which
108
+ * requires an object as the response part's value. So if a function returns
109
+ * "undefined" or an array, it throws an error. So this is a wrapper.
85
110
  */
86
111
  export interface FunctionResponsePart_ResponseWrapper {
87
112
  value: any | undefined;
113
+ [key: string]: any; // This satisfies the compiler for the *external* library
88
114
  }