mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 14:32:31 +08:00
docs: update docs
This commit is contained in:
@@ -36,15 +36,6 @@ func (h *MCPHost) NewChat(ctx context.Context, systemPromptFile string) (*Chat,
|
||||
return nil, errors.Wrap(code.LLMPrepareRequestError, err.Error())
|
||||
}
|
||||
|
||||
// Create markdown renderer
|
||||
renderer, err := glamour.NewTermRenderer(
|
||||
glamour.WithStandardStyle(styles.TokyoNightStyle),
|
||||
glamour.WithWordWrap(getTerminalWidth()),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to create markdown renderer")
|
||||
}
|
||||
|
||||
// Load system prompt from file if provided
|
||||
systemPrompt := "chat to interact with MCP tools"
|
||||
if systemPromptFile != "" {
|
||||
@@ -57,17 +48,25 @@ func (h *MCPHost) NewChat(ctx context.Context, systemPromptFile string) (*Chat,
|
||||
}
|
||||
}
|
||||
|
||||
// convert MCP tools to eino tool infos
|
||||
// Convert MCP tools to eino tool infos
|
||||
einoTools, err := h.GetEinoToolInfos(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get eino tool infos")
|
||||
}
|
||||
|
||||
toolCallingModel, err := model.WithTools(einoTools)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(code.LLMPrepareRequestError, err.Error())
|
||||
}
|
||||
|
||||
// Create markdown renderer
|
||||
renderer, err := glamour.NewTermRenderer(
|
||||
glamour.WithStandardStyle(styles.TokyoNightStyle),
|
||||
glamour.WithWordWrap(getTerminalWidth()),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to create markdown renderer")
|
||||
}
|
||||
|
||||
return &Chat{
|
||||
model: toolCallingModel,
|
||||
systemPrompt: systemPrompt,
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestNewChat(t *testing.T) {
|
||||
systemPromptFile := "test_system_prompt.txt"
|
||||
_ = os.WriteFile(systemPromptFile, []byte("You are a helpful assistant."), 0o644)
|
||||
_ = os.WriteFile(systemPromptFile, []byte("You are a helpful assistant."), 0o600)
|
||||
defer os.Remove(systemPromptFile)
|
||||
|
||||
host, err := NewMCPHost("./testdata/test.mcp.json")
|
||||
|
||||
@@ -122,7 +122,7 @@ func ConvertToolsToRecords(tools []MCPTools) []MCPToolRecord {
|
||||
|
||||
for _, tool := range mcpTools.Tools {
|
||||
// Generate unique ID by combining server name and tool name
|
||||
id := fmt.Sprintf("%s_%s", mcpTools.ServerName, tool.Name)
|
||||
id := fmt.Sprintf("%s__%s", mcpTools.ServerName, tool.Name)
|
||||
|
||||
// Extract docstring information
|
||||
info := extractDocStringInfo(tool.Description)
|
||||
@@ -172,7 +172,7 @@ func (h *MCPHost) ExportToolsToJSON(ctx context.Context, dumpPath string) error
|
||||
// create output directory
|
||||
outputDir := filepath.Dir(dumpPath)
|
||||
if outputDir != "." {
|
||||
if err := os.MkdirAll(outputDir, 0o755); err != nil {
|
||||
if err := os.MkdirAll(outputDir, 0o754); err != nil {
|
||||
return fmt.Errorf("failed to create output directory: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user