godly-ai
Version:
Personlize your OpenAI completions with custom context.
696 lines • 77.8 kB
JavaScript
"use strict";
/* tslint:disable */
/* eslint-disable */
/**
* Godly Api
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GodlyApi = exports.GodlyApiFactory = exports.GodlyApiFp = exports.GodlyApiAxiosParamCreator = exports.MessageRoleEnum = void 0;
var axios_1 = require("axios");
// Some imports not used depending on template conditions
// @ts-ignore
var common_1 = require("./common");
// @ts-ignore
var base_1 = require("./base");
exports.MessageRoleEnum = {
System: 'system',
User: 'user',
Assistant: 'assistant'
};
/**
* GodlyApi - axios parameter creator
* @export
*/
var GodlyApiAxiosParamCreator = function (configuration) {
var _this = this;
return {
/**
* Creates multiple new context items in a batch. Limited to 100 context items per batch. The context items are indexed for appending into related prompts using the with-context endpoint. You can optionally add references and types to the context item.
* @summary Batch Create Context Items
* @param {string} projectId ID of project
* @param {Array<CreateContextItemRequest>} [createContextItemRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
batchCreateContextItems: function (projectId, createContextItemRequest, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('batchCreateContextItems', 'projectId', projectId);
localVarPath = "/projects/{projectId}/context-items/batch"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
localVarHeaderParameter['Content-Type'] = 'application/json';
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(createContextItemRequest, localVarRequestOptions, configuration);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* This endpoint is the same as the openAI API, but it uses context to improve the results. See https://platform.openai.com/docs/api-reference/chat/create. ### Context Control The only difference in the request params is that you can manage matched context items with `max_matches`, `max_total_matches_tokens`, `max_single_match_tokens` and `min_match_relevancy_score` ###Filter context using tags You can use the `tags` and `tags_exlude` params to only find context item matches that have/don\'t have the specifiec tags. ### Context Placement By default the relevant context will be added as a `system` user message. If you need more fine grained control you can include the string `[context]` within any of the messages and the context will be add inline. ### Context Items Prompt By default Godly will use the `content` of the last `message` to retrieve relevant context items. However to improve accuracy you can pass the original request with the `context_search_prompt` param and Godly will use that for context item search. ### Response The only difference to OpenAI in the response is that it returns `matches` which is an array of context items that were applied. You can use this for debugging or improving the user experience by providing reference responses.
* @summary GPT3 chat completion with context.
* @param {string} projectId ID of project
* @param {ChatCompletionWithContextRequest} [chatCompletionWithContextRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
chatCompletionWithContext: function (projectId, chatCompletionWithContextRequest, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('chatCompletionWithContext', 'projectId', projectId);
localVarPath = "/with-context/{projectId}/chatCompletions"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
localVarHeaderParameter['Content-Type'] = 'application/json';
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(chatCompletionWithContextRequest, localVarRequestOptions, configuration);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* This endpoint is the same as the openAI API, but it uses context to improve the results. See https://platform.openai.com/docs/api-reference/completions/create. ### Context Control The only difference in the request params is that you can manage matched context items with `max_matches`, `max_total_matches_tokens`, `max_single_match_tokens` and `min_match_relevancy_score` ###Filter context using tags You can use the `tags` and `tags_exlude` params to only find context item matches that have/don\'t have the specifiec tags. ### Context Placement By default the relevant context will be prepended to the prompt. If you need more fine grained control you can include the string `[context]` within the prompt and the context will be added inline. ### Context Items Prompt By default Godly will use the `prompt` to retrieve relevant context items. However if you engineer your `prompt` it could include some language confuses the semantic search. To improve accuracy you can pass the original request with the `context_search_prompt` param and Godly will use that for context item search. ### Response The only difference to OpenAI in the response is that it returns `matches` which is an array of context items that were used in the `prompt` (or `context_search_prompt`). You can use this for debugging or improving the user experience by providing reference responses.
* @summary GPT3 completion with context.
* @param {string} projectId ID of project
* @param {CompletionWithContextRequest} [completionWithContextRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
completionWithContext: function (projectId, completionWithContextRequest, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('completionWithContext', 'projectId', projectId);
localVarPath = "/with-context/{projectId}/completions"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
localVarHeaderParameter['Content-Type'] = 'application/json';
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(completionWithContextRequest, localVarRequestOptions, configuration);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Creates a new context item. The context items are indexed for appending into related prompts using the with-context endpoint. You can optionally add references and types to the context item.
* @summary Create a new Context Item
* @param {string} projectId ID of project
* @param {number} [maxTokens] The maximum amount of tokens for the context item. If the context item exceeds this amount, it will fail unless include the exceedTokensStrategy to specify the result. Defaults to 800.
* @param {'fail' | 'split' | 'truncate'} [exceedTokensStrategy] How to handle context items that exceed the maxTokens. Defaults to \'fail\'. `fail` will return an error, `split` will split the context item into multiple context items with none larger than the maxTokens, and `truncate` will truncate the context item to the maxTokens.
* @param {CreateContextItemRequest} [createContextItemRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createContextItem: function (projectId, maxTokens, exceedTokensStrategy, createContextItemRequest, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('createContextItem', 'projectId', projectId);
localVarPath = "/projects/{projectId}/context-items"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
if (maxTokens !== undefined) {
localVarQueryParameter['maxTokens'] = maxTokens;
}
if (exceedTokensStrategy !== undefined) {
localVarQueryParameter['exceedTokensStrategy'] = exceedTokensStrategy;
}
localVarHeaderParameter['Content-Type'] = 'application/json';
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(createContextItemRequest, localVarRequestOptions, configuration);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Creates a new project for the user. The project is used to group context items.
* @summary Create a new Project
* @param {CreateProjectRequest} [createProjectRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createProject: function (createProjectRequest, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
localVarPath = "/projects";
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
localVarHeaderParameter['Content-Type'] = 'application/json';
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(createProjectRequest, localVarRequestOptions, configuration);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Deletes a context item from the user\'s project. This will remove the item from the project entirely.
* @summary Delete a Context Item
* @param {string} projectId ID of project
* @param {string} itemId ID of context item
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteContextItem: function (projectId, itemId, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('deleteContextItem', 'projectId', projectId);
// verify required parameter 'itemId' is not null or undefined
(0, common_1.assertParamExists)('deleteContextItem', 'itemId', itemId);
localVarPath = "/projects/{projectId}/context-items/{itemId}"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)))
.replace("{".concat("itemId", "}"), encodeURIComponent(String(itemId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'DELETE' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Returns a list of all the context items in a project.
* @summary Get all Context Items
* @param {string} projectId ID of project
* @param {string} prompt The prompt to use for a semantic search for related context items
* @param {number} [limit] The number of items to return. Defaults to 6
* @param {Array<string>} [tags] The tags a context item must have to be returned. Context items must match ANY of the tags. Multiple tags can be specified with querystring multiple tags method, `tags=tag1&tags=tag2`
* @param {Array<string>} [tagsAnd] The tags a context item must have to be returned. Context items must match ALL of the tags. Multiple tags can be specified with querystring multiple tags method, `tagsAnd=tag1&tagsAnd=tag2`
* @param {Array<string>} [tagsExclude] The tags a context item must NOT have to be returned. Multiple tags can be specified with querystring multiple tags method, `tags=tag1&tags=tag2`
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getContextItems: function (projectId, prompt, limit, tags, tagsAnd, tagsExclude, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('getContextItems', 'projectId', projectId);
// verify required parameter 'prompt' is not null or undefined
(0, common_1.assertParamExists)('getContextItems', 'prompt', prompt);
localVarPath = "/projects/{projectId}/context-items"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'GET' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
if (prompt !== undefined) {
localVarQueryParameter['prompt'] = prompt;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (tags) {
localVarQueryParameter['tags'] = tags;
}
if (tagsAnd) {
localVarQueryParameter['tagsAnd'] = tagsAnd;
}
if (tagsExclude) {
localVarQueryParameter['tagsExclude'] = tagsExclude;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Returns a single project by ID
* @summary Get Single Project
* @param {string} projectId ID of project
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getProjectById: function (projectId, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('getProjectById', 'projectId', projectId);
localVarPath = "/projects/{projectId}"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'GET' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Returns a list of all the projects the user has access to.
* @summary Get all Projects
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getProjects: function (options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
localVarPath = "/projects";
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'GET' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
/**
* Updates a context item. This is a full update meaning whatever you provide will fully replace the existing context item.Including generating a new embedding for the updated text
* @summary Update a Context Item
* @param {string} projectId ID of project
* @param {string} itemId ID of context item
* @param {ContextItemUpdate} [contextItemUpdate]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateContextItem: function (projectId, itemId, contextItemUpdate, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// verify required parameter 'projectId' is not null or undefined
(0, common_1.assertParamExists)('updateContextItem', 'projectId', projectId);
// verify required parameter 'itemId' is not null or undefined
(0, common_1.assertParamExists)('updateContextItem', 'itemId', itemId);
localVarPath = "/projects/{projectId}/context-items/{itemId}"
.replace("{".concat("projectId", "}"), encodeURIComponent(String(projectId)))
.replace("{".concat("itemId", "}"), encodeURIComponent(String(itemId)));
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
if (configuration) {
baseOptions = configuration.baseOptions;
}
localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
localVarHeaderParameter = {};
localVarQueryParameter = {};
// authentication BearerKey required
// http bearer authentication required
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
case 1:
// authentication BearerKey required
// http bearer authentication required
_a.sent();
localVarHeaderParameter['Content-Type'] = 'application/json';
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(contextItemUpdate, localVarRequestOptions, configuration);
return [2 /*return*/, {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
}];
}
});
});
},
};
};
exports.GodlyApiAxiosParamCreator = GodlyApiAxiosParamCreator;
/**
* GodlyApi - functional programming interface
* @export
*/
var GodlyApiFp = function (configuration) {
var localVarAxiosParamCreator = (0, exports.GodlyApiAxiosParamCreator)(configuration);
return {
/**
* Creates multiple new context items in a batch. Limited to 100 context items per batch. The context items are indexed for appending into related prompts using the with-context endpoint. You can optionally add references and types to the context item.
* @summary Batch Create Context Items
* @param {string} projectId ID of project
* @param {Array<CreateContextItemRequest>} [createContextItemRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
batchCreateContextItems: function (projectId, createContextItemRequest, options) {
return __awaiter(this, void 0, void 0, function () {
var localVarAxiosArgs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, localVarAxiosParamCreator.batchCreateContextItems(projectId, createContextItemRequest, options)];
case 1:
localVarAxiosArgs = _a.sent();
return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
}
});
});
},
/**
* This endpoint is the same as the openAI API, but it uses context to improve the results. See https://platform.openai.com/docs/api-reference/chat/create. ### Context Control The only difference in the request params is that you can manage matched context items with `max_matches`, `max_total_matches_tokens`, `max_single_match_tokens` and `min_match_relevancy_score` ###Filter context using tags You can use the `tags` and `tags_exlude` params to only find context item matches that have/don\'t have the specifiec tags. ### Context Placement By default the relevant context will be added as a `system` user message. If you need more fine grained control you can include the string `[context]` within any of the messages and the context will be add inline. ### Context Items Prompt By default Godly will use the `content` of the last `message` to retrieve relevant context items. However to improve accuracy you can pass the original request with the `context_search_prompt` param and Godly will use that for context item search. ### Response The only difference to OpenAI in the response is that it returns `matches` which is an array of context items that were applied. You can use this for debugging or improving the user experience by providing reference responses.
* @summary GPT3 chat completion with context.
* @param {string} projectId ID of project
* @param {ChatCompletionWithContextRequest} [chatCompletionWithContextRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
chatCompletionWithContext: function (projectId, chatCompletionWithContextRequest, options) {
return __awaiter(this, void 0, void 0, function () {
var localVarAxiosArgs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, localVarAxiosParamCreator.chatCompletionWithContext(projectId, chatCompletionWithContextRequest, options)];
case 1:
localVarAxiosArgs = _a.sent();
return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
}
});
});
},
/**
* This endpoint is the same as the openAI API, but it uses context to improve the results. See https://platform.openai.com/docs/api-reference/completions/create. ### Context Control The only difference in the request params is that you can manage matched context items with `max_matches`, `max_total_matches_tokens`, `max_single_match_tokens` and `min_match_relevancy_score` ###Filter context using tags You can use the `tags` and `tags_exlude` params to only find context item matches that have/don\'t have the specifiec tags. ### Context Placement By default the relevant context will be prepended to the prompt. If you need more fine grained control you can include the string `[context]` within the prompt and the context will be added inline. ### Context Items Prompt By default Godly will use the `prompt` to retrieve relevant context items. However if you engineer your `prompt` it could include some language confuses the semantic search. To improve accuracy you can pass the original request with the `context_search_prompt` param and Godly will use that for context item search. ### Response The only difference to OpenAI in the response is that it returns `matches` which is an array of context items that were used in the `prompt` (or `context_search_prompt`). You can use this for debugging or improving the user experience by providing reference responses.
* @summary GPT3 completion with context.
* @param {string} projectId ID of project
* @param {CompletionWithContextRequest} [completionWithContextRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
completionWithContext: function (projectId, completionWithContextRequest, options) {
return __awaiter(this, void 0, void 0, function () {
var localVarAxiosArgs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, localVarAxiosParamCreator.completionWithContext(projectId, completionWithContextRequest, options)];
case 1:
localVarAxiosArgs = _a.sent();
return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
}
});
});
},
/**
* Creates a new context item. The context items are indexed for appending into related prompts using the with-context endpoint. You can optionally add references and types to the context item.
* @summary Create a new Context Item
* @param {string} projectId ID of project
* @param {number} [maxTokens] The maximum amount of tokens for the context item. If the context item exceeds this amount, it will fail unless include the exceedTokensStrategy to specify the result. Defaults to 800.
* @param {'fail' | 'split' | 'truncate'} [exceedTokensStrategy] How to handle context items that exceed the maxTokens. Defaults to \'fail\'. `fail` will return an error, `split` will split the context item into multiple context items with none larger than the maxTokens, and `truncate` will truncate the context item to the maxTokens.
* @param {CreateContextItemRequest} [createContextItemRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createContextItem: function (projectId, maxTokens, exceedTokensStrategy, createContextItemRequest, options) {
return __awaiter(this, void 0, void 0, function () {
var localVarAxiosArgs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, localVarAxiosParamCreator.createContextItem(projectId, maxTokens, exceedTokensStrategy, createContextItemRequest, options)];
case 1:
localVarAxiosArgs = _a.sent();
return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
}
});
});
},
/**
* Creates a new project for the user. The project is used to group context items.
* @summary Create a new Project
* @param {CreateProjectRequest} [createProjectRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createProject: function (createProjectRequest, options) {
return __awaiter(this, void 0, void 0, function () {
var localVarAxiosArgs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, localVarAxiosParamCreator.createProject(createProjectRequest, options)];
case 1:
localVarAxiosArgs = _a.sent();
return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
}
});
});
},
/**
* Deletes a context item from the user\'s project. This will remove the item from the project entirely.
* @summary Delete a Context Item
* @param {string} projectId ID of project
* @param {string} itemId ID of context item
* @param {*} [o