-
Notifications
You must be signed in to change notification settings - Fork 5k
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
想在使用文件对话时使用自己的提示词,想要的回答时结构化的格式输出,我在自定义提示词的时候如何写我需要结构化方式的回答? #4030
Comments
To customize your prompt for structured format responses in file dialogs, you can use Python's
Example code snippet to illustrate these steps: class CustomPromptTemplate(StringPromptTemplate):
template: str
tools: List[Tool]
def format(self, **kwargs) -> str:
# Example of adding intermediate steps and tool descriptions
kwargs["agent_scratchpad"] = "\n".join([f"Thought: {action.log}" for action, _ in kwargs.get("intermediate_steps", [])])
kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools])
return self.template.format(**kwargs)
# Rendering the custom prompt
custom_prompt_template = CustomPromptTemplate(template="Your custom prompt here with variables like {input}")
rendered_prompt = custom_prompt_template.format(input="Your specific question or input")
# Simulate getting a structured response
def get_response_for_custom_prompt(prompt):
# Logic to process the prompt and return a structured response
return {"action": "ExampleAction", "data": "ExampleData"}
# Handling the structured response
response = get_response_for_custom_prompt(rendered_prompt)
print(response) This approach allows you to dynamically generate prompts tailored to your needs and handle responses in a structured format, facilitating easier parsing and processing of the data.
|
插眼 |
prompt_config.py里改提示词,我把中文的改成英文了,这样老外可以看到英文回复 |
我想以xxx:xxx |
没明白你的意思,能具体些? |
1-prompt中举例说明回复格式 |
No description provided.
The text was updated successfully, but these errors were encountered: