UNPKG

godly-ai

Version:

Personlize your OpenAI completions with custom context.

1,174 lines (1,104 loc) 88.5 kB
/* 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. */ import { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; /** * * @export * @interface ChatCompletionWithContext200Response */ export interface ChatCompletionWithContext200Response { /** * Unique identifier for the completion * @type {string} * @memberof ChatCompletionWithContext200Response */ 'id'?: string; /** * Object type, chat.completion * @type {string} * @memberof ChatCompletionWithContext200Response */ 'object'?: string; /** * Timestamp of when the completion was created * @type {number} * @memberof ChatCompletionWithContext200Response */ 'created'?: number; /** * * @type {Array<ChatCompletionWithContext200ResponseChoicesInner>} * @memberof ChatCompletionWithContext200Response */ 'choices'?: Array<ChatCompletionWithContext200ResponseChoicesInner>; /** * * @type {CompletionWithContext200ResponseUsage} * @memberof ChatCompletionWithContext200Response */ 'usage'?: CompletionWithContext200ResponseUsage; /** * * @type {Array<ContextItemMatch>} * @memberof ChatCompletionWithContext200Response */ 'matches'?: Array<ContextItemMatch>; } /** * * @export * @interface ChatCompletionWithContext200ResponseChoicesInner */ export interface ChatCompletionWithContext200ResponseChoicesInner { /** * The index of the chosen prompt * @type {number} * @memberof ChatCompletionWithContext200ResponseChoicesInner */ 'index'?: number; /** * * @type {Message} * @memberof ChatCompletionWithContext200ResponseChoicesInner */ 'message'?: Message; /** * The reason the completion was finished. One of: length, max_tokens, stop_sequence, manual, model_failure * @type {string} * @memberof ChatCompletionWithContext200ResponseChoicesInner */ 'finish_reason'?: string; } /** * The request body is the same as the request to openAI API. See https://platform.openai.com/docs/api-reference/chat/create * @export * @interface ChatCompletionWithContextRequest */ export interface ChatCompletionWithContextRequest { /** * The maximum number of context items to match. Defaults to 6. This can also be affected by max_tokens and max_match_tokens. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'max_matches'?: number; /** * The maximum amount of tokens the matched context items should use. If your max_match_tokens is set to 250 and you have 3 matches that are 100 tokens in size, it will return the first 2 matches. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'max_total_matches_tokens'?: number; /** * The maximum amount of tokens each individual match can include. Any matches that are larger than this will be excluded. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'max_single_match_tokens'?: number; /** * The minimum relevancy score for context item matches. Defaults to 0.75. This is a number between 0 and 1. The higher the number the more strict the matches will be. The playground in the dashboard is useful for finding optimal match scores * @type {number} * @memberof ChatCompletionWithContextRequest */ 'min_match_relevancy_score'?: number; /** * Only match context items that have ANY of these tags. This will perfom like an OR query tht will match on any of the tags. * @type {Array<string>} * @memberof ChatCompletionWithContextRequest */ 'tags'?: Array<string>; /** * Only match context items that have ALL of these tags. This will perfom like an AND query tht will match on context items that have all the tags. * @type {Array<string>} * @memberof ChatCompletionWithContextRequest */ 'tags_and'?: Array<string>; /** * Tags to exclude context items by. Any context items with any of the tags will be excluded. * @type {Array<string>} * @memberof ChatCompletionWithContextRequest */ 'tags_exclude'?: Array<string>; /** * A unique identifier for user completions. This can be used for rate limiting and debugging log events. * @type {string} * @memberof ChatCompletionWithContextRequest */ 'sessionId'?: string; /** * A prompt to use when searching for context items. This is useful if you want to use a different prompt than the one you use for the completion. If you don\'t provide this, the prompt will be used for both. * @type {string} * @memberof ChatCompletionWithContextRequest */ 'context_search_prompt'?: string; /** * An array of context loaders for defining how to search and apply context to the completion. * @type {Array<ContextLoader>} * @memberof ChatCompletionWithContextRequest */ 'context_loaders'?: Array<ContextLoader>; /** * ID of the model to use. EG `gpt-3.5-turbo` or `gpt-3.5-turbo-0301`. * @type {string} * @memberof ChatCompletionWithContextRequest */ 'model': string; /** * The messages to generate chat completions for, in the chat format. * @type {Array<Message>} * @memberof ChatCompletionWithContextRequest */ 'messages': Array<Message>; /** * What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or top_p but not both. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'temperature'?: number; /** * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'top_p'?: number; /** * How many chat completions to generate for each message. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'n'?: number; /** * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. * @type {boolean} * @memberof ChatCompletionWithContextRequest */ 'stream'?: boolean; /** * * @type {CompletionWithContextRequestStop} * @memberof ChatCompletionWithContextRequest */ 'stop'?: CompletionWithContextRequestStop; /** * The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model\'s context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096). * @type {number} * @memberof ChatCompletionWithContextRequest */ 'max_tokens'?: number; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model\'s likelihood to talk about new topics. See more information about frequency and presence penalties. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'presence_penalty'?: number; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model\'s likelihood to repeat the same line verbatim. See more information about frequency and presence penalties. * @type {number} * @memberof ChatCompletionWithContextRequest */ 'frequency_penalty'?: number; /** * Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token id) to biases (float values between -10 and 10). This feature is best used in conjunction with echo=false. * @type {object} * @memberof ChatCompletionWithContextRequest */ 'logit_bias'?: object; /** * A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. * @type {string} * @memberof ChatCompletionWithContextRequest */ 'user'?: string; } /** * * @export * @interface CompletionWithContext200Response */ export interface CompletionWithContext200Response { /** * Unique identifier for the completion * @type {string} * @memberof CompletionWithContext200Response */ 'id'?: string; /** * Object type, text_completion * @type {string} * @memberof CompletionWithContext200Response */ 'object'?: string; /** * Timestamp of when the completion was created * @type {number} * @memberof CompletionWithContext200Response */ 'created'?: number; /** * The model used to generate the completion * @type {string} * @memberof CompletionWithContext200Response */ 'model'?: string; /** * * @type {Array<CompletionWithContext200ResponseChoicesInner>} * @memberof CompletionWithContext200Response */ 'choices'?: Array<CompletionWithContext200ResponseChoicesInner>; /** * * @type {CompletionWithContext200ResponseUsage} * @memberof CompletionWithContext200Response */ 'usage'?: CompletionWithContext200ResponseUsage; /** * * @type {Array<ContextItemMatch>} * @memberof CompletionWithContext200Response */ 'matches'?: Array<ContextItemMatch>; } /** * * @export * @interface CompletionWithContext200ResponseChoicesInner */ export interface CompletionWithContext200ResponseChoicesInner { /** * The generated text * @type {string} * @memberof CompletionWithContext200ResponseChoicesInner */ 'text'?: string; /** * The index of the chosen prompt * @type {number} * @memberof CompletionWithContext200ResponseChoicesInner */ 'index'?: number; /** * The log probabilities of the tokens in the completion. Only returned if requested in the API call * @type {Array<number>} * @memberof CompletionWithContext200ResponseChoicesInner */ 'logprobs'?: Array<number>; /** * The reason the completion was finished. One of: length, max_tokens, stop_sequence, manual, model_failure * @type {string} * @memberof CompletionWithContext200ResponseChoicesInner */ 'finish_reason'?: string; } /** * * @export * @interface CompletionWithContext200ResponseUsage */ export interface CompletionWithContext200ResponseUsage { /** * The number of tokens in the prompt * @type {number} * @memberof CompletionWithContext200ResponseUsage */ 'prompt_tokens'?: number; /** * The number of tokens in the completion * @type {number} * @memberof CompletionWithContext200ResponseUsage */ 'completion_tokens'?: number; /** * The total number of tokens generated, including the prompt * @type {number} * @memberof CompletionWithContext200ResponseUsage */ 'total_tokens'?: number; } /** * The request body is the same as the request to openAI API. See https://platform.openai.com/docs/api-reference/completions/create * @export * @interface CompletionWithContextRequest */ export interface CompletionWithContextRequest { /** * The maximum number of context items to match. Defaults to 6. This can also be affected by max_tokens and max_match_tokens. * @type {number} * @memberof CompletionWithContextRequest */ 'max_matches'?: number; /** * The maximum amount of tokens the matched context items should use. If your max_match_tokens is set to 250 and you have 3 matches that are 100 tokens in size, it will return the first 2 matches. * @type {number} * @memberof CompletionWithContextRequest */ 'max_total_matches_tokens'?: number; /** * The maximum amount of tokens each individual match can include. Any matches that are larger than this will be excluded. * @type {number} * @memberof CompletionWithContextRequest */ 'max_single_match_tokens'?: number; /** * The minimum relevancy score for context item matches. Defaults to 0.75. This is a number between 0 and 1. The higher the number the more strict the matches will be. The playground in the dashboard is useful for finding optimal match scores * @type {number} * @memberof CompletionWithContextRequest */ 'min_match_relevancy_score'?: number; /** * Only match context items that have ANY of these tags. This will perfom like an OR query tht will match on any of the tags. * @type {Array<string>} * @memberof CompletionWithContextRequest */ 'tags'?: Array<string>; /** * Only match context items that have ALL of these tags. This will perfom like an AND query tht will match on context items that have all the tags. * @type {Array<string>} * @memberof CompletionWithContextRequest */ 'tags_and'?: Array<string>; /** * Tags to exclude context items by. Any context items with any of the tags will be excluded. * @type {Array<string>} * @memberof CompletionWithContextRequest */ 'tags_exclude'?: Array<string>; /** * A unique identifier for user completions. This can be used for rate limiting and debugging log events. * @type {string} * @memberof CompletionWithContextRequest */ 'sessionId'?: string; /** * A prompt to use when searching for context items. This is useful if you want to use a different prompt than the one you use for the completion. If you don\'t provide this, the prompt will be used for both. * @type {string} * @memberof CompletionWithContextRequest */ 'context_search_prompt'?: string; /** * An array of context loaders for defining how to search and apply context to the completion. * @type {Array<ContextLoader>} * @memberof CompletionWithContextRequest */ 'context_loaders'?: Array<ContextLoader>; /** * ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them. * @type {string} * @memberof CompletionWithContextRequest */ 'model': string; /** * * @type {CompletionWithContextRequestPrompt} * @memberof CompletionWithContextRequest */ 'prompt': CompletionWithContextRequestPrompt; /** * The suffix that comes after a completion of inserted text. * @type {string} * @memberof CompletionWithContextRequest */ 'suffix'?: string; /** * The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model\'s context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096). * @type {number} * @memberof CompletionWithContextRequest */ 'max_tokens'?: number; /** * What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or top_p but not both. * @type {number} * @memberof CompletionWithContextRequest */ 'temperature'?: number; /** * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. * @type {number} * @memberof CompletionWithContextRequest */ 'top_p'?: number; /** * How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop. * @type {number} * @memberof CompletionWithContextRequest */ 'n'?: number; /** * Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. * @type {boolean} * @memberof CompletionWithContextRequest */ 'stream'?: boolean; /** * Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response. The maximum value for logprobs is 5. If you need more than this, please contact us through our Help center and describe your use case. * @type {number} * @memberof CompletionWithContextRequest */ 'logprobs'?: number; /** * Echo back the prompt in addition to the completion * @type {boolean} * @memberof CompletionWithContextRequest */ 'echo'?: boolean; /** * * @type {CompletionWithContextRequestStop} * @memberof CompletionWithContextRequest */ 'stop'?: CompletionWithContextRequestStop; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model\'s likelihood to talk about new topics. See more information about frequency and presence penalties. * @type {number} * @memberof CompletionWithContextRequest */ 'presence_penalty'?: number; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model\'s likelihood to repeat the same line verbatim. See more information about frequency and presence penalties. * @type {number} * @memberof CompletionWithContextRequest */ 'frequency_penalty'?: number; /** * Generates best_of completions server-side and returns the \'best\' (the one with the highest log probability per token). Results cannot be streamed. When used with n, best_of controls the number of candidate completions and n specifies how many to return – best_of must be greater than n. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop. * @type {number} * @memberof CompletionWithContextRequest */ 'best_of'?: number; /** * Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token id) to biases (float values between -10 and 10). This feature is best used in conjunction with echo=false. * @type {object} * @memberof CompletionWithContextRequest */ 'logit_bias'?: object; } /** * @type CompletionWithContextRequestPrompt * The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. Note that is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. By default the context will be prepended to the prompt. If you include `[context]` in the prompt, the context will be inseted in place of the `context` string. * @export */ export type CompletionWithContextRequestPrompt = Array<string> | string; /** * @type CompletionWithContextRequestStop * Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. * @export */ export type CompletionWithContextRequestStop = Array<string> | string; /** * * @export * @interface ContextItem */ export interface ContextItem { /** * * @type {string} * @memberof ContextItem */ 'id': string; /** * * @type {string} * @memberof ContextItem */ 'projectId': string; /** * * @type {string} * @memberof ContextItem */ 'value': string; /** * * @type {string} * @memberof ContextItem */ 'reference'?: string; /** * * @type {string} * @memberof ContextItem */ 'type'?: string; /** * * @type {Array<string>} * @memberof ContextItem */ 'tags'?: Array<string>; } /** * * @export * @interface ContextItemMatch */ export interface ContextItemMatch { /** * * @type {number} * @memberof ContextItemMatch */ 'score'?: number; /** * The prompt that was used for the semantic context item search. * @type {string} * @memberof ContextItemMatch */ 'prompt'?: string; /** * * @type {ContextItem} * @memberof ContextItemMatch */ 'item': ContextItem; } /** * * @export * @interface ContextItemUpdate */ export interface ContextItemUpdate { /** * * @type {string} * @memberof ContextItemUpdate */ 'value': string; /** * * @type {string} * @memberof ContextItemUpdate */ 'reference'?: string; /** * * @type {string} * @memberof ContextItemUpdate */ 'type'?: string; } /** * * @export * @interface ContextLoader */ export interface ContextLoader { /** * The prompt to use when searching for context items to append to your completion. * @type {string} * @memberof ContextLoader */ 'prompt': string; /** * The ID of the loader. You can use the loader ID merge the content into the prompt or chat message provided to the LLM. Simply include the id in this format `[LOADER_ID]` and the matched context items will be merged into the prompt. * @type {string} * @memberof ContextLoader */ 'id': string; /** * The maximum number of context items to match. Defaults to 6. This can also be affected by max_tokens and max_match_tokens. * @type {number} * @memberof ContextLoader */ 'max_matches'?: number; /** * The maximum amount of tokens the matched context items should use. If your max_match_tokens is set to 250 and you have 3 matches that are 100 tokens in size, it will return the first 2 matches. * @type {number} * @memberof ContextLoader */ 'max_total_matches_tokens'?: number; /** * The maximum amount of tokens each individual match can include. Any matches that are larger than this will be excluded. * @type {number} * @memberof ContextLoader */ 'max_single_match_tokens'?: number; /** * The minimum relevancy score for context item matches. Defaults to 0.75. This is a number between 0 and 1. The higher the number the more strict the matches will be. The playground in the dashboard is useful for finding optimal match scores * @type {number} * @memberof ContextLoader */ 'min_match_relevancy_score'?: number; /** * Only match context items that have ANY of these tags. This will perfom like an OR query tht will match on any of the tags. * @type {Array<string>} * @memberof ContextLoader */ 'tags'?: Array<string>; /** * Only match context items that have ALL of these tags. This will perfom like an AND query tht will match on context items that have all the tags. * @type {Array<string>} * @memberof ContextLoader */ 'tags_and'?: Array<string>; /** * Tags to exclude context items by. Any context items with any of the tags will be excluded. * @type {Array<string>} * @memberof ContextLoader */ 'tags_exclude'?: Array<string>; } /** * * @export * @interface CreateContextItemRequest */ export interface CreateContextItemRequest { /** * The string you want to index as a Context Item * @type {string} * @memberof CreateContextItemRequest */ 'value': string; /** * The ID of the Context Item. Will be autogenerated if not provided. Useful for mapping to your own IDs from databases or other systems. * @type {string} * @memberof CreateContextItemRequest */ 'id'?: string; /** * A reference url you want to filter by or link to in the future * @type {string} * @memberof CreateContextItemRequest */ 'reference'?: string; /** * The type of the Context Item. This is used to filter by in the future. * @type {string} * @memberof CreateContextItemRequest */ 'type'?: string; /** * * @type {Array<string>} * @memberof CreateContextItemRequest */ 'tags'?: Array<string>; } /** * * @export * @interface CreateProjectRequest */ export interface CreateProjectRequest { /** * * @type {string} * @memberof CreateProjectRequest */ 'name': string; /** * * @type {string} * @memberof CreateProjectRequest */ 'id'?: string; } /** * * @export * @interface DeleteContextItem200Response */ export interface DeleteContextItem200Response { /** * * @type {string} * @memberof DeleteContextItem200Response */ 'message'?: string; } /** * * @export * @interface Message */ export interface Message { /** * * @type {string} * @memberof Message */ 'role': MessageRoleEnum; /** * * @type {string} * @memberof Message */ 'content': string; } export const MessageRoleEnum = { System: 'system', User: 'user', Assistant: 'assistant' } as const; export type MessageRoleEnum = typeof MessageRoleEnum[keyof typeof MessageRoleEnum]; /** * * @export * @interface Project */ export interface Project { /** * * @type {string} * @memberof Project */ 'name': string; /** * * @type {string} * @memberof Project */ 'id': string; /** * * @type {string} * @memberof Project */ 'createdAt': string; /** * * @type {string} * @memberof Project */ 'updatedAt': string; /** * * @type {string} * @memberof Project */ 'teamId': string; /** * * @type {boolean} * @memberof Project */ 'public': boolean; } /** * GodlyApi - axios parameter creator * @export */ export const GodlyApiAxiosParamCreator = function (configuration?: 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: async (projectId: string, createContextItemRequest?: Array<CreateContextItemRequest>, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('batchCreateContextItems', 'projectId', projectId) const localVarPath = `/projects/{projectId}/context-items/batch` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(createContextItemRequest, localVarRequestOptions, configuration) return { url: 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: async (projectId: string, chatCompletionWithContextRequest?: ChatCompletionWithContextRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('chatCompletionWithContext', 'projectId', projectId) const localVarPath = `/with-context/{projectId}/chatCompletions` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(chatCompletionWithContextRequest, localVarRequestOptions, configuration) return { url: 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: async (projectId: string, completionWithContextRequest?: CompletionWithContextRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('completionWithContext', 'projectId', projectId) const localVarPath = `/with-context/{projectId}/completions` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(completionWithContextRequest, localVarRequestOptions, configuration) return { url: 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 \&#39;fail\&#39;. &#x60;fail&#x60; will return an error, &#x60;split&#x60; will split the context item into multiple context items with none larger than the maxTokens, and &#x60;truncate&#x60; will truncate the context item to the maxTokens. * @param {CreateContextItemRequest} [createContextItemRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ createContextItem: async (projectId: string, maxTokens?: number, exceedTokensStrategy?: 'fail' | 'split' | 'truncate', createContextItemRequest?: CreateContextItemRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('createContextItem', 'projectId', projectId) const localVarPath = `/projects/{projectId}/context-items` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) if (maxTokens !== undefined) { localVarQueryParameter['maxTokens'] = maxTokens; } if (exceedTokensStrategy !== undefined) { localVarQueryParameter['exceedTokensStrategy'] = exceedTokensStrategy; } localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(createContextItemRequest, localVarRequestOptions, configuration) return { url: 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: async (createProjectRequest?: CreateProjectRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { const localVarPath = `/projects`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(createProjectRequest, localVarRequestOptions, configuration) return { url: 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: async (projectId: string, itemId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('deleteContextItem', 'projectId', projectId) // verify required parameter 'itemId' is not null or undefined assertParamExists('deleteContextItem', 'itemId', itemId) const localVarPath = `/projects/{projectId}/context-items/{itemId}` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))) .replace(`{${"itemId"}}`, encodeURIComponent(String(itemId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: 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, &#x60;tags&#x3D;tag1&amp;tags&#x3D;tag2&#x60; * @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, &#x60;tagsAnd&#x3D;tag1&amp;tagsAnd&#x3D;tag2&#x60; * @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, &#x60;tags&#x3D;tag1&amp;tags&#x3D;tag2&#x60; * @param {*} [options] Override http request option. * @throws {RequiredError} */ getContextItems: async (projectId: string, prompt: string, limit?: number, tags?: Array<string>, tagsAnd?: Array<string>, tagsExclude?: Array<string>, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('getContextItems', 'projectId', projectId) // verify required parameter 'prompt' is not null or undefined assertParamExists('getContextItems', 'prompt', prompt) const localVarPath = `/projects/{projectId}/context-items` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) 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; } setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: 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: async (projectId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'projectId' is not null or undefined assertParamExists('getProjectById', 'projectId', projectId) const localVarPath = `/projects/{projectId}` .replace(`{${"projectId"}}`, encodeURIComponent(String(projectId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication BearerKey required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: 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}