@golpoai/sdk 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -6
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +22 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -54,10 +54,9 @@ var Golpo = class {
|
|
|
54
54
|
/* ------------------------------------------------------------ *
|
|
55
55
|
* PUBLIC API
|
|
56
56
|
* ------------------------------------------------------------ */
|
|
57
|
-
async
|
|
57
|
+
async createPodcastJob(prompt, opts = {}) {
|
|
58
58
|
const {
|
|
59
59
|
uploads,
|
|
60
|
-
pollIntervalMs = 2e3,
|
|
61
60
|
concurrency = 8,
|
|
62
61
|
addMusic = false,
|
|
63
62
|
voiceInstructions,
|
|
@@ -87,8 +86,25 @@ var Golpo = class {
|
|
|
87
86
|
const { data } = await this.http.post("/generate", new URLSearchParams(fields), {
|
|
88
87
|
timeout: 6e4
|
|
89
88
|
});
|
|
90
|
-
return
|
|
91
|
-
|
|
89
|
+
return data.job_id;
|
|
90
|
+
}
|
|
91
|
+
async poll(jobId) {
|
|
92
|
+
const { data } = await this.http.get(`/status/${jobId}`);
|
|
93
|
+
if (data.status === "completed") {
|
|
94
|
+
return {
|
|
95
|
+
status: "completed",
|
|
96
|
+
podcastUrl: data.podcast_url,
|
|
97
|
+
podcastScript: data.podcast_script
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
return { status: "generating" };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async createPodcast(prompt, opts = {}) {
|
|
104
|
+
const { pollIntervalMs = 2e3, ...jobOpts } = opts;
|
|
105
|
+
const jobId = await this.createPodcastJob(prompt, jobOpts);
|
|
106
|
+
return this.pollUntilComplete(
|
|
107
|
+
jobId,
|
|
92
108
|
pollIntervalMs
|
|
93
109
|
).then((r) => ({
|
|
94
110
|
podcastUrl: r.podcast_url,
|
|
@@ -134,7 +150,7 @@ var Golpo = class {
|
|
|
134
150
|
const { data } = await this.http.post("/generate", new URLSearchParams(fields), {
|
|
135
151
|
timeout: 6e4
|
|
136
152
|
});
|
|
137
|
-
return this.
|
|
153
|
+
return this.pollUntilComplete(
|
|
138
154
|
data.job_id,
|
|
139
155
|
pollIntervalMs
|
|
140
156
|
).then((r) => ({
|
|
@@ -145,7 +161,7 @@ var Golpo = class {
|
|
|
145
161
|
/* ------------------------------------------------------------ *
|
|
146
162
|
* INTERNAL HELPERS
|
|
147
163
|
* ------------------------------------------------------------ */
|
|
148
|
-
async
|
|
164
|
+
async pollUntilComplete(jobId, interval) {
|
|
149
165
|
while (true) {
|
|
150
166
|
try {
|
|
151
167
|
const { data } = await this.http.get(`/status/${jobId}`);
|
package/dist/index.d.cts
CHANGED
|
@@ -34,6 +34,14 @@ interface CreateVideoOptions {
|
|
|
34
34
|
declare class Golpo {
|
|
35
35
|
private readonly http;
|
|
36
36
|
constructor(apiKey: string, baseUrl?: string);
|
|
37
|
+
createPodcastJob(prompt: string, opts?: CreatePodcastOptions): Promise<string>;
|
|
38
|
+
poll(jobId: string): Promise<{
|
|
39
|
+
status: 'generating';
|
|
40
|
+
} | {
|
|
41
|
+
status: 'completed';
|
|
42
|
+
podcastUrl: string;
|
|
43
|
+
podcastScript: string;
|
|
44
|
+
}>;
|
|
37
45
|
createPodcast(prompt: string, opts?: CreatePodcastOptions): Promise<{
|
|
38
46
|
podcastUrl: string;
|
|
39
47
|
podcastScript: string;
|
|
@@ -42,7 +50,7 @@ declare class Golpo {
|
|
|
42
50
|
videoUrl: string;
|
|
43
51
|
videoScript: string;
|
|
44
52
|
}>;
|
|
45
|
-
private
|
|
53
|
+
private pollUntilComplete;
|
|
46
54
|
private attachUploads;
|
|
47
55
|
private normalizeUpload;
|
|
48
56
|
private uploadToS3;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,14 @@ interface CreateVideoOptions {
|
|
|
34
34
|
declare class Golpo {
|
|
35
35
|
private readonly http;
|
|
36
36
|
constructor(apiKey: string, baseUrl?: string);
|
|
37
|
+
createPodcastJob(prompt: string, opts?: CreatePodcastOptions): Promise<string>;
|
|
38
|
+
poll(jobId: string): Promise<{
|
|
39
|
+
status: 'generating';
|
|
40
|
+
} | {
|
|
41
|
+
status: 'completed';
|
|
42
|
+
podcastUrl: string;
|
|
43
|
+
podcastScript: string;
|
|
44
|
+
}>;
|
|
37
45
|
createPodcast(prompt: string, opts?: CreatePodcastOptions): Promise<{
|
|
38
46
|
podcastUrl: string;
|
|
39
47
|
podcastScript: string;
|
|
@@ -42,7 +50,7 @@ declare class Golpo {
|
|
|
42
50
|
videoUrl: string;
|
|
43
51
|
videoScript: string;
|
|
44
52
|
}>;
|
|
45
|
-
private
|
|
53
|
+
private pollUntilComplete;
|
|
46
54
|
private attachUploads;
|
|
47
55
|
private normalizeUpload;
|
|
48
56
|
private uploadToS3;
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,9 @@ var Golpo = class {
|
|
|
17
17
|
/* ------------------------------------------------------------ *
|
|
18
18
|
* PUBLIC API
|
|
19
19
|
* ------------------------------------------------------------ */
|
|
20
|
-
async
|
|
20
|
+
async createPodcastJob(prompt, opts = {}) {
|
|
21
21
|
const {
|
|
22
22
|
uploads,
|
|
23
|
-
pollIntervalMs = 2e3,
|
|
24
23
|
concurrency = 8,
|
|
25
24
|
addMusic = false,
|
|
26
25
|
voiceInstructions,
|
|
@@ -50,8 +49,25 @@ var Golpo = class {
|
|
|
50
49
|
const { data } = await this.http.post("/generate", new URLSearchParams(fields), {
|
|
51
50
|
timeout: 6e4
|
|
52
51
|
});
|
|
53
|
-
return
|
|
54
|
-
|
|
52
|
+
return data.job_id;
|
|
53
|
+
}
|
|
54
|
+
async poll(jobId) {
|
|
55
|
+
const { data } = await this.http.get(`/status/${jobId}`);
|
|
56
|
+
if (data.status === "completed") {
|
|
57
|
+
return {
|
|
58
|
+
status: "completed",
|
|
59
|
+
podcastUrl: data.podcast_url,
|
|
60
|
+
podcastScript: data.podcast_script
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
return { status: "generating" };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async createPodcast(prompt, opts = {}) {
|
|
67
|
+
const { pollIntervalMs = 2e3, ...jobOpts } = opts;
|
|
68
|
+
const jobId = await this.createPodcastJob(prompt, jobOpts);
|
|
69
|
+
return this.pollUntilComplete(
|
|
70
|
+
jobId,
|
|
55
71
|
pollIntervalMs
|
|
56
72
|
).then((r) => ({
|
|
57
73
|
podcastUrl: r.podcast_url,
|
|
@@ -97,7 +113,7 @@ var Golpo = class {
|
|
|
97
113
|
const { data } = await this.http.post("/generate", new URLSearchParams(fields), {
|
|
98
114
|
timeout: 6e4
|
|
99
115
|
});
|
|
100
|
-
return this.
|
|
116
|
+
return this.pollUntilComplete(
|
|
101
117
|
data.job_id,
|
|
102
118
|
pollIntervalMs
|
|
103
119
|
).then((r) => ({
|
|
@@ -108,7 +124,7 @@ var Golpo = class {
|
|
|
108
124
|
/* ------------------------------------------------------------ *
|
|
109
125
|
* INTERNAL HELPERS
|
|
110
126
|
* ------------------------------------------------------------ */
|
|
111
|
-
async
|
|
127
|
+
async pollUntilComplete(jobId, interval) {
|
|
112
128
|
while (true) {
|
|
113
129
|
try {
|
|
114
130
|
const { data } = await this.http.get(`/status/${jobId}`);
|