-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8b4f69
commit 400f339
Showing
6 changed files
with
91 additions
and
622 deletions.
There are no files selected for viewing
73 changes: 44 additions & 29 deletions
73
JS/edgechains/examples/testcases/Palm2AiEndpoints.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,54 @@ | ||
import { Palm2AiEndpoint } from "../../lib/src/lib/endpoints/Palm2AiEndpoint"; | ||
|
||
describe('Palm2AiEndpoint', () => { | ||
test('should return the expected response for a given prompt', async () => { | ||
const apiKey = 'AIzaSyB2Cc5yX0q5HCOgMWtdsh5mALBorAiLlxE'; | ||
const model = 'models/text-bison-001'; | ||
const temperature = 0.7; | ||
const { setTimeout } = require("timers/promises"); | ||
const palm2Prompts = require("./palm2Prompts.json"); | ||
const Palm2ChatFn = require("../../lib/src/lib/endpoints/Palm2AiEndpoint") | ||
|
||
|
||
it('should return a string when called with valid parameters', async () => { | ||
// Arrange | ||
const prompt = palm2Prompts["Pm_of_india"]; | ||
const apiKey = "AIzaSyB2Cc5yX0q5HCOgMWtdsh5mALBorAiLlxE"; | ||
const temperature = 0.1; | ||
|
||
// Mock the fetch function | ||
global.fetch = jest.fn().mockResolvedValue({ | ||
json: jest.fn().mockResolvedValue({ | ||
candidates: [{ content: "Response" }] | ||
}) | ||
}); | ||
|
||
const palm2AiEndpoint = new Palm2AiEndpoint(apiKey, model, temperature); | ||
const result = await Palm2ChatFn(prompt, apiKey, temperature); | ||
|
||
// const response = await palm2AiEndpoint.chatFun(promptText) | ||
expect(await palm2AiEndpoint.chatFun("how many states in Inida")).toBe('28'); | ||
}); | ||
expect(typeof result).toBe("string"); | ||
}); | ||
describe('Palm2AiEndpoint', () => { | ||
test('should return the expected response for a given prompt', async () => { | ||
const apiKey = 'AIzaSyB2Cc5yX0q5HCOgMWtdsh5mALBorAiLlxE'; | ||
const model = 'models/text-bison-001'; | ||
const temperature = 0.7; | ||
it('should return a string when called with valid parameters', async () => { | ||
// Arrange | ||
const prompt = palm2Prompts["states_in_India"]; | ||
const apiKey = "AIzaSyB2Cc5yX0q5HCOgMWtdsh5mALBorAiLlxE"; | ||
const temperature = 0.1; | ||
|
||
global.fetch = jest.fn().mockResolvedValue({ | ||
json: jest.fn().mockResolvedValue({ | ||
candidates: [{ content: "Response" }] | ||
}) | ||
}); | ||
|
||
const palm2AiEndpoint = new Palm2AiEndpoint(apiKey, model, temperature); | ||
const result = await Palm2ChatFn(prompt, apiKey, temperature); | ||
|
||
// const response = await palm2AiEndpoint.chatFun(promptText) | ||
expect(await palm2AiEndpoint.chatFun("Pm of india")).toBe('NarendraModi'); | ||
}); | ||
expect(typeof result).toBe("string"); | ||
}); | ||
|
||
describe('Palm2AiEndpoint', () => { | ||
test('should return the expected response for a given prompt', async () => { | ||
const apiKey = 'AIzaSyB2Cc5yX0q5HCOgMWtdsh5mALBorAiLlxE'; | ||
const model = 'models/text-bison-001'; | ||
const temperature = 0.7; | ||
|
||
const palm2AiEndpoint = new Palm2AiEndpoint(apiKey, model, temperature); | ||
it('should return a string when called with valid parameters', async () => { | ||
const prompt = palm2Prompts["smallest_2_digit_value"]; | ||
const apiKey = "AIzaSyB2Cc5yX0q5HCOgMWtdsh5mALBorAiLlxE"; | ||
const temperature = 0.1; | ||
|
||
// const response = await palm2AiEndpoint.chatFun(promptText) | ||
expect(await palm2AiEndpoint.chatFun("smallest 2 digit value")).toBe('10'); | ||
global.fetch = jest.fn().mockResolvedValue({ | ||
json: jest.fn().mockResolvedValue({ | ||
candidates: [{ content: "Response" }] | ||
}) | ||
}); | ||
|
||
const result = await Palm2ChatFn(prompt, apiKey, temperature); | ||
|
||
expect(typeof result).toBe("string"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"states_in_India":"states in India", | ||
"Pm_of_india":"Who is Pm of india", | ||
"smallest_2_digit_value":"smallest 2 digit value" | ||
} | ||
|
Oops, something went wrong.