MCPcopy Index your code
hub / github.com/InternLM/InternLM / generate

Method generate

tools/pal_inference.py:150–165  ·  view source on GitHub ↗
(self, prompt)

Source from the content-addressed store, hash-verified

148 self.verbose = verbose
149
150 def generate(self, prompt):
151 # The api will generate response word by word
152 # we only need the last generation as the final results
153 for cur_gen in generate_interactive(
154 model=self.model,
155 tokenizer=self.tokenizer,
156 prompt=prompt,
157 additional_eos_token_id=self.additional_eos_token_id,
158 **asdict(self.generation_config),
159 ):
160 continue
161 # Get final response
162 self.history.append(cur_gen)
163 # Extract code block
164 code = self.process_generation_to_code(cur_gen)
165 return code
166
167 def process_generation_to_code(self, gens: str):
168 if "```python" in gens:

Callers 3

runMethod · 0.95
chatMethod · 0.45

Calls 2

generate_interactiveFunction · 0.90

Tested by

no test coverage detected