MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / generation_handler

Method generation_handler

tensorrt_llm/scaffolding/worker.py:103–116  ·  view source on GitHub ↗
(self, task: GenerationTask)

Source from the content-addressed store, hash-verified

101 task.output_tokens = response.choices[0].token_ids
102
103 async def generation_handler(self, task: GenerationTask) -> TaskStatus:
104 params = self.convert_task_params(task)
105
106 # Make the API call
107 try:
108 response = await self.async_client.completions.create(**params)
109 self.fill_generation_task_with_response(task, response)
110
111 return TaskStatus.SUCCESS
112
113 except Exception as e:
114 # Handle errors
115 print('Openai client get exception: ' + str(e))
116 return TaskStatus.WORKER_EXECEPTION
117
118 def shutdown(self):
119 # OpenAI client doesn't require explicit cleanup

Callers

nothing calls this directly

Calls 3

convert_task_paramsMethod · 0.95
createMethod · 0.45

Tested by

no test coverage detected