@restnfeel/agentc-starter-kit
Version:
한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템
92 lines (89 loc) • 3.07 kB
JavaScript
import { APIResource } from '../../../resource.js';
import { isRequestOptions } from '../../../core.js';
import { AssistantStream } from '../../../lib/AssistantStream.js';
import { Messages, MessagesPage } from './messages.js';
import { Runs, RunsPage } from './runs/runs.js';
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
/**
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
class Threads extends APIResource {
constructor() {
super(...arguments);
this.runs = new Runs(this._client);
this.messages = new Messages(this._client);
}
create(body = {}, options) {
if (isRequestOptions(body)) {
return this.create({}, body);
}
return this._client.post('/threads', {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
}
/**
* Retrieves a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadId, options) {
return this._client.get(`/threads/${threadId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
}
/**
* Modifies a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(threadId, body, options) {
return this._client.post(`/threads/${threadId}`, {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
}
/**
* Delete a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
del(threadId, options) {
return this._client.delete(`/threads/${threadId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
}
createAndRun(body, options) {
return this._client.post('/threads/runs', {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
stream: body.stream ?? false,
});
}
/**
* A helper to create a thread, start a run and then poll for a terminal state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async createAndRunPoll(body, options) {
const run = await this.createAndRun(body, options);
return await this.runs.poll(run.thread_id, run.id, options);
}
/**
* Create a thread and stream the run back
*/
createAndRunStream(body, options) {
return AssistantStream.createThreadAssistantStream(body, this._client.beta.threads, options);
}
}
Threads.Runs = Runs;
Threads.RunsPage = RunsPage;
Threads.Messages = Messages;
Threads.MessagesPage = MessagesPage;
export { Threads };
//# sourceMappingURL=threads.js.map