Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updated to support streaming#1151

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SilasMarvin merged 6 commits intomasterfromsilas-sdk-streaming
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Updated some signatures added some very basic tests and cleaned some …
…stuff up
  • Loading branch information
@SilasMarvin
SilasMarvin committedNov 8, 2023
commit231e2292e18deb867febc59b5427f39bd0ac4fdd
22 changes: 22 additions & 0 deletionspgml-sdks/pgml/javascript/tests/typescript-tests/test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,6 +280,28 @@ it("can order documents", async () => {
await collection.archive();
});

///////////////////////////////////////////////////
// Transformer Pipeline Tests /////////////////////
///////////////////////////////////////////////////

it("can transformer pipeline", async () => {
const t = pgml.newTransformerPipeline("text-generation");
const it = await t.transform(["AI is going to"], {max_new_tokens: 5});
expect(it.length).toBeGreaterThan(0)
});

it("can transformer pipeline stream", async () => {
const t = pgml.newTransformerPipeline("text-generation");
const it = await t.transform_stream("AI is going to", {max_new_tokens: 5});
let result = await it.next();
let output = [];
while (!result.done) {
output.push(result.value);
result = await it.next();
}
expect(output.length).toBeGreaterThan(0)
});

///////////////////////////////////////////////////
// Test migrations ////////////////////////////////
///////////////////////////////////////////////////
Expand Down
21 changes: 21 additions & 0 deletionspgml-sdks/pgml/python/tests/test.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -298,6 +298,27 @@ async def test_order_documents():
await collection.archive()


###################################################
## Transformer Pipeline Tests #####################
###################################################


@pytest.mark.asyncio
async def test_transformer_pipeline():
t = pgml.TransformerPipeline("text-generation")
it = await t.transform(["AI is going to"], {"max_new_tokens": 5})
assert (len(it)) > 0

@pytest.mark.asyncio
async def test_transformer_pipeline_stream():
t = pgml.TransformerPipeline("text-generation")
it = await t.transform_stream("AI is going to", {"max_new_tokens": 5})
total = []
async for c in it:
total.append(c)
assert (len(total)) > 0


###################################################
## Migration tests ################################
###################################################
Expand Down
1 change: 0 additions & 1 deletionpgml-sdks/pgml/src/languages/javascript.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,7 +83,6 @@ fn transform_stream_iterate_next(mut cx: FunctionContext) -> JsResult<JsPromise>
let s: Handle<JsBox<TransformerStreamArcMutex>> = this
.get(&mut cx, "s")
.expect("Error getting self in transformer_stream_iterate_next");
let mut b: &JsBox<TransformerStreamArcMutex> = &s;
let ts: &TransformerStreamArcMutex = &s;
let ts: TransformerStreamArcMutex = ts.clone();

Expand Down
4 changes: 2 additions & 2 deletionspgml-sdks/pgml/src/languages/python.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ impl TransformerStreamPython {
slf
}

fn __anext__<'p>(mutslf: PyRefMut<'_, Self>, py: Python<'p>) -> PyResult<Option<PyObject>> {
fn __anext__<'p>(slf: PyRefMut<'_, Self>, py: Python<'p>) -> PyResult<Option<PyObject>> {
let ts = slf.wrapped.clone();
let fut = pyo3_asyncio::tokio::future_into_py(py, async move {
let mut ts = ts.lock().await;
Expand DownExpand Up@@ -150,7 +150,7 @@ impl FromPyObject<'_> for PipelineSyncData {
}

impl FromPyObject<'_> for TransformerStream {
fn extract(ob: &PyAny) -> PyResult<Self> {
fn extract(_ob: &PyAny) -> PyResult<Self> {
panic!("We must implement this, but this is impossible to be reached")
}
}
Expand Down
8 changes: 4 additions & 4 deletionspgml-sdks/pgml/src/transformer_pipeline.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,7 +163,7 @@ impl TransformerPipeline {
#[instrument(skip(self))]
pub async fn transform_stream(
&self,
inputs: Vec<String>,
input: &str,
args: Option<Json>,
batch_size: Option<i32>,
) -> anyhow::Result<TransformerStream> {
Expand All@@ -173,10 +173,10 @@ impl TransformerPipeline {

let mut transaction = pool.begin().await?;
sqlx::query(
"DECLARE c CURSOR FOR SELECT pgml.transform_stream(task => $1,inputs => $2, args => $3)",
"DECLARE c CURSOR FOR SELECT pgml.transform_stream(task => $1,input => $2, args => $3)",
)
.bind(&self.task)
.bind(inputs)
.bind(input)
.bind(&args)
.execute(&mut *transaction)
.await?;
Expand DownExpand Up@@ -246,7 +246,7 @@ mod tests {
);
let mut stream = t
.transform_stream(
vec!["AI is going to".to_string()],
"AI is going to",
Some(
serde_json::json!({
"max_new_tokens": 10
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp