Skip to content

Commit

Permalink
removed InputContent interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alx13 committed Mar 11, 2024
1 parent 2c971f1 commit 89f7756
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/main/src/methods/chat-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
GenerateContentStreamResult,
Part,
RequestOptions,
Role,
StartChatParams,
} from "../../types";
import { formatNewContent } from "../requests/request-helpers";
Expand Down Expand Up @@ -164,7 +165,7 @@ export class ChatSession {
const responseContent = { ...response.candidates[0].content };
// Response seems to come back without a role set.
if (!responseContent.role) {
responseContent.role = "model";
responseContent.role = Role.MODEL;
}
this._history.push(responseContent);
} else {
Expand Down
14 changes: 4 additions & 10 deletions packages/main/types/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@
* limitations under the License.
*/

import {Role} from "./enums";

/**
* Content type for both prompts and response candidates.
* @public
*/
export interface Content extends InputContent {
export interface Content {
role: Role;
parts: Part[];
}

/**
* Content that can be provided as history input to startChat().
* @public
*/
export interface InputContent {
parts: string | Array<string | Part>;
role: string;
}

/**
* Content part - includes text or image part types.
* @public
Expand Down
4 changes: 2 additions & 2 deletions packages/main/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { Content, InputContent } from "./content";
import { Content } from "./content";
import { HarmBlockThreshold, HarmCategory, TaskType } from "./enums";

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ export interface GenerationConfig {
* @public
*/
export interface StartChatParams extends BaseParams {
history?: InputContent[];
history?: Content[];
tools?: Tool[];
}

Expand Down
4 changes: 2 additions & 2 deletions samples/node/advanced-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ async function run() {
history: [
{
role: "user",
parts: "Hello, I have 2 dogs in my house.",
parts: [{"text": "Hello, I have 2 dogs in my house."}],
},
{
role: "model",
parts: "Great to meet you. What would you like to know?",
parts: [{"text": "Great to meet you. What would you like to know?"}],
},
],
generationConfig: {
Expand Down

0 comments on commit 89f7756

Please sign in to comment.