-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for the saved prompt generations
- Loading branch information
1 parent
a1293fb
commit d89a792
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Portkey } from "../src"; | ||
|
||
const portkey = new Portkey({ | ||
mode: "fallback" | ||
}); | ||
|
||
async function main() { | ||
const chatCompletion = await portkey.generations.create({ | ||
promptId: "your-prompt-id", | ||
// variables: {hello: "world"} # Add variables if required | ||
}); | ||
|
||
console.log(chatCompletion.data); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
export class Generations { } | ||
import { ModelParams } from "../_types/portkeyConstructs"; | ||
import { ApiResource } from "../apiResource"; | ||
import { APIPromise, RequestOptions } from "../baseClient"; | ||
|
||
export class Generations extends ApiResource { | ||
create( | ||
_body: GenerationsBody, | ||
opts?: RequestOptions | ||
): APIPromise<Generation> { | ||
const config = this.client.config || { | ||
mode: this.client.mode, | ||
options: this.client.llms | ||
} | ||
const body = { "variables": _body.variables } | ||
return this.post<Generation>(`/v1/prompts/${_body.promptId}/generate`, { body, ...opts }) | ||
} | ||
} | ||
|
||
export interface GenerationsBody extends ModelParams { | ||
promptId: string; | ||
variables?: Record<string, any> | ||
} | ||
|
||
export interface Generation { | ||
success: boolean, | ||
data: Record<string, any> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters