MCPcopy Create free account
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / to_jsonl_line

Method to_jsonl_line

scrapegraphai/utils/batch_api.py:50–67  ·  view source on GitHub ↗

Convert to a JSONL line for the Batch API input file.

(self)

Source from the content-addressed store, hash-verified

48 """Optional response format (e.g., {"type": "json_object"})."""
49
50 def to_jsonl_line(self) -> str:
51 """Convert to a JSONL line for the Batch API input file."""
52 body = {
53 "model": self.model,
54 "messages": self.messages,
55 "temperature": self.temperature,
56 }
57 if self.max_tokens is not None:
58 body["max_tokens"] = self.max_tokens
59 if self.response_format is not None:
60 body["response_format"] = self.response_format
61
62 return json.dumps({
63 "custom_id": self.custom_id,
64 "method": "POST",
65 "url": "/v1/chat/completions",
66 "body": body,
67 })
68
69
70@dataclass

Calls

no outgoing calls