Skip to content

Commit

Permalink
return pl id when streaming (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
abubakarsohail authored May 7, 2024
1 parent 77cd9a4 commit e2fd939
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "promptlayer",
"license": "MIT",
"version": "0.0.19",
"version": "0.0.20",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
Expand Down
11 changes: 9 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,22 @@ async function* proxyGenerator<Item>(
) {
const results = [];
for await (const value of generator) {
yield value;
yield body.return_pl_id ? [value, null] : value;
results.push(value);
}
const request_response = cleaned_result(results, body.function_name);
await promptLayerApiRequest({
const response = await promptLayerApiRequest({
...body,
request_response,
request_end_time: new Date().toISOString(),
});
if (response) {
if (body.return_pl_id) {
const request_id = (response as any)[1];
const lastResult = results.at(-1);
yield [lastResult, request_id];
}
}
}

const warnOnBadResponse = (request_response: any, main_message: string) => {
Expand Down

0 comments on commit e2fd939

Please sign in to comment.