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

Update README.md #12

Merged
merged 1 commit into from
Jun 28, 2024
Merged
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
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ The REST API documentation can be found [on dev.writer.com](https://dev.writer.c

## Installation

To install the package from PyPI, use the following command:

```sh
# install from PyPI
pip install writer-sdk
```

Expand All @@ -39,7 +40,7 @@ chat = client.chat.chat(
"role": "user",
}
],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
)
print(chat.id)
```
Expand Down Expand Up @@ -72,7 +73,7 @@ async def main() -> None:
"role": "user",
}
],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
)
print(chat.id)

Expand All @@ -92,28 +93,32 @@ from writerai import Writer
client = Writer()

stream = client.completions.create(
model="palmyra-x-32k",
model="palmyra-x-002-instruct",
prompt="Hi, my name is",
stream=True,
)
for completion in stream:
print(completion.choices)
print(completion.value)
```

The async client uses the exact same interface.

```python
import asyncio
from writerai import AsyncWriter

client = AsyncWriter()

stream = await client.completions.create(
model="palmyra-x-32k",
prompt="Hi, my name is",
stream=True,
)
async for completion in stream:
print(completion.choices)
async def main() -> None:
stream = await client.completions.create(
model="palmyra-x-002-instruct",
prompt="Hi, my name is",
stream=True,
)
async for completion in stream:
print(completion.value)

asyncio.run(main())
```

## Using types
Expand Down Expand Up @@ -148,7 +153,7 @@ try:
"role": "user",
}
],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
)
except writerai.APIConnectionError as e:
print("The server could not be reached")
Expand Down Expand Up @@ -199,7 +204,7 @@ client.with_options(max_retries=5).chat.chat(
"role": "user",
}
],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
)
```

Expand Down Expand Up @@ -230,7 +235,7 @@ client.with_options(timeout=5.0).chat.chat(
"role": "user",
}
],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
)
```

Expand Down Expand Up @@ -275,7 +280,7 @@ response = client.chat.with_raw_response.chat(
"content": "string",
"role": "user",
}],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
)
print(response.headers.get('X-My-Header'))

Expand All @@ -301,7 +306,7 @@ with client.chat.with_streaming_response.chat(
"role": "user",
}
],
model="palmyra-x-32k",
model="palmyra-x-002-32k",
) as response:
print(response.headers.get("X-My-Header"))

Expand Down
Loading