Skip to content

Commit

Permalink
temp stop point on Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jnaglick committed Jun 19, 2024
1 parent 5d65085 commit c13384f
Show file tree
Hide file tree
Showing 10 changed files with 1,131 additions and 208 deletions.
274 changes: 265 additions & 9 deletions packages/core/src/apis/google/__snapshots__/gemini.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GoogleGeminiApi.requestTemplate doesnt include prompt if contents end with a user role 1`] = `
exports[`GoogleGeminiApi.requestTemplate prompt 1`] = `
{
"contents": [
{
"parts": [
{
"text": "mock-user-text",
"text": "mock-prompt",
},
],
"role": "user",
Expand All @@ -15,7 +15,7 @@ exports[`GoogleGeminiApi.requestTemplate doesnt include prompt if contents end w
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt 1`] = `
exports[`GoogleGeminiApi.requestTemplate prompt, $tools 1`] = `
{
"contents": [
{
Expand All @@ -27,10 +27,48 @@ exports[`GoogleGeminiApi.requestTemplate prompt 1`] = `
"role": "user",
},
],
"tools": [
{
"function_declarations": [
{
"description": "mock-description-1",
"name": "mock-function-1",
"parameters": {
"properties": {
"mock-function-1-param-1": {
"description": "mock-function-1-param-1-description-1",
"type": "STRING",
},
"mock-function-1-param-2": {
"description": "mock-function-1-param-2-description-2",
"type": "NUMBER",
},
},
"required": [],
"type": "OBJECT",
},
},
{
"description": "mock-description-2",
"name": "mock-function-2",
"parameters": {
"properties": {
"mock-function-2-param-1": {
"description": "mock-function-2-param-1-description-1",
"type": "BOOLEAN",
},
},
"required": [],
"type": "OBJECT",
},
},
],
},
],
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents 1`] = `
exports[`GoogleGeminiApi.requestTemplate prompt, contents (appends prompt) 1`] = `
{
"contents": [
{
Expand Down Expand Up @@ -69,7 +107,7 @@ exports[`GoogleGeminiApi.requestTemplate prompt, contents 1`] = `
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents with function_call 1`] = `
exports[`GoogleGeminiApi.requestTemplate prompt, contents ending with function_call, $tools with matching invocation (adds function_response content items) 1`] = `
{
"contents": [
{
Expand All @@ -83,33 +121,108 @@ exports[`GoogleGeminiApi.requestTemplate prompt, contents with function_call 1`]
},
},
],
"role": "model",
},
{
"parts": [
{
"text": "mock-prompt",
"function_response": {
"name": "mock-function",
"response": {
"returned": {
"responseKey": "responseValue",
},
},
},
},
],
"role": "user",
},
],
"tools": [
{
"function_declarations": [
{
"description": "mock-description",
"name": "mock-function",
"parameters": {
"properties": {
"key": {
"description": "mock-key-description",
"type": "STRING",
},
},
"required": [
"key",
],
"type": "OBJECT",
},
},
],
},
],
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents with function_response 1`] = `
exports[`GoogleGeminiApi.requestTemplate prompt, contents ending with model function_call, $tools without matching invocation (appends prompt; TODO logs warning) 1`] = `
{
"contents": [
{
"parts": [
{
"function_response": {
"function_call": {
"args": {
"key": "value",
},
"name": "mock-function",
"response": {
},
},
],
"role": "model",
},
{
"parts": [],
"role": "user",
},
],
"tools": [
{
"function_declarations": [
{
"description": "another-description",
"name": "another-function",
"parameters": {
"properties": {
"another-key": {
"description": "another-key-description",
"type": "STRING",
},
},
"required": [],
"type": "OBJECT",
},
},
],
},
],
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents ending with model function_call, no $tools (appends prompt; TODO logs warning) 1`] = `
{
"contents": [
{
"parts": [
{
"function_call": {
"args": {
"key": "value",
},
"name": "mock-function",
},
},
],
"role": "model",
},
{
"parts": [
Expand All @@ -123,6 +236,78 @@ exports[`GoogleGeminiApi.requestTemplate prompt, contents with function_response
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents ending with user (does not append prompt) 1`] = `
{
"contents": [
{
"parts": [
{
"text": "mock-model-text",
},
],
"role": "model",
},
{
"parts": [
{
"text": "mock-user-text",
},
],
"role": "user",
},
{
"parts": [
{
"text": "mock-model-text-2",
},
],
"role": "model",
},
{
"parts": [
{
"text": "mock-user-text-2",
},
],
"role": "user",
},
],
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents ending with user function_response (doesnt append prompt) 1`] = `
{
"contents": [
{
"parts": [
{
"function_call": {
"args": {
"key": "value",
},
"name": "mock-function",
},
},
],
"role": "model",
},
{
"parts": [
{
"function_response": {
"name": "mock-function",
"response": {
"responseKey": "responseValue",
},
},
},
],
"role": "user",
},
],
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, contents, system_instruction 1`] = `
{
"contents": [
Expand Down Expand Up @@ -600,6 +785,77 @@ exports[`GoogleGeminiApi.requestTemplate prompt, tools 1`] = `
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, tools, $tools 1`] = `
{
"contents": [
{
"parts": [
{
"text": "mock-prompt",
},
],
"role": "user",
},
],
"tools": [
{
"function_declarations": [
{
"description": "mock-description",
"name": "mock-function",
"parameters": {
"properties": {
"key": {
"type": "STRING",
},
},
"type": "OBJECT",
},
},
],
},
{
"function_declarations": [
{
"description": "mock-description-1",
"name": "mock-function-1",
"parameters": {
"properties": {
"mock-function-1-param-1": {
"description": "mock-function-1-param-1-description-1",
"type": "STRING",
},
"mock-function-1-param-2": {
"description": "mock-function-1-param-2-description-2",
"type": "NUMBER",
},
},
"required": [
"mock-function-1-param-2",
],
"type": "OBJECT",
},
},
{
"description": "mock-description-2",
"name": "mock-function-2",
"parameters": {
"properties": {
"mock-function-2-param-1": {
"description": "mock-function-2-param-1-description-1",
"type": "BOOLEAN",
},
},
"required": [],
"type": "OBJECT",
},
},
],
},
],
}
`;

exports[`GoogleGeminiApi.requestTemplate prompt, tools_config 1`] = `
{
"contents": [
Expand Down
Loading

0 comments on commit c13384f

Please sign in to comment.