Skip to content

Commit

Permalink
Merge pull request #82 from writer/release-please--branches--main--ch…
Browse files Browse the repository at this point in the history
…anges--next--components--writer-sdk
  • Loading branch information
ramedina86 authored Oct 9, 2024
2 parents 2236af2 + e373671 commit b6c7f90
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.0.0"
".": "1.1.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-2ad4cffb18a01119bca51bc468740407407dcf2aea29a0323e3c84662817b000.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-330636638e8423bfe0b00d5b5a5f605f9a64c59f27a3a45dd4c7ff88b9411c36.yml
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.1.0 (2024-10-09)

Full Changelog: [v1.0.0...v1.1.0](https://github.com/writer/writer-node/compare/v1.0.0...v1.1.0)

### Features

* **api:** api update ([#81](https://github.com/writer/writer-node/issues/81)) ([d61a1db](https://github.com/writer/writer-node/commit/d61a1db8343f7ca2d98de4ef66c16020b2d7144b))

## 1.0.0 (2024-10-09)

Full Changelog: [v0.5.0...v1.0.0](https://github.com/writer/writer-node/compare/v0.5.0...v1.0.0)
Expand Down
34 changes: 8 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ const client = new Writer({
});

async function main() {
const chat = await client.chat.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
});
const chat = await client.chat.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' });

console.log(chat.id);
}
Expand Down Expand Up @@ -73,10 +70,7 @@ const client = new Writer({
});

async function main() {
const params: Writer.ChatChatParams = {
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
};
const params: Writer.ChatChatParams = { messages: [{ role: 'user' }], model: 'palmyra-x-004' };
const chat: Writer.Chat = await client.chat.chat(params);
}

Expand All @@ -95,10 +89,7 @@ a subclass of `APIError` will be thrown:
```ts
async function main() {
const chat = await client.chat
.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
})
.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' })
.catch(async (err) => {
if (err instanceof Writer.APIError) {
console.log(err.status); // 400
Expand Down Expand Up @@ -142,7 +133,7 @@ const client = new Writer({
});

// Or, configure per-request:
await client.chat.chat({ messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }], model: 'palmyra-x-004' }, {
await client.chat.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' }, {
maxRetries: 5,
});
```
Expand All @@ -159,7 +150,7 @@ const client = new Writer({
});

// Override per-request:
await client.chat.chat({ messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }], model: 'palmyra-x-004' }, {
await client.chat.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' }, {
timeout: 5 * 1000,
});
```
Expand Down Expand Up @@ -212,19 +203,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
const client = new Writer();

const response = await client.chat
.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
})
.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' })
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: chat, response: raw } = await client.chat
.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
})
.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(chat.id);
Expand Down Expand Up @@ -332,10 +317,7 @@ const client = new Writer({

// Override per-request:
await client.chat.chat(
{
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
},
{ messages: [{ role: 'user' }], model: 'palmyra-x-004' },
{
httpAgent: new http.Agent({ keepAlive: false }),
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "writer-sdk",
"version": "1.0.0",
"version": "1.1.0",
"description": "The official TypeScript library for the Writer API",
"author": "Writer <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/resources/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,13 @@ export interface ChatChatParamsBase {

export namespace ChatChatParams {
export interface Message {
content: string;
role: 'user' | 'assistant' | 'system' | 'tool';

role: 'user' | 'assistant' | 'system';
content?: string;

name?: string;

tool_id?: string;
}

/**
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 = '1.0.0'; // x-release-please-version
export const VERSION = '1.1.0'; // x-release-please-version
14 changes: 9 additions & 5 deletions tests/api-resources/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ const client = new Writer({

describe('resource chat', () => {
test('chat: only required params', async () => {
const responsePromise = client.chat.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x-004',
});
const responsePromise = client.chat.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -25,7 +22,14 @@ describe('resource chat', () => {

test('chat: required and optional params', async () => {
const response = await client.chat.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user', name: 'name' }],
messages: [
{
role: 'user',
content: 'Write a memo summarizing this earnings report.',
name: 'name',
tool_id: 'tool_id',
},
],
model: 'palmyra-x-004',
logprobs: true,
max_tokens: 0,
Expand Down

0 comments on commit b6c7f90

Please sign in to comment.