Skip to content

Add missing generative modules and unit tests #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/collections/config/types/generative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ type GenerativeOpenAIConfigBase = {
topPProperty?: number;
};

export type GenerativeAWSConfig = {
region: string;
service: string;
model?: string;
endpoint?: string;
};

export type GenerativeAnyscaleConfig = {
model?: string;
temperature?: number;
};

export type GenerativeMistralConfig = {
maxTokens?: number;
model?: string;
temperature?: number;
};

export type GenerativeOctoAIConfig = {
baseURL?: string;
maxTokens?: number;
model?: string;
temperature?: number;
};

export type GenerativeOllamaConfig = {
apiEndpoint?: string;
model?: string;
};

export type GenerativeOpenAIConfig = GenerativeOpenAIConfigBase & {
model?: string;
};
Expand Down Expand Up @@ -53,6 +83,11 @@ export type GenerativeConfigType<G> = G extends 'generative-openai'
: Record<string, any> | undefined;

export type GenerativeSearch =
| 'generative-anyscale'
| 'generative-aws'
| 'generative-mistral'
| 'generative-octoai'
| 'generative-ollama'
| 'generative-openai'
| 'generative-cohere'
| 'generative-palm'
Expand Down
94 changes: 91 additions & 3 deletions src/collections/configure/generative.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
import {
GenerativeAWSConfig,
GenerativeAnyscaleConfig,
GenerativeAzureOpenAIConfig,
GenerativeCohereConfig,
GenerativeMistralConfig,
GenerativeOctoAIConfig,
GenerativeOllamaConfig,
GenerativeOpenAIConfig,
GenerativePaLMConfig,
ModuleConfig,
} from '../config/types/index.js';
import {
GenerativeAWSConfigCreate,
GenerativeAnyscaleConfigCreate,
GenerativeAzureOpenAIConfigCreate,
GenerativeCohereConfigCreate,
GenerativeMistralConfigCreate,
GenerativeOctoAIConfigCreate,
GenerativeOllamaConfigCreate,
GenerativeOpenAIConfigCreate,
GenerativePaLMConfigCreate,
} from '../index.js';

export default {
/**
* Create a `ModuleConfig<'generative-anyscale', GenerativeAnyscaleConfig | undefined>` object for use when performing AI generation using the `generative-anyscale` module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-anyscale) for detailed usage.
*
* @param {GenerativeAnyscaleConfigCreate} config The configuration for the `generative-aws` module.
* @returns {ModuleConfig<'generative-anyscale', GenerativeAnyscaleConfig | undefined>} The configuration object.
*/
anyscale(
config?: GenerativeAnyscaleConfigCreate
): ModuleConfig<'generative-anyscale', GenerativeAnyscaleConfig | undefined> {
return {
name: 'generative-anyscale',
config,
};
},
/**
* Create a `ModuleConfig<'generative-aws', GenerativeAWSConfig>` object for use when performing AI generation using the `generative-aws` module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-aws) for detailed usage.
*
* @param {GenerativeAWSConfigCreate} config The configuration for the `generative-aws` module.
* @returns {ModuleConfig<'generative-aws', GenerativeAWSConfig>} The configuration object.
*/
aws(config: GenerativeAWSConfigCreate): ModuleConfig<'generative-aws', GenerativeAWSConfig> {
return {
name: 'generative-aws',
config,
};
},
/**
* Create a `ModuleConfig<'generative-openai', GenerativeAzureOpenAIConfig>` object for use when performing AI generation using the `generative-openai` module.
*
Expand Down Expand Up @@ -64,12 +104,60 @@ export default {
};
},
/**
* Create a `ModuleConfig<'generative-openai', GenerativeOpenAIConfig>` object for use when performing AI generation using the `generative-openai` module.
* Create a `ModuleConfig<'generative-mistral', GenerativeMistralConfig | undefined>` object for use when performing AI generation using the `generative-mistral` module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-mistral) for detailed usage.
*
* @param {GenerativeMistralConfigCreate} [config] The configuration for the `generative-mistral` module.
* @returns {ModuleConfig<'generative-mistral', GenerativeMistralConfig | undefined>} The configuration object.
*/
mistral(
config?: GenerativeMistralConfigCreate
): ModuleConfig<'generative-mistral', GenerativeMistralConfig | undefined> {
return {
name: 'generative-mistral',
config,
};
},
/**
* Create a `ModuleConfig<'generative-octoai', GenerativeOpenAIConfig | undefined>` object for use when performing AI generation using the `generative-octoai` module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-octoai) for detailed usage.
*
* @param {GenerativeOctoAIConfigCreate} [config] The configuration for the `generative-octoai` module.
* @returns {ModuleConfig<'generative-octoai', GenerativeOctoAIConfig | undefined>} The configuration object.
*/
octoai(
config?: GenerativeOctoAIConfigCreate
): ModuleConfig<'generative-octoai', GenerativeOctoAIConfig | undefined> {
return {
name: 'generative-octoai',
config,
};
},
/**
* Create a `ModuleConfig<'generative-ollama', GenerativeOllamaConfig | undefined>` object for use when performing AI generation using the `generative-ollama` module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-ollama) for detailed usage.
*
* @param {GenerativeOllamaConfigCreate} [config] The configuration for the `generative-openai` module.
* @returns {ModuleConfig<'generative-ollama', GenerativeOllamaConfig | undefined>} The configuration object.
*/
ollama(
config?: GenerativeOllamaConfigCreate
): ModuleConfig<'generative-ollama', GenerativeOllamaConfig | undefined> {
return {
name: 'generative-ollama',
config,
};
},
/**
* Create a `ModuleConfig<'generative-openai', GenerativeOpenAIConfig | undefined>` object for use when performing AI generation using the `generative-openai` module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-openai) for detailed usage.
*
* @param {GenerativeOpenAIConfigCreate} [config] The configuration for the `generative-openai` module.
* @returns {ModuleConfig<'generative-openai', GenerativeOpenAIConfig>} The configuration object.
* @returns {ModuleConfig<'generative-openai', GenerativeOpenAIConfig | undefined>} The configuration object.
*/
openAI: (
config?: GenerativeOpenAIConfigCreate
Expand Down Expand Up @@ -100,7 +188,7 @@ export default {
palm: (config: GenerativePaLMConfigCreate): ModuleConfig<'generative-palm', GenerativePaLMConfig> => {
return {
name: 'generative-palm',
config: config,
config,
};
},
};
19 changes: 18 additions & 1 deletion src/collections/configure/types/generative.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { GenerativePaLMConfig } from '../../index.js';
import {
GenerativeAWSConfig,
GenerativeAnyscaleConfig,
GenerativeMistralConfig,
GenerativeOctoAIConfig,
GenerativeOllamaConfig,
GenerativePaLMConfig,
} from '../../index.js';

type GenerativeOpenAIConfigBaseCreate = {
baseURL?: string;
Expand Down Expand Up @@ -27,6 +34,16 @@ export type GenerativeCohereConfigCreate = {
temperature?: number;
};

export type GenerativeAnyscaleConfigCreate = GenerativeAnyscaleConfig;

export type GenerativeAWSConfigCreate = GenerativeAWSConfig;

export type GenerativeMistralConfigCreate = GenerativeMistralConfig;

export type GenerativeOctoAIConfigCreate = GenerativeOctoAIConfig;

export type GenerativeOllamaConfigCreate = GenerativeOllamaConfig;

export type GenerativePaLMConfigCreate = GenerativePaLMConfig;

export type GenerativeConfigCreate =
Expand Down
Loading
Loading