import openai prompt = CustomPromptTemplate( template=template, tools=tools, This omits…
- User
import openai
prompt = CustomPromptTemplate( template=template, tools=tools, # This omits the `agent_scratchpad`, `tools`, and `tool_names` variables because those are generated dynamically # This includes the `intermediate_steps` variable because that is needed input_variables=["input", "intermediate_steps"] ) output_parser = CustomOutputParser() openai.api_key = "EMPTY" # Not support yet # openai.api_base = "http://i-2.gpushare.com:43036/v1" # model_name = "StableBeluga-13B" # model_name = "chatglm2-6b" # openai.api_base = "http://i-2.gpushare.com:42054/v1" openai.api_base = "http://i-2.gpushare.com:20778/v1" # model_name = "SFT_Model" # model_name = "openbuddy-llama2-13b-v11.1-bf16" model_name = "izdax-llama2-7b-v1-chat" llm = OpenAI(model=model_name, openai_api_key=openai.api_key, openai_api_base=openai.api_base) # LLM chain consisting of the LLM and a prompt llm_chain = LLMChain(llm=llm, prompt=prompt) tool_names = [tool.name for tool in tools] agent = LLMSingleActionAgent( llm_chain=llm_chain, output_parser=output_parser, stop=["\nObservation:"], allowed_tools=tool_names ) # print(agent.llm_chain.prompt.template) agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True) 我想查看最终的prompt 我该如何查看 类似这种template = """Respond to the human as helpfully and accurately as possible. You have access to the following tools:terminal: Run shell commands on this MacOS machine., args: {{{{'commands': {{{{'title': 'Commands', 'description': 'List of shell commands to run. Deserialized using json.loads', 'anyOf': [{{{{'type': 'string'}}}}, {{{{'type': 'array', 'items': {{{{'type': 'string'}}}}}}}}]}}}}}}}} get_time: get_time(text: str = '') -> str - Returns todays date, use this for any questions related to knowing todays date . this input should always be an empty string, and this function will always return todays date - any date mathmatics should occur outside this function., args: {{{{'text': {{{{'title': 'Text', 'default': '', 'type': 'string'}}}}}}}} Search: Search(query: str, top_n: int) -> dict - A wrapper around film search plugin. Useful for when you need to answer questions about films or other movies., args: {{{{'query': {{{{'title': 'Query', 'description': 'should be a chinese search query', 'type': 'string'}}}}, 'top_n': {{{{'title': 'Top N', 'description': 'should be a integer number that agent want to get If you cannot find a number, should be 10', 'type': 'integer'}}}}}}}} text_to_image: text_to_image(query, top_n: int) -> dict - A wrapper around Text To Image plugin. Useful for when you need to generate image., args: {{{{'query': {{{{'title': 'Query', 'description': 'should be a chinese search query', 'type': 'string'}}}}, 'top_n': {{{{'title': 'Top N', 'description': 'should be a integer number that agent want to get If you cannot find a number, should be 3', 'type': 'integer'}}}}}}}} weather_info: weather_info(city_name: str, time_str: str) -> dict - A wrapper around weather info plugin. Useful for when you need to get weather info., args: {{{{'city_name': {{{{'title': 'City Name', 'description': 'should be a chinese city name if you cannot find a name should be 乌鲁木齐', 'type': 'string'}}}}, 'time_str': {{{{'title': 'Time Str', 'description': 'should be a time str that like 20230726', 'type': 'string'}}}}}}}} qa: qa(query: str) -> dict - A wrapper around QA plugin. input should be a chinese search query Useful for when you need to get answer., args: {{{{'query': {{{{'title': 'Query', 'type': 'string'}}}}}}}}
- Assistant
The code you have provided sets up an agent for executing actions with various tools. The prompt you're wanting to view seems to be part of the
CustomPromptTemplatewhich appears to be custom, and therefore isn't shown in Python's standard library or in the OpenAI library.The template you've provided at the end looks like a structured communication protocol for an AI model to interact with various tools and provide a response. It guides the model to ask questions, think, take actions (like running commands, searching, or getting weather information), observe the results, and iteratively refine its responses.
If you're looking to view the final prompt that has been generated by your
promptvariable, you would simply need to print it. Assuming that in your custom classes (CustomPromptTemplateandLLMChain) you've implemented features to convert the template into the final prompt dynamically, you'd do the following:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.