Skip to content

Commit

Permalink
feat(sdk-js): add palm2 llm
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Jun 13, 2023
1 parent 8470db6 commit fbf10c9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
23 changes: 23 additions & 0 deletions sdk/embedbase-js/src/EmbedbaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,29 @@ export default class EmbedbaseClient {
const data: { results: Document[] } = await res.json()
return data.results
}

/**
* Execute a prompt using Google PaLM2 model
* @param prompt
* @returns
*/
public async complete(prompt: string): Promise<string> {
const url = 'https://llm-usx5gpslaq-uc.a.run.app'

const res = await fetch(url, {
method: 'POST',
body: JSON.stringify({
prompt: prompt,
}),
headers: {
'Content-Type': 'application/json',
},
})

await this.handleError(res);
const data: { answer: string } = await res.json()
return data.answer
}
}


Expand Down
22 changes: 21 additions & 1 deletion sdk/embedbase-js/src/EmbedbaseExperimentalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,27 @@ export default class EmbedbaseExperimentalClient {
const data: { results: Document[] } = await res.json()
return data.results
}
}

/**
* Execute a prompt using Google PaLM2 model
* @param prompt
* @returns
*/
public async complete(prompt: string): Promise<string> {
const url = 'https://llm-usx5gpslaq-uc.a.run.app'

const res = await fetch(url, {
method: 'POST',
body: JSON.stringify({
prompt: prompt,
}),
headers: {
'Content-Type': 'application/json',
},
})

await this.handleError(res);
const data: { answer: string } = await res.json()
return data.answer
}
}
14 changes: 10 additions & 4 deletions sdk/embedbase-js/test/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, jest, test } from '@jest/globals';
import fs from 'fs';
import glob from 'glob';
import path from 'path';
import { createClient, createExperimentalClient } from '../src/index';
import { stream as originalStream } from '../src/utils';
import glob from 'glob'
import fs from 'fs'
import path from 'path';

try {
require('dotenv').config({ path: './.env' })
Expand Down Expand Up @@ -524,4 +524,10 @@ test('should return a list of strings when using createContext with experimental

expect(data).toBeDefined()
expect(data).toHaveLength(2)
}, TIMEOUT)
}, TIMEOUT)

test('should be able to complete with experimental api', async () => {
const embedbase = createExperimentalClient(URL, KEY)
const data = await embedbase.complete('the tiger is the biggest cat')
expect(data).toBeDefined()
}, TIMEOUT)

2 comments on commit fbf10c9

@vercel
Copy link

@vercel vercel bot commented on fbf10c9 Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

embedbase – ./dashboard

app.embedbase.xyz
embedbase-prologe.vercel.app
embedbase.vercel.app
embedbase-git-main-prologe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on fbf10c9 Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.