Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.6.0-alpha.7 #45

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ jobs:

- name: Check types
run: ./scripts/lint

build:
name: build
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: yarn install

- name: Check build
run: ./scripts/build
test:
name: test
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.6.0-alpha.6"
".": "0.6.0-alpha.7"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-1fe74361c29a31a4c44057fb30a8ddb72a635d9cd4b37e64a8bd668c3c964326.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-49d420a0d032aa57d5da9e8ef21bd80ca55cac0c21161bf3a20e0fca38db44ff.yml
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.6.0-alpha.7 (2024-08-28)

Full Changelog: [v0.6.0-alpha.6...v0.6.0-alpha.7](https://github.com/togethercomputer/together-typescript/compare/v0.6.0-alpha.6...v0.6.0-alpha.7)

### Features

* **api:** OpenAPI spec update via Stainless API ([#44](https://github.com/togethercomputer/together-typescript/issues/44)) ([5fbcdd8](https://github.com/togethercomputer/together-typescript/commit/5fbcdd8eb359ccd8f0bceb34d8d424c96e3e4268))


### Bug Fixes

* chat completion streaming when enabling logprobs ([cad72ef](https://github.com/togethercomputer/together-typescript/commit/cad72ef78213cbaa4497c7358b65e94c4b15f99a))


### Chores

* **ci:** check for build errors ([#46](https://github.com/togethercomputer/together-typescript/issues/46)) ([ef2541c](https://github.com/togethercomputer/together-typescript/commit/ef2541c70dfee841373dfe16a5c866ebcf382822))

## 0.6.0-alpha.6 (2024-08-26)

Full Changelog: [v0.6.0-alpha.5...v0.6.0-alpha.6](https://github.com/togethercomputer/together-typescript/compare/v0.6.0-alpha.5...v0.6.0-alpha.6)
Expand Down
5 changes: 3 additions & 2 deletions examples/chat-completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ async function main() {
.stream({
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
messages: [{ role: 'user', content: 'Say this is a test' }],
logprobs: 1,
})
.on('message', (msg) => console.log(msg))
.on('content', (diff) => process.stdout.write(diff));

for await (const chunk of runner) {
// Note: comment out the next line to print chunks as they are streamed from the API
// console.log('chunk', chunk);
console.log('chunk', chunk);
}

const result = await runner.finalMessage();
console.log(result);
console.log({ result });
}

main();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "together-ai",
"version": "0.6.0-alpha.6",
"version": "0.6.0-alpha.7",
"description": "The official TypeScript library for the Together API",
"author": "Together <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
24 changes: 15 additions & 9 deletions src/lib/ChatCompletionStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,26 @@ export class ChatCompletionStream
for (const { delta, finish_reason, index, logprobs = null, ...other } of chunk.choices) {
let choice = snapshot.choices[index];
if (!choice) {
choice = snapshot.choices[index] = { finish_reason, index, message: {}, logprobs, ...other };
choice = snapshot.choices[index] = {
finish_reason,
index,
message: {},
logprobs: { token_ids: [], token_logprobs: [], tokens: [] },
...other,
};
}

if (logprobs) {
console.log({ logprobs });
if (!choice.logprobs) {
choice.logprobs = Object.assign({}, logprobs);
} else {
const { content, ...rest } = logprobs;
Object.assign(choice.logprobs, rest);
if (content) {
choice.logprobs.content ??= [];
choice.logprobs.content.push(...content);
}
choice.logprobs = { token_ids: [], token_logprobs: [], tokens: [] };
}
choice.logprobs.token_ids ??= [];
choice.logprobs.token_ids.push(delta.token_id ?? null);
choice.logprobs.token_logprobs ??= [];
choice.logprobs.token_logprobs.push(logprobs ?? null);
choice.logprobs.tokens ??= [];
choice.logprobs.tokens.push(delta.content ?? null);
}

if (finish_reason) choice.finish_reason = finish_reason;
Expand Down
6 changes: 3 additions & 3 deletions src/resources/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export interface LogProbs {
/**
* List of token IDs corresponding to the logprobs
*/
token_ids?: Array<number>;
token_ids?: Array<number | null>;

/**
* List of token log probabilities
*/
token_logprobs?: Array<number>;
token_logprobs?: Array<number | null>;

/**
* List of token strings
*/
tokens?: Array<string>;
tokens?: Array<string | null>;
}

export interface ToolChoice {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export namespace ModelListResponse {

object: string;

type: 'chat' | 'language' | 'code' | 'image' | 'embedding' | 'moderation';
type: 'chat' | 'language' | 'code' | 'image' | 'embedding' | 'moderation' | 'rerank';

context_length?: number;

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.6.0-alpha.6'; // x-release-please-version
export const VERSION = '0.6.0-alpha.7'; // x-release-please-version