adjust unrolling for blocks
This commit is contained in:
parent
368f9653cb
commit
4c554f05f4
14 changed files with 326 additions and 144 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { Assistant } from "./schemas/index.js";
|
||||
import { AssistantRolled } from "./schemas/index.js";
|
||||
import { ModelRoles } from "./schemas/models.js";
|
||||
|
||||
type ModelYaml = NonNullable<Assistant["models"]>[number];
|
||||
type ContextYaml = NonNullable<Assistant["context"]>[number];
|
||||
type PromptYaml = NonNullable<Assistant["prompts"]>[number];
|
||||
type ModelYaml = NonNullable<AssistantRolled["models"]>[number];
|
||||
type ContextYaml = NonNullable<AssistantRolled["context"]>[number];
|
||||
type PromptYaml = NonNullable<AssistantRolled["prompts"]>[number];
|
||||
|
||||
function convertModel(
|
||||
m: ConfigJson["models"][number],
|
||||
|
|
@ -68,7 +68,9 @@ function convertCustomCommand(
|
|||
};
|
||||
}
|
||||
|
||||
function convertMcp(mcp: any): NonNullable<Assistant["mcpServers"]>[number] {
|
||||
function convertMcp(
|
||||
mcp: any,
|
||||
): NonNullable<AssistantRolled["mcpServers"]>[number] {
|
||||
const { transport } = mcp;
|
||||
const { command, args, env } = transport;
|
||||
|
||||
|
|
@ -82,7 +84,7 @@ function convertMcp(mcp: any): NonNullable<Assistant["mcpServers"]>[number] {
|
|||
|
||||
function convertDoc(
|
||||
doc: NonNullable<ConfigJson["docs"]>[number],
|
||||
): NonNullable<Assistant["docs"]>[number] {
|
||||
): NonNullable<AssistantRolled["docs"]>[number] {
|
||||
return {
|
||||
name: doc.title,
|
||||
startUrl: doc.startUrl,
|
||||
|
|
@ -91,7 +93,9 @@ function convertDoc(
|
|||
};
|
||||
}
|
||||
|
||||
export function convertJsonToYamlConfig(configJson: ConfigJson): Assistant {
|
||||
export function convertJsonToYamlConfig(
|
||||
configJson: ConfigJson,
|
||||
): AssistantRolled {
|
||||
// models
|
||||
const models = configJson.models.map((m) => convertModel(m, ["chat"]));
|
||||
const autocompleteModels = Array.isArray(configJson.tabAutocompleteModel)
|
||||
|
|
@ -126,7 +130,7 @@ export function convertJsonToYamlConfig(configJson: ConfigJson): Assistant {
|
|||
// docs
|
||||
const docs = configJson.docs?.map(convertDoc);
|
||||
|
||||
const configYaml: Assistant = {
|
||||
const configYaml: AssistantRolled = {
|
||||
name: "Continue Config",
|
||||
version: "0.0.1",
|
||||
models,
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@ import {
|
|||
SecretLocation,
|
||||
} from "../interfaces/SecretResult.js";
|
||||
import { decodeFQSN, encodeFQSN, FQSN } from "../interfaces/slugs.js";
|
||||
import { Assistant } from "../schemas/index.js";
|
||||
import { AssistantUnrolled } from "../schemas/index.js";
|
||||
import {
|
||||
fillTemplateVariables,
|
||||
getTemplateVariables,
|
||||
parseConfigYaml,
|
||||
parseAssistantUnrolled,
|
||||
} from "./unroll.js";
|
||||
|
||||
export async function clientRender(
|
||||
unrolledConfigContent: string,
|
||||
secretStore: SecretStore,
|
||||
platformClient?: PlatformClient,
|
||||
): Promise<Assistant> {
|
||||
): Promise<AssistantUnrolled> {
|
||||
// 1. First we need to get a list of all the FQSNs that are required to render the config
|
||||
const secrets = getTemplateVariables(unrolledConfigContent);
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ export async function clientRender(
|
|||
);
|
||||
|
||||
// 6. The rendered YAML is parsed and validated again
|
||||
const parsedYaml = parseConfigYaml(renderedYaml);
|
||||
const parsedYaml = parseAssistantUnrolled(renderedYaml);
|
||||
|
||||
// 7. We update any of the items with the proxy version if there are un-rendered secrets
|
||||
const finalConfig = useProxyForUnrenderedSecrets(parsedYaml);
|
||||
|
|
@ -102,7 +102,9 @@ function getUnrenderedSecretLocation(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
function useProxyForUnrenderedSecrets(config: Assistant): Assistant {
|
||||
function useProxyForUnrenderedSecrets(
|
||||
config: AssistantUnrolled,
|
||||
): AssistantUnrolled {
|
||||
if (config.models) {
|
||||
for (let i = 0; i < config.models.length; i++) {
|
||||
const apiKeyLocation = getUnrenderedSecretLocation(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Assistant } from "../schemas/index.js";
|
||||
import { AssistantRolled } from "../schemas/index.js";
|
||||
|
||||
export function mergePackages(
|
||||
current: Assistant,
|
||||
incoming: Assistant,
|
||||
): Assistant {
|
||||
current: AssistantRolled,
|
||||
incoming: AssistantRolled,
|
||||
): AssistantRolled {
|
||||
return {
|
||||
...current,
|
||||
models: [...(current.models ?? []), ...(incoming.models ?? [])],
|
||||
|
|
|
|||
|
|
@ -1,20 +1,48 @@
|
|||
import * as YAML from "yaml";
|
||||
import { Registry } from "../interfaces/index.js";
|
||||
import {
|
||||
PackageSlug,
|
||||
decodeFullSlug,
|
||||
encodePackageSlug,
|
||||
FullSlug,
|
||||
PackageSlug,
|
||||
} from "../interfaces/slugs.js";
|
||||
import { Assistant, assistantSchema } from "../schemas/index.js";
|
||||
import { mergePackages } from "./merge.js";
|
||||
import {
|
||||
AssistantRolled,
|
||||
assistantRolledSchema,
|
||||
AssistantUnrolled,
|
||||
assistantUnrolledSchema,
|
||||
Block,
|
||||
blockSchema,
|
||||
} from "../schemas/index.js";
|
||||
|
||||
export function parseConfigYaml(configYaml: string): Assistant {
|
||||
export function parseAssistantRolled(configYaml: string): AssistantRolled {
|
||||
try {
|
||||
const parsed = YAML.parse(configYaml);
|
||||
const result = assistantSchema.parse(parsed);
|
||||
const result = assistantRolledSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to parse config yaml: ${e.message}`);
|
||||
console.log(configYaml);
|
||||
throw new Error(`Failed to parse rolled assistant: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function parseAssistantUnrolled(configYaml: string): AssistantUnrolled {
|
||||
try {
|
||||
const parsed = YAML.parse(configYaml);
|
||||
const result = assistantUnrolledSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to parse unrolled assistant: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function parseBlock(configYaml: string): Block {
|
||||
try {
|
||||
const parsed = YAML.parse(configYaml);
|
||||
const result = blockSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to parse block: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,29 +71,8 @@ export function fillTemplateVariables(
|
|||
});
|
||||
}
|
||||
|
||||
export async function unrollImportedPackage(
|
||||
pkgImport: NonNullable<Assistant["packages"]>[number],
|
||||
parentPackages: PackageSlug[],
|
||||
registry: Registry,
|
||||
): Promise<Assistant> {
|
||||
const { uses, with: params } = pkgImport;
|
||||
|
||||
const fullSlug = decodeFullSlug(uses);
|
||||
|
||||
// Request the content from the registry
|
||||
const rawContent = await registry.getContent(fullSlug);
|
||||
|
||||
// Convert the raw YAML to unrolled config
|
||||
return await unrollPackageFromContent(
|
||||
rawContent,
|
||||
params,
|
||||
parentPackages,
|
||||
registry,
|
||||
);
|
||||
}
|
||||
|
||||
export interface TemplateData {
|
||||
params: Record<string, string> | undefined;
|
||||
inputs: Record<string, string> | undefined;
|
||||
secrets: Record<string, string> | undefined;
|
||||
continue: {};
|
||||
}
|
||||
|
|
@ -75,9 +82,9 @@ function flattenTemplateData(
|
|||
): Record<string, string> {
|
||||
const flattened: Record<string, string> = {};
|
||||
|
||||
if (templateData.params) {
|
||||
for (const [key, value] of Object.entries(templateData.params)) {
|
||||
flattened[`params.${key}`] = value;
|
||||
if (templateData.inputs) {
|
||||
for (const [key, value] of Object.entries(templateData.inputs)) {
|
||||
flattened[`inputs.${key}`] = value;
|
||||
}
|
||||
}
|
||||
if (templateData.secrets) {
|
||||
|
|
@ -116,57 +123,158 @@ function extractFQSNMap(
|
|||
return secretToFQSNMap(secrets, parentPackages);
|
||||
}
|
||||
|
||||
export async function unrollPackageFromContent(
|
||||
rawContent: string,
|
||||
params: Record<string, string> | undefined,
|
||||
packagePath: PackageSlug[],
|
||||
registry: Registry,
|
||||
): Promise<Assistant> {
|
||||
// Collect template data
|
||||
const templateData: TemplateData = {
|
||||
// params are passed from the parent package
|
||||
params: params,
|
||||
// at this stage, secrets are mapped to a (still templated) FQSN
|
||||
secrets: extractFQSNMap(rawContent, packagePath),
|
||||
// Built-in variables
|
||||
continue: {},
|
||||
};
|
||||
|
||||
const templatedYaml = fillTemplateVariables(
|
||||
rawContent,
|
||||
flattenTemplateData(templateData),
|
||||
);
|
||||
|
||||
let parsedYaml = parseConfigYaml(templatedYaml);
|
||||
|
||||
const unrolledChildPackages = await Promise.all(
|
||||
parsedYaml.packages?.map((pkg) => {
|
||||
const pkgSlug = decodeFullSlug(pkg.uses);
|
||||
return unrollImportedPackage(pkg, [...packagePath, pkgSlug], registry);
|
||||
}) ?? [],
|
||||
);
|
||||
|
||||
delete parsedYaml.packages;
|
||||
for (const childPkg of unrolledChildPackages) {
|
||||
parsedYaml = mergePackages(parsedYaml, childPkg);
|
||||
}
|
||||
|
||||
return parsedYaml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loading an assistant is equivalent to loading a package without params
|
||||
*/
|
||||
export async function unrollAssistant(
|
||||
fullSlug: string,
|
||||
registry: Registry,
|
||||
): Promise<Assistant> {
|
||||
const packageSlug = decodeFullSlug(fullSlug);
|
||||
return await unrollImportedPackage(
|
||||
{
|
||||
uses: fullSlug,
|
||||
},
|
||||
[packageSlug],
|
||||
): Promise<AssistantUnrolled> {
|
||||
const assistantSlug = decodeFullSlug(fullSlug);
|
||||
|
||||
// Request the content from the registry
|
||||
const rawContent = await registry.getContent(assistantSlug);
|
||||
|
||||
// Convert the raw YAML to unrolled config
|
||||
const templateData: TemplateData = {
|
||||
// no inputs to an assistant
|
||||
inputs: {},
|
||||
// at this stage, secrets are mapped to a (still templated) FQSN
|
||||
secrets: extractFQSNMap(rawContent, [assistantSlug]),
|
||||
// Built-in variables
|
||||
continue: {},
|
||||
};
|
||||
|
||||
// Render the template
|
||||
const templatedYaml = fillTemplateVariables(
|
||||
rawContent,
|
||||
flattenTemplateData(templateData),
|
||||
);
|
||||
|
||||
// Parse string to Zod-validated YAML
|
||||
let parsedYaml = parseAssistantRolled(templatedYaml);
|
||||
|
||||
// Unroll blocks
|
||||
const unrolledAssistant = await unrollBlocks(
|
||||
parsedYaml,
|
||||
assistantSlug,
|
||||
registry,
|
||||
);
|
||||
|
||||
return unrolledAssistant;
|
||||
}
|
||||
|
||||
export async function unrollBlocks(
|
||||
assistant: AssistantRolled,
|
||||
assistantFullSlug: FullSlug,
|
||||
registry: Registry,
|
||||
): Promise<AssistantUnrolled> {
|
||||
const unrolledAssistant: AssistantUnrolled = {
|
||||
name: assistant.name,
|
||||
version: assistant.version,
|
||||
};
|
||||
|
||||
const sections: (keyof Omit<
|
||||
AssistantRolled,
|
||||
"name" | "version" | "rules"
|
||||
>)[] = [
|
||||
"models",
|
||||
"context",
|
||||
"data",
|
||||
"tools",
|
||||
"mcpServers",
|
||||
"prompts",
|
||||
"docs",
|
||||
];
|
||||
|
||||
// For each section, replace "uses/with" blocks with the real thing
|
||||
for (const section of sections) {
|
||||
if (assistant[section]) {
|
||||
const sectionBlocks: any[] = [];
|
||||
|
||||
for (const unrolledBlock of assistant[section]) {
|
||||
// "uses/with" block
|
||||
if ("uses" in unrolledBlock) {
|
||||
const blockConfigYaml = await resolveBlock(
|
||||
decodeFullSlug(unrolledBlock.uses),
|
||||
unrolledBlock.with,
|
||||
assistantFullSlug,
|
||||
registry,
|
||||
);
|
||||
const block = blockConfigYaml[section]?.[0];
|
||||
if (block) {
|
||||
sectionBlocks.push(
|
||||
mergeOverrides(block, unrolledBlock.override ?? {}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Normal block
|
||||
sectionBlocks.push(unrolledBlock);
|
||||
}
|
||||
}
|
||||
|
||||
unrolledAssistant[section] = sectionBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
// Rules are a bit different because they're just strings, so handle separately
|
||||
if (assistant.rules) {
|
||||
const rules: string[] = [];
|
||||
for (const rule of assistant.rules) {
|
||||
if (typeof rule === "string") {
|
||||
rules.push(rule);
|
||||
} else {
|
||||
const blockConfigYaml = await resolveBlock(
|
||||
decodeFullSlug(rule.uses),
|
||||
rule.with,
|
||||
assistantFullSlug,
|
||||
registry,
|
||||
);
|
||||
const block = blockConfigYaml.rules?.[0];
|
||||
if (block) {
|
||||
rules.push(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unrolledAssistant.rules = rules;
|
||||
}
|
||||
|
||||
return unrolledAssistant;
|
||||
}
|
||||
|
||||
export async function resolveBlock(
|
||||
fullSlug: FullSlug,
|
||||
inputs: Record<string, string> | undefined,
|
||||
parentFullSlug: FullSlug,
|
||||
registry: Registry,
|
||||
): Promise<AssistantUnrolled> {
|
||||
// Retrieve block raw yaml
|
||||
const rawYaml = await registry.getContent(fullSlug);
|
||||
|
||||
// Render template variables
|
||||
const templateData: TemplateData = {
|
||||
inputs,
|
||||
secrets: extractFQSNMap(rawYaml, [parentFullSlug, fullSlug]),
|
||||
continue: {},
|
||||
};
|
||||
const templatedYaml = fillTemplateVariables(
|
||||
rawYaml,
|
||||
flattenTemplateData(templateData),
|
||||
);
|
||||
|
||||
const parsedYaml = parseBlock(templatedYaml);
|
||||
return parsedYaml;
|
||||
}
|
||||
|
||||
export function mergeOverrides<T extends Record<string, any>>(
|
||||
block: T,
|
||||
overrides: Partial<T>,
|
||||
): T {
|
||||
for (const key in overrides) {
|
||||
if (overrides.hasOwnProperty(key)) {
|
||||
block[key] = overrides[key]!;
|
||||
}
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import * as z from "zod";
|
||||
import { modelSchema } from "./models.js";
|
||||
import { modelSchema, partialModelSchema } from "./models.js";
|
||||
|
||||
export const dataSchema = z.object({
|
||||
destination: z.string(),
|
||||
|
|
@ -38,30 +38,66 @@ const docSchema = z.object({
|
|||
faviconUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export const blockItemWrapperSchema = <T extends z.ZodType>(schema: T) =>
|
||||
export const blockItemWrapperSchema = <T extends z.AnyZodObject>(schema: T) =>
|
||||
z.object({
|
||||
uses: z.string(),
|
||||
with: z.record(z.string()).optional(),
|
||||
override: schema.optional(),
|
||||
override: schema.partial().optional(),
|
||||
});
|
||||
|
||||
export const blockOrSchema = <T extends z.ZodType>(schema: T) =>
|
||||
export const blockOrSchema = <T extends z.AnyZodObject>(schema: T) =>
|
||||
z.union([schema, blockItemWrapperSchema(schema)]);
|
||||
|
||||
export const assistantSchema = z.object({
|
||||
export const assistantRolledSchema = z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
models: z.array(blockOrSchema(modelSchema)).optional(),
|
||||
models: z
|
||||
.array(
|
||||
z.union([
|
||||
modelSchema,
|
||||
z.object({
|
||||
uses: z.string(),
|
||||
with: z.record(z.string()).optional(),
|
||||
override: partialModelSchema.optional(),
|
||||
}),
|
||||
]),
|
||||
)
|
||||
.optional(),
|
||||
context: z.array(blockOrSchema(contextSchema)).optional(),
|
||||
data: z.array(blockOrSchema(dataSchema)).optional(),
|
||||
tools: z.array(blockOrSchema(toolSchema)).optional(),
|
||||
mcpServers: z.array(blockOrSchema(mcpServerSchema)).optional(),
|
||||
rules: z.array(z.string()).optional(),
|
||||
rules: z
|
||||
.array(
|
||||
z.union([
|
||||
z.string(),
|
||||
z.object({
|
||||
uses: z.string(),
|
||||
with: z.record(z.string()).optional(),
|
||||
}),
|
||||
]),
|
||||
)
|
||||
.optional(),
|
||||
prompts: z.array(blockOrSchema(promptSchema)).optional(),
|
||||
docs: z.array(blockOrSchema(docSchema)).optional(),
|
||||
});
|
||||
|
||||
export type Assistant = z.infer<typeof assistantSchema>;
|
||||
export type AssistantRolled = z.infer<typeof assistantRolledSchema>;
|
||||
|
||||
export const assistantUnrolledSchema = z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
models: z.array(modelSchema).optional(),
|
||||
context: z.array(contextSchema).optional(),
|
||||
data: z.array(dataSchema).optional(),
|
||||
tools: z.array(toolSchema).optional(),
|
||||
mcpServers: z.array(mcpServerSchema).optional(),
|
||||
rules: z.array(z.string()).optional(),
|
||||
prompts: z.array(promptSchema).optional(),
|
||||
docs: z.array(docSchema).optional(),
|
||||
});
|
||||
|
||||
export type AssistantUnrolled = z.infer<typeof assistantUnrolledSchema>;
|
||||
|
||||
export const blockSchema = z
|
||||
.object({
|
||||
|
|
|
|||
|
|
@ -64,4 +64,20 @@ export const modelSchema = z.union([
|
|||
}),
|
||||
]);
|
||||
|
||||
export const partialModelSchema = z.union([
|
||||
z
|
||||
.object({
|
||||
...baseModelFields,
|
||||
provider: z.literal("continue-proxy"),
|
||||
apiKeyLocation: z.string(),
|
||||
})
|
||||
.partial(),
|
||||
z
|
||||
.object({
|
||||
...baseModelFields,
|
||||
provider: z.string().refine((val) => val !== "continue-proxy"),
|
||||
})
|
||||
.partial(),
|
||||
]);
|
||||
|
||||
export type ModelConfig = z.infer<typeof modelSchema>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Assistant, assistantSchema } from "./schemas/index.js";
|
||||
import { AssistantRolled, assistantRolledSchema } from "./schemas/index.js";
|
||||
|
||||
export interface ConfigValidationError {
|
||||
fatal: boolean;
|
||||
|
|
@ -11,11 +11,13 @@ export interface ConfigResult<T> {
|
|||
configLoadInterrupted: boolean;
|
||||
}
|
||||
|
||||
export function validateConfigYaml(config: Assistant): ConfigValidationError[] {
|
||||
export function validateConfigYaml(
|
||||
config: AssistantRolled,
|
||||
): ConfigValidationError[] {
|
||||
const errors: ConfigValidationError[] = [];
|
||||
|
||||
try {
|
||||
assistantSchema.parse(config);
|
||||
assistantRolledSchema.parse(config);
|
||||
} catch (e: any) {
|
||||
return [
|
||||
{
|
||||
|
|
@ -26,6 +28,9 @@ export function validateConfigYaml(config: Assistant): ConfigValidationError[] {
|
|||
}
|
||||
|
||||
config.models?.forEach((model) => {
|
||||
if ("uses" in model) {
|
||||
return;
|
||||
}
|
||||
// Max tokens not too close to context length
|
||||
if (
|
||||
model.defaultCompletionOptions?.contextLength &&
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe("E2E Scenarios", () => {
|
|||
|
||||
const packageSecrets: Record<string, string> = {
|
||||
"test-org/assistant/ANTHROPIC_API_KEY": "sk-ant",
|
||||
"test-org/models/GEMINI_API_KEY": "gemini-api-key",
|
||||
"test-org/gemini/GEMINI_API_KEY": "gemini-api-key",
|
||||
};
|
||||
|
||||
const proxyEnvSecrets: Record<string, string> = {
|
||||
|
|
@ -100,22 +100,24 @@ describe("E2E Scenarios", () => {
|
|||
);
|
||||
|
||||
// Test that packages were correctly unrolled and params replaced
|
||||
expect(unrolledConfig.models?.length).toBe(4);
|
||||
expect(unrolledConfig.models?.length).toBe(3);
|
||||
expect(unrolledConfig.models?.[0].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/OPENAI_API_KEY }}",
|
||||
);
|
||||
expect(unrolledConfig.models?.[1].apiKey).toBe("sk-456");
|
||||
expect(unrolledConfig.models?.[2].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/test-org/models/ANTHROPIC_API_KEY }}",
|
||||
expect(unrolledConfig.models?.[1].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/test-org/gemini/GEMINI_API_KEY }}",
|
||||
);
|
||||
expect(unrolledConfig.models?.[3].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/test-org/models/GEMINI_API_KEY }}",
|
||||
expect(unrolledConfig.models?.[2].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/ANTHROPIC_API_KEY }}",
|
||||
);
|
||||
|
||||
expect(unrolledConfig.rules?.length).toBe(3);
|
||||
expect(unrolledConfig.rules?.length).toBe(2);
|
||||
expect(unrolledConfig.docs?.[0].startUrl).toBe(
|
||||
"https://docs.python.org/release/3.13.1",
|
||||
);
|
||||
expect(unrolledConfig.docs?.[0].rootUrl).toBe(
|
||||
"https://docs.python.org/release/3.13.1",
|
||||
);
|
||||
|
||||
const clientRendered = await clientRender(
|
||||
YAML.stringify(unrolledConfig),
|
||||
|
|
@ -126,19 +128,18 @@ describe("E2E Scenarios", () => {
|
|||
// Test that user secrets were injected and others were changed to use proxy
|
||||
const anthropicSecretLocation =
|
||||
"package:test-org/assistant/ANTHROPIC_API_KEY";
|
||||
const geminiSecretLocation = "package:test-org/models/GEMINI_API_KEY";
|
||||
const geminiSecretLocation = "package:test-org/gemini/GEMINI_API_KEY";
|
||||
expect(clientRendered.models?.[0].apiKey).toBe("sk-123");
|
||||
expect(clientRendered.models?.[1].apiKey).toBe("sk-456");
|
||||
expect(clientRendered.models?.[1].provider).toBe("continue-proxy");
|
||||
expect((clientRendered.models?.[1] as any).apiKeyLocation).toBe(
|
||||
geminiSecretLocation,
|
||||
);
|
||||
expect(clientRendered.models?.[1].apiKey).toBeUndefined();
|
||||
expect(clientRendered.models?.[2].provider).toBe("continue-proxy");
|
||||
expect((clientRendered.models?.[2] as any).apiKeyLocation).toBe(
|
||||
anthropicSecretLocation,
|
||||
);
|
||||
expect(clientRendered.models?.[2].apiKey).toBeUndefined();
|
||||
expect(clientRendered.models?.[3].provider).toBe("continue-proxy");
|
||||
expect((clientRendered.models?.[3] as any).apiKeyLocation).toBe(
|
||||
geminiSecretLocation,
|
||||
);
|
||||
expect(clientRendered.models?.[3].apiKey).toBeUndefined();
|
||||
|
||||
// Test that proxy can correctly resolve secrets
|
||||
const decodedAnthropicSecretLocation = decodeSecretLocation(
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
name: Assistant
|
||||
version: 0.0.1
|
||||
|
||||
packages:
|
||||
- uses: test-org/models
|
||||
docs:
|
||||
- uses: test-org/docs
|
||||
with:
|
||||
version: 3.13.1
|
||||
|
||||
rules:
|
||||
- uses: test-org/rules
|
||||
- Use KaTeX for math
|
||||
|
||||
models:
|
||||
- name: gpt-5
|
||||
|
|
@ -14,5 +16,13 @@ models:
|
|||
model: gpt-5
|
||||
apiKey: ${{ secrets.OPENAI_API_KEY }}
|
||||
|
||||
rules:
|
||||
- Use KaTeX for math
|
||||
- uses: test-org/gemini
|
||||
override:
|
||||
contextLength: 500000
|
||||
defaultCompletionOptions:
|
||||
topP: 1.0
|
||||
apiBase: https://example.com
|
||||
|
||||
- uses: test-org/claude35sonnet
|
||||
with:
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
name: Claude 3.5 sonnet latest
|
||||
version: 0.0.1
|
||||
|
||||
models:
|
||||
- name: claude-3-5-sonnet-latest
|
||||
provider: anthropic
|
||||
model: claude-3-5-sonnet-latest
|
||||
apiKey: ${{ inputs.ANTHROPIC_API_KEY }}
|
||||
|
|
@ -3,5 +3,5 @@ version: 0.0.1
|
|||
|
||||
docs:
|
||||
- name: Python
|
||||
startUrl: https://docs.python.org/release/${{ params.version }}
|
||||
rootUrl: https://docs.python.org/release/${{ params.version }}
|
||||
startUrl: https://docs.python.org/release/${{ inputs.version }}
|
||||
rootUrl: https://docs.python.org/release/${{ inputs.version }}
|
||||
|
|
|
|||
11
packages/config-yaml/test/packages/test-org/gemini.yaml
Normal file
11
packages/config-yaml/test/packages/test-org/gemini.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
name: Gemini
|
||||
version: 0.0.1
|
||||
|
||||
models:
|
||||
- name: gemini
|
||||
provider: gemini
|
||||
model: gemini
|
||||
apiKey: ${{ secrets.GEMINI_API_KEY }}
|
||||
defaultCompletionOptions:
|
||||
temperature: 0.7
|
||||
contextLength: 1000000
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
name: Models
|
||||
version: 0.0.1
|
||||
|
||||
models:
|
||||
- name: gpt-4
|
||||
provider: openai
|
||||
model: gpt-4
|
||||
apiKey: sk-456
|
||||
|
||||
- name: claude-3-5-sonnet-latest
|
||||
provider: anthropic
|
||||
model: claude-3-5-sonnet-latest
|
||||
apiKey: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
- name: gemini
|
||||
provider: gemini
|
||||
model: gemini
|
||||
apiKey: ${{ secrets.GEMINI_API_KEY }}
|
||||
|
|
@ -3,4 +3,3 @@ version: 0.0.1
|
|||
|
||||
rules:
|
||||
- Be kind
|
||||
- Be concise
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue