MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / run

Method run

eval_heldout/rewoo/nodes/Worker.py:156–180  ·  view source on GitHub ↗
(self, input, log=False)

Source from the content-addressed store, hash-verified

154 "yourself. Input can be any instruction."
155
156 def run(self, input, log=False):
157 assert isinstance(input, self.input_type)
158 if self.model in {'gpt-3.5-turbo', 'gpt-4'}:
159 llm = OpenAIChat(temperature=0, model=self.model)
160 prompt = PromptTemplate(template="Respond in short directly with no extra words.\n\n{request}",
161 input_variables=["request"])
162 tool = LLMChain(prompt=prompt, llm=llm, verbose=False)
163 response = tool(input)
164 evidence = response["text"].strip("\n")
165 assert isinstance(evidence, self.output_type)
166 if log:
167 return {"input": response["request"], "output": response["text"]}
168 return evidence
169 else:
170 conv = get_conversation_template('llama-2')
171 conv.set_system_message("You are a helpful, respectful and honest assistant.")
172 conv.append_message(conv.roles[0], f'Responds in short directly with no extra words.\n\n{input}')
173 conv.append_message(conv.roles[1], None)
174 prompt = conv.get_prompt()
175 response = llm_llama(prompt)
176 evidence = response.strip('\n')
177 assert isinstance(evidence, self.output_type)
178 if log:
179 return {"input": prompt, "output": evidence}
180 return evidence
181
182
183class ZipCodeRetriever(Node):

Callers 3

runMethod · 0.45
runMethod · 0.45
runMethod · 0.45

Calls 2

llm_llamaFunction · 0.90
get_promptMethod · 0.80

Tested by

no test coverage detected