@@ -46,7 +46,17 @@ def generate_yaml(self, conversation, string, **kwargs):
4646
4747 bare_llm = get_watsonx_predictor (model = model )
4848
49- prompt_instructions = PromptTemplate .from_template ("{string}\n " )
49+ prompt_instructions = PromptTemplate .from_template (
50+ """Instructions:
51+ - Produce only a yaml response to the user request
52+ - Do not augment the response with markdown or other formatting beyond standard yaml formatting
53+ - Only provide a single yaml object containg a single resource type in your response, do not provide multiple yaml objects
54+
55+ User Request: {string}
56+ """
57+ )
58+
59+
5060 llm_chain = LLMChain (llm = bare_llm , verbose = verbose , prompt = prompt_instructions )
5161
5262 task_query = prompt_instructions .format (string = string )
@@ -56,18 +66,19 @@ def generate_yaml(self, conversation, string, **kwargs):
5666 response = llm_chain (inputs = {"string" : string })
5767
5868 # https://stackoverflow.com/a/63082323/2328066
59- regex = r"(?:\n+|\A)?(?P<code_block>\`{3,}yaml\n+[\S\s]*\`{3,})"
60-
61- match = re .search (regex , response ["text" ])
62-
63- if match :
64- clean_response = match .group ("code_block" )
65- self .logger .info (conversation + " generated yaml: " + clean_response )
66- return clean_response
67- else :
68- # TODO: need to do the right thing here - raise an exception?
69- self .logger .error (conversation + " could not parse response:\n " + response ["text" ])
70- return "some failure"
69+ # regex = r"(?:\n+|\A)?(?P<code_block>\`{3,}yaml\n+[\S\s]*\`{3,})"
70+
71+ # match = re.search(regex, response["text"])
72+
73+ # if match:
74+ # clean_response = match.group("code_block")
75+ # self.logger.info(conversation + " generated yaml: " + clean_response)
76+ # return clean_response
77+ # else:
78+ # # TODO: need to do the right thing here - raise an exception?
79+ # self.logger.error(conversation + " could not parse response:\n"+ response["text"])
80+ # return "some failure"
81+ return response ["text" ]
7182
7283if __name__ == "__main__" :
7384 """to execute, from the repo root, use python -m modules.yaml_generator"""
0 commit comments