Skip to content

Commit

Permalink
fix/remove google sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Raghuwanshi committed Mar 1, 2024
1 parent b8b4f69 commit 400f339
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 622 deletions.
73 changes: 44 additions & 29 deletions JS/edgechains/examples/testcases/Palm2AiEndpoints.test.js
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");
});
6 changes: 6 additions & 0 deletions JS/edgechains/examples/testcases/palm2Prompts.json
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"
}

Loading

0 comments on commit 400f339

Please sign in to comment.