-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: updated the code to new APIs structure * feat: adding the embeddings api * feat: adding test cases * feat: embedding APIs * fix: minor changes on tsconfig * fix: minor changes * feat: adding the new prompts API * feat: adding the embeddings api * fix: updating the embeddings API * fix: updating the baseurl and routes * feat: post api for proxy and minor changes on the urls * fix: adding the postmethdo file * fix: updating the test cases * fix: adding yarn.lock file * feat: adding the CI pipeline for publishing to NPM on release * fix: making portkey the default export * docs: adding an example docs * feat: adding commit checker * fix: updating the commit checker * fix: updating the commit checker * fix: updating the commit checker * fix: updating the commit checker * feat: adding feedback routes * fix: adding streaming to feedbacks and override configs in APIs * feat: over-ride of the params in chat and completions route * fix: feedbacks to accept array as input * fix: config override * fix: adding the embeddings api in client * fix: changing traceID to trace_id * fix: adding traceid type * fix: adding the tracid correction * feat: added the getHeaders function for each response in non-streaming mode * feat: added the completions method on embeddings * feat: added Llamaindex integration in portkey * fix: removing the langchain folder * fix: fixed override of configs with empty updated config. Also added an isempty check function * fix: added langchainjs * fix: updating the type * fix: overwriting the config everytime * fix: removing empty values on the headers * fix: embeddings and prompts completion * fix: handling last package in streaming mode * fix: minor fix * fix: update on the url of prompts api * fix: adding stream to prompts body * fix: updating the promptId to promptID * feat: adding authorization param in the client * fix: updating the post method * fix: fixing the camel case issue in the body * doc: Udpating the readme file with the latest changes * doc: URL update and contributing guidelines added * feat: version upgrade to 1.0.0
- Loading branch information
1 parent
9b4d860
commit df889c8
Showing
43 changed files
with
15,673 additions
and
1,757 deletions.
There are no files selected for viewing
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,13 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
], | ||
rules: { | ||
'no-unused-vars': 'off', | ||
} | ||
}; |
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,11 @@ | ||
name: verify-conventional-commits | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
conventional-commits-checker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: verify conventional commits | ||
uses: taskmedia/[email protected] | ||
|
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,18 @@ | ||
name: Publish Package to npmjs | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# Setup .npmrc file to publish to npm | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm run build && npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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
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 @@ | ||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', { targets: { node: 'current' } }], | ||
'@babel/preset-typescript', | ||
], | ||
}; |
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,27 @@ | ||
|
||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
|
||
node scripts/check-version.cjs | ||
|
||
# Build into dist and will publish the package from there, | ||
# so that src/resources/foo.ts becomes <package root>/resources/foo.js | ||
# This way importing from `"portkey-ai/apis/foo"` works | ||
# even with `"moduleResolution": "node"` | ||
|
||
rm -rf dist; mkdir dist | ||
|
||
# Copy src to dist/src and build from dist/src into dist, so that | ||
# the source map for index.js.map will refer to ./src/index.ts etc | ||
cp -rp src README.md dist | ||
# Copy the changelog and license files tp dist | ||
for file in LICENSE CHANGELOG.md; do | ||
if [ -e "${file}" ]; then cp "${file}" dist; fi | ||
done | ||
|
||
# this converts the export map paths for the dist directory | ||
# and does a few other minor things | ||
node scripts/make-dist-package-json.cjs > dist/package.json | ||
|
||
# build to .js/.mjs/.d.ts files | ||
npm exec tsc-multi |
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,35 +1,23 @@ | ||
import { Portkey } from "../src"; | ||
import { config } from 'dotenv'; | ||
import Portkey from '../src'; | ||
|
||
const client = new Portkey({ | ||
mode: "fallback", | ||
llms: [{ | ||
provider: "openai", | ||
virtual_key: "openai-v" | ||
}] | ||
}); | ||
config({ override: true }) | ||
|
||
const messages = [ | ||
{ content: "You want to talk in rhymes.", role: "system" }, | ||
{ content: "Hello, world!", role: "user" }, | ||
{ content: "Hello!", role: "assistant" }, | ||
{ | ||
content: | ||
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?", | ||
role: "user", | ||
}, | ||
] | ||
// Initialize the Portkey client | ||
const portkey = new Portkey({ | ||
apiKey: process.env["PORTKEY_API_KEY"] ?? "", | ||
baseURL: "https://api.portkeydev.com/v1", | ||
provider: "openai", | ||
virtualKey: process.env["OPENAI_VIRTUAL_KEY"] ?? "" | ||
}); | ||
|
||
const prompt = "write a story about a king" | ||
// Generate a text completion | ||
async function getTextCompletion() { | ||
const completion = await portkey.completions.create({ | ||
prompt: "Say this is a test", | ||
model: "gpt-3.5-turbo-instruct", | ||
}); | ||
|
||
async function main() { | ||
const params = {} | ||
const res = await client.chatCompletions.create({ messages, ...params, stream: true }) | ||
for await (const completion of res) { | ||
process.stdout.write(completion.choices[0]?.delta?.content || ""); | ||
} | ||
console.log(completion.choices[0]?.text); | ||
} | ||
|
||
main().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
getTextCompletion(); |
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,20 +1,20 @@ | ||
import { Portkey } from "../src"; | ||
// import { Portkey } from "../src"; | ||
|
||
const portkey = new Portkey({ | ||
apiKey:"your-portkey-api-key", | ||
mode: "fallback", | ||
llms: [ | ||
{ provider: "openai", virtual_key: "open-ai-key-1234", trace_id: "1234", metadata: { hello: "world" } }, | ||
{ provider: "cohere", virtual_key: "cohere-api-key-1234", trace_id: "1234", metadata: { hello: "world" } }, | ||
] | ||
}); | ||
// const portkey = new Portkey({ | ||
// apiKey:"your-portkey-api-key", | ||
// mode: "fallback", | ||
// llms: [ | ||
// { provider: "openai", virtual_key: "open-ai-key-1234", trace_id: "1234", metadata: { hello: "world" } }, | ||
// { provider: "cohere", virtual_key: "cohere-api-key-1234", trace_id: "1234", metadata: { hello: "world" } }, | ||
// ] | ||
// }); | ||
|
||
async function main() { | ||
const chatCompletion = await portkey.chatCompletions.create({ | ||
messages: [{ role: 'user', content: 'Say this is a test' }], | ||
}); | ||
// async function main() { | ||
// const chatCompletion = await portkey.chatCompletions.create({ | ||
// messages: [{ role: 'user', content: 'Say this is a test' }], | ||
// }); | ||
|
||
console.log(chatCompletion.choices); | ||
}; | ||
// console.log(chatCompletion.choices); | ||
// }; | ||
|
||
main(); | ||
// main(); |
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,16 +1,16 @@ | ||
import { Portkey } from "../src"; | ||
// import { Portkey } from "../src"; | ||
|
||
const portkey = new Portkey({ | ||
mode: "fallback" | ||
}); | ||
// const portkey = new Portkey({ | ||
// mode: "fallback" | ||
// }); | ||
|
||
async function main() { | ||
const chatCompletion = await portkey.generations.create({ | ||
promptId: "your-prompt-id", | ||
// variables: {hello: "world"} # Add variables if required | ||
}); | ||
// async function main() { | ||
// const chatCompletion = await portkey.generations.create({ | ||
// promptId: "your-prompt-id", | ||
// // variables: {hello: "world"} # Add variables if required | ||
// }); | ||
|
||
console.log(chatCompletion.data); | ||
}; | ||
// console.log(chatCompletion.data); | ||
// }; | ||
|
||
main(); | ||
// main(); |
Oops, something went wrong.