Skip to content

Commit 28b60a0

Browse files
committed
Release sdk-py 0.2.3 feat: use model generate and stream text
1 parent ca0c30f commit 28b60a0

10 files changed

Lines changed: 232 additions & 1246 deletions

File tree

docs/pages/sdk.mdx

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ embedbase_key = "<get your key here: https://app.embedbase.xyz>"
6262
embedbase = EmbedbaseClient(embedbase_url, embedbase_key)
6363
```
6464

65-
In an **async** context, you can use the `EmbedbaseAsyncClient` class instead.
66-
This class provides the same methods as `EmbedbaseClient`, but they are all asynchronous.
67-
```python copy
68-
from embedbase_client import EmbedbaseAsyncClient
69-
```
70-
71-
Remember to use `await` when calling methods on `EmbedbaseAsyncClient` objects.
72-
73-
Learn more about asynchronous Python [here](https://docs.python.org/3/library/asyncio.html).
7465
</Tab>
7566
</Tabs>
7667

@@ -80,8 +71,8 @@ Learn more about asynchronous Python [here](https://docs.python.org/3/library/as
8071

8172
### Generating text
8273

83-
Under the hood, generating text use OpenAI models. If you are interested in using
84-
other models, such as open-source ones, please contact us.
74+
Embedbase supports 9+ LLMs, including OpenAI, Google, and many state-of-the-art open source ones. If you are interested in using
75+
other models, please contact us.
8576

8677
Remember that this count in your playground usage,
8778
for more information head to the [billing page](https://app.embedbase.xyz/dashboard/pricing).
@@ -109,36 +100,21 @@ You can list models with `await embedbase.getModels()`
109100

110101
</Tab>
111102
<Tab>
112-
```python copy
113-
data = embedbase.dataset(dataset_id).create_context("my-context")
114-
question = 'How do I use Embedbase?'
115-
# ⚠️ note here that the prompt depends
116-
# on the used embedder in embedbase.
117-
# See `create_context` doc for details. ⚠️
118-
prompt = (
119-
"Based on the following context:\n"
120-
+ "\n".join(data)
121-
+ f"\nAnswer the user's question: {question}"
122-
)
123-
for r in embedbase.generate(prompt):
124-
print(r)
125-
# You, need, to, query, Notion, API, like, so:, ...
126-
```
103+
```py copy
104+
data = embedbase.dataset('my-documentation').create_context('my-context')
127105

128-
You can also send the history, like in [OpenAI API](https://platform.openai.com/docs/guides/chat/introduction):
106+
const question = 'How do I use Embedbase?'
107+
const prompt = """Based on the following context:\n{'\n'.join(data)}\nAnswer the user's question: {question}"""
129108

130-
```python copy
131-
history = [
132-
{"role": "system", "content": "You are a helpful assistant that teach how to use Embedbase"},
133-
{"role": "user", "content": "How can I connect my data to LLMs using Embedbase?"},
134-
{"role": "assistant", "content": "You can pip install embedbase-client, write two lines of code, and..."},
135-
{"role": "user", "content": "how can i do this with my notion pages now using their api?"},
136-
]
109+
for res of embedbase.use_model('openai/gpt-3.5-turbo').stream_text(prompt):
110+
print(res)
111+
# You, can, use, ...
137112

138-
for r in embedbase.generate(prompt, history):
139-
print(r)
140-
# You, need, to, query, Notion, API, like, so:, ...
113+
# or res = embedbase.use_model('openai/gpt-3.5-turbo').generate_text(prompt)
141114
```
115+
116+
You can list models with `embedbase.get_models()`
117+
142118
</Tab>
143119
</Tabs>
144120

@@ -471,7 +447,7 @@ updated_docs = [
471447
Document(id="document1", data="Updated Document 1"),
472448
Document(id="document2", data="Updated Document 2"),
473449
]
474-
updated_results = await async_ds.update(updated_docs)
450+
updated_results = embedbase.dataset('my-dataset').update(updated_docs)
475451
```
476452
This will update the data for the documents with the given IDs, while keeping all other fields intact.
477453

sdk/embedbase-py/embedbase_client/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ def get_version() -> str:
1212

1313
version: str = get_version()
1414

15-
from .async_client import EmbedbaseAsyncClient
16-
from .sync_client import EmbedbaseClient
15+
from .client import EmbedbaseClient

0 commit comments

Comments
 (0)