add prompt reader
This commit is contained in:
parent
7098382317
commit
be641197b5
@ -783,4 +783,14 @@ export class TaskLoop {
|
||||
settings: _settings
|
||||
}
|
||||
}
|
||||
|
||||
public async getPrompt(promptId: string, args: Record<string, any>) {
|
||||
const prompt = await mcpClientAdapter.readPromptTemplate(promptId, args);
|
||||
return prompt;
|
||||
}
|
||||
|
||||
public async getResource(resourceUri: string) {
|
||||
const resource = await mcpClientAdapter.readResource(resourceUri);
|
||||
return resource;
|
||||
}
|
||||
}
|
36
resources/openmcp-sdk-release/task-loop.d.ts
vendored
36
resources/openmcp-sdk-release/task-loop.d.ts
vendored
@ -5,25 +5,25 @@ export type ChatCompletionChunk = OpenAI.Chat.Completions.ChatCompletionChunk;
|
||||
export type ChatCompletionCreateParamsBase = OpenAI.Chat.Completions.ChatCompletionCreateParams & { id?: string };
|
||||
|
||||
interface SchemaProperty {
|
||||
title: string;
|
||||
type: string;
|
||||
description?: string;
|
||||
title: string;
|
||||
type: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface InputSchema {
|
||||
type: string;
|
||||
properties: Record<string, SchemaProperty>;
|
||||
required?: string[];
|
||||
title?: string;
|
||||
$defs?: any;
|
||||
type: string;
|
||||
properties: Record<string, SchemaProperty>;
|
||||
required?: string[];
|
||||
title?: string;
|
||||
$defs?: any;
|
||||
}
|
||||
|
||||
interface ToolItem {
|
||||
name: string;
|
||||
description: string;
|
||||
inputSchema: InputSchema;
|
||||
name: string;
|
||||
description: string;
|
||||
inputSchema: InputSchema;
|
||||
enabled: boolean;
|
||||
anyOf?: any;
|
||||
anyOf?: any;
|
||||
}
|
||||
|
||||
interface IExtraInfo {
|
||||
@ -87,7 +87,7 @@ export interface ToolCall {
|
||||
export interface ToolCallContent {
|
||||
type: string;
|
||||
text: string;
|
||||
[key: string]: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface ToolCallResult {
|
||||
@ -290,6 +290,16 @@ export class TaskLoop {
|
||||
* @description Create single conversation context
|
||||
*/
|
||||
createStorage(settings?: ChatSetting): Promise<ChatStorage>;
|
||||
|
||||
/**
|
||||
* @description Get prompt template from mcp server
|
||||
*/
|
||||
getPrompt(promptId: string, args: Record<string, any>): Promise<string>;
|
||||
|
||||
/**
|
||||
* @description Get resource template from mcp server
|
||||
*/
|
||||
getResource(resourceUri: string): Promise<string>;
|
||||
}
|
||||
|
||||
export declare const getToolSchema: any;
|
||||
|
@ -164,7 +164,8 @@ interface StdioMCPConfig {
|
||||
[key: string]: string;
|
||||
};
|
||||
description?: string;
|
||||
prompt?: string;
|
||||
prompts?: string[];
|
||||
resources?: string[];
|
||||
}
|
||||
|
||||
interface HttpMCPConfig {
|
||||
@ -174,7 +175,8 @@ interface HttpMCPConfig {
|
||||
[key: string]: string;
|
||||
};
|
||||
description?: string;
|
||||
prompt?: string;
|
||||
prompts?: string[];
|
||||
resources?: string[];
|
||||
}
|
||||
|
||||
export interface OmAgentConfiguration {
|
||||
@ -255,8 +257,7 @@ export class OmAgent {
|
||||
* "OPENMEMORY_API_KEY": "YOUR_API_KEY",
|
||||
* "CLIENT_NAME": "openmemory"
|
||||
* },
|
||||
* "description": "A MCP for long-term memory support",
|
||||
* "prompt": "You are a helpful assistant."
|
||||
* "description": "A MCP for long-term memory support"
|
||||
* }
|
||||
* },
|
||||
* "defaultLLM": {
|
||||
@ -287,7 +288,6 @@ export class OmAgent {
|
||||
connectionType: 'STDIO',
|
||||
env: mcpConfig.env,
|
||||
description: mcpConfig.description,
|
||||
prompt: mcpConfig.prompt,
|
||||
});
|
||||
} else {
|
||||
const connectionType: ConnectionType = mcpConfig.type === 'http' ? 'STREAMABLE_HTTP' : 'SSE';
|
||||
@ -296,12 +296,18 @@ export class OmAgent {
|
||||
env: mcpConfig.env,
|
||||
connectionType,
|
||||
description: mcpConfig.description,
|
||||
prompt: mcpConfig.prompt,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Add MCP server
|
||||
*/
|
||||
public addMcpServer(connectionArgs: IConnectionArgs) {
|
||||
this._adapter.addMcp(connectionArgs);
|
||||
}
|
||||
|
||||
private async getLoop(loopOption?: TaskLoopOptions) {
|
||||
if (this._loop) {
|
||||
return this._loop;
|
||||
@ -324,6 +330,12 @@ export class OmAgent {
|
||||
this._defaultLLM = option;
|
||||
}
|
||||
|
||||
public async getPrompt(promptId: string, args: Record<string, any>) {
|
||||
const loop = await this.getLoop();
|
||||
const prompt = await loop.getPrompt(promptId, args);
|
||||
return prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Asynchronous invoking agent by string or messages
|
||||
* @param messages Chat message or string
|
||||
|
10
service/task-loop.d.ts
vendored
10
service/task-loop.d.ts
vendored
@ -290,6 +290,16 @@ export class TaskLoop {
|
||||
* @description Create single conversation context
|
||||
*/
|
||||
createStorage(settings?: ChatSetting): Promise<ChatStorage>;
|
||||
|
||||
/**
|
||||
* @description Get prompt template from mcp server
|
||||
*/
|
||||
getPrompt(promptId: string, args: Record<string, any>): Promise<string>;
|
||||
|
||||
/**
|
||||
* @description Get resource template from mcp server
|
||||
*/
|
||||
getResource(resourceUri: string): Promise<string>;
|
||||
}
|
||||
|
||||
export declare const getToolSchema: any;
|
||||
|
Loading…
x
Reference in New Issue
Block a user