together-ai 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.js +47 -0
- package/package.json +1 -1
- package/demo/test.ts +0 -25
package/README.md
CHANGED
|
@@ -44,4 +44,4 @@ This is a list of popular models that are supported.
|
|
|
44
44
|
|
|
45
45
|
## How it works
|
|
46
46
|
|
|
47
|
-
This library uses the [Together Inference Engine](https://www.together.ai/blog/together-inference-engine-v1), the world's fastest inference stack for open source LLMs. It calls the [Together.ai](<[together.ai](https://www.together.ai/)>) Inference API
|
|
47
|
+
This library uses the [Together Inference Engine](https://www.together.ai/blog/together-inference-engine-v1), the world's fastest inference stack for open source LLMs. It calls the [Together.ai](<[together.ai](https://www.together.ai/)>) Inference API, specifically their serverless endpoints product, to enable you to use OSS LLMs quickly and effeciently.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type ApiResponse = {
|
|
2
|
+
status: string;
|
|
3
|
+
prompt: string[];
|
|
4
|
+
model: string;
|
|
5
|
+
model_owner: string;
|
|
6
|
+
tags: Record<string, unknown>;
|
|
7
|
+
num_returns: number;
|
|
8
|
+
args: {
|
|
9
|
+
model: string;
|
|
10
|
+
prompt: string;
|
|
11
|
+
max_tokens: number;
|
|
12
|
+
stop: string;
|
|
13
|
+
temperature: number;
|
|
14
|
+
top_p: number;
|
|
15
|
+
top_k: number;
|
|
16
|
+
repetition_penalty: number;
|
|
17
|
+
};
|
|
18
|
+
subjobs: any[];
|
|
19
|
+
output: {
|
|
20
|
+
choices: {
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
request_id: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
declare class Together {
|
|
27
|
+
authApiKey: string | null;
|
|
28
|
+
constructor({ auth }: {
|
|
29
|
+
auth: string;
|
|
30
|
+
});
|
|
31
|
+
inference(model: string, { ...inputs }: {
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
}): Promise<ApiResponse>;
|
|
34
|
+
}
|
|
35
|
+
export default Together;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
class Together {
|
|
24
|
+
constructor({ auth }) {
|
|
25
|
+
this.authApiKey = null;
|
|
26
|
+
this.authApiKey = auth;
|
|
27
|
+
}
|
|
28
|
+
inference(model, _a) {
|
|
29
|
+
var inputs = __rest(_a, []);
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (!this.authApiKey) {
|
|
32
|
+
throw new Error('Auth key is not set!');
|
|
33
|
+
}
|
|
34
|
+
const res = yield fetch('https://api.together.xyz/inference', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
Authorization: 'Bearer ' + this.authApiKey,
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify(Object.assign({ model }, inputs)),
|
|
41
|
+
});
|
|
42
|
+
const data = yield res.json();
|
|
43
|
+
return data;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = Together;
|
package/package.json
CHANGED
package/demo/test.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Together from '../src';
|
|
2
|
-
|
|
3
|
-
const together = new Together({
|
|
4
|
-
auth: 'dd706fe7edbe3a935c46a939fa62a02443666e8b3959caeef70458da5d6cff7c',
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
const result = await together.inference(
|
|
9
|
-
'mistralai/Mistral-7B-Instruct-v0.1',
|
|
10
|
-
{
|
|
11
|
-
prompt: 'tell me about the history of the United States of America',
|
|
12
|
-
max_tokens: 300,
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
// console.log({ output });
|
|
17
|
-
console.log({ choices: result.output.choices[0].text });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
main();
|
|
21
|
-
|
|
22
|
-
// Together feedback
|
|
23
|
-
|
|
24
|
-
// language model was confusing, specify it better in dashboard
|
|
25
|
-
// Better defaults like max tokens
|