From 4dd21e7ee83309210de7be9212406b54f4c7318b Mon Sep 17 00:00:00 2001 From: Johnny Chadda Date: Fri, 2 Feb 2024 16:05:55 +0100 Subject: [PATCH] Fix imports --- examples/README.md | 4 +- examples/basic.ts | 6 +-- examples/package.json | 5 ++- examples/streaming.ts | 12 +++--- package-lock.json | 93 ------------------------------------------- package.json | 9 ++--- src/index.ts | 4 +- 7 files changed, 19 insertions(+), 114 deletions(-) diff --git a/examples/README.md b/examples/README.md index 11b7775..c7fd599 100644 --- a/examples/README.md +++ b/examples/README.md @@ -25,11 +25,11 @@ Run the examples: `basic.ts`: Simple example of how to use the Opper TypeScript SDK to send a message to a function and receive a response. ```shell -npx ts-node basic.ts +npm run basic ``` `streaming.ts`: Example of how to use the Opper TypeScript SDK to start a streaming connection to a function and receive messages. ```shell -npx ts-node streaming.ts +npm run streaming ``` diff --git a/examples/basic.ts b/examples/basic.ts index e34d34b..6d0ac8b 100644 --- a/examples/basic.ts +++ b/examples/basic.ts @@ -1,16 +1,16 @@ import { config } from 'dotenv'; -import { Message, ChatPayload } from 'opperai/types'; +import { types } from 'opperai'; import Client from 'opperai'; config(); const client = new Client(process.env.OPPER_API_KEY); -const message: Message = { +const message: types.Message = { role: "user", content: "Hello world! This is a test message." }; -const payload: ChatPayload = { +const payload: types.ChatPayload = { messages: [message] }; diff --git a/examples/package.json b/examples/package.json index b282ed7..8ae92b3 100644 --- a/examples/package.json +++ b/examples/package.json @@ -3,11 +3,12 @@ "version": "1.0.0", "description": "Examples of using the Opper SDK", "scripts": { - "dev": "tsc && node index.js" + "basic": "npx ts-node basic.ts", + "streaming": "npx ts-node streaming.ts" }, "dependencies": { "dotenv": "^16.4.1", - "opperai": "file:../dist" + "opperai": "^0.1.1" }, "devDependencies": { "@types/node": "^20.11.15", diff --git a/examples/streaming.ts b/examples/streaming.ts index df74081..b89ae6a 100644 --- a/examples/streaming.ts +++ b/examples/streaming.ts @@ -1,20 +1,20 @@ import { config } from 'dotenv'; -import { Message, ChatPayload, SSEStreamCallbacks } from 'opperai/types'; -import { SSEClient } from 'opperai/ssestream'; +import { types } from 'opperai'; +import { ssestream } from 'opperai'; config(); -const sseClient = new SSEClient(process.env.OPPER_API_KEY); +const sseClient = new ssestream.SSEClient(process.env.OPPER_API_KEY); -const message: Message = { +const message: types.Message = { role: "user", content: "Hello world! This is a test message." }; -const payload: ChatPayload = { +const payload: types.ChatPayload = { messages: [message] }; -const callbacks: SSEStreamCallbacks = { +const callbacks: types.SSEStreamCallbacks = { onMessage: (data: any) => { console.log('Received message:', data); }, diff --git a/package-lock.json b/package-lock.json index a05212d..f4d91f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,9 +8,6 @@ "name": "opperai", "version": "0.1.0", "license": "ISC", - "dependencies": { - "axios": "^1.6.7" - }, "devDependencies": { "@types/jest": "^29.5.11", "@typescript-eslint/eslint-plugin": "^6.20.0", @@ -1915,11 +1912,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, "node_modules/available-typed-arrays": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.6.tgz", @@ -1932,16 +1924,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/axios": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", - "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", - "dependencies": { - "follow-redirects": "^1.15.4", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -2290,17 +2272,6 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2431,14 +2402,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -3182,25 +3145,6 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, - "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -3210,19 +3154,6 @@ "is-callable": "^1.1.3" } }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4775,25 +4706,6 @@ "node": ">=8.6" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -5286,11 +5198,6 @@ "node": ">= 6" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/package.json b/package.json index 970a03a..525e9b9 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "opperai", - "version": "0.1.0", + "version": "0.1.1", "description": "", - "main": "dist/index.js", - "types": "dist/types.d.ts", + "main": "dist/index", + "types": "dist/types", "scripts": { "prepare": "npm run build", "build": "tsc", @@ -31,8 +31,5 @@ "ts-jest": "^29.1.2", "typescript": "^5.3.3", "web-streams-polyfill": "^3.3.2" - }, - "dependencies": { - "axios": "^1.6.7" } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 72fbde0..723ed62 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * as types from './types' -export * as ssestream from './ssestream' +export * as types from "./types"; +export * as ssestream from "./ssestream"; export { Client } from "./client"; export { Client as default } from "./client"; \ No newline at end of file