Urgent.News

What's breaking now, across thousands of outlets.

AI

Wrap AI CLI into OpenAI compatible API: from stdin, JSON output to timeout handling (with runnable examples)

In a nutshell, connecting CLI to HTTP revolves around input, program lifecycle, and output format; the path /v1/chat/completions does not represent full protocol support. The problem encountered was that there was already an AI CLI in the terminal that could answer questions, but the program to be connected only sent HTTP requests, and the two were speaking different languages. The initial thought was to run the CLI once after receiving the question and then return the answer. However, it was only when the actual connection was attempted that it was discovered that the areas prone to errors were all in the middle: how to pass long prompts? Which part of the JSON printed by the CLI was the answer? How long should HTTP wait when the command was stuck? This article condensed the actual practices used in packaging services into an example that could run locally. First, a fake CLI was used to verify the process and protocol, which did not require model keys and would not consume model usage. The Python packaging process was tested, and no real model was called during this test. When replacing with a real CLI, login, flags, and output format still needed to be verified separately. First, decide where to be compatible. The example only accepted one text user message and returned a complete JSON once. …

Translated from Chinese Read in Chinese

An article discusses connecting a Command-Line Interface (CLI) to HTTP, specifically implementing a chat completion service. The example provided uses a fake CLI and a Python script to wrap the service, allowing an HTTP client to send a text message and receive a response in JSON format. The service only supports a limited set of features, including a single text user message and a fixed model named "cli-demo", and does not support streaming, multiple tool calls, or other parameters.

The implementation follows the OpenAI Chat Completions API, but only partially. The example code is written in Python and can be run locally without using a real model.

Written by urgent.news from Dev.to's report — not a translation of it. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Bridging Context and Execution: An Engineering Assessment of Connected AI Workflows

Every engineering leader managing modern distributed systems eventually hits the same bottleneck: context fragmentation. Teams communicate decisions across Slack threads, Google Meets, Jira tickets…

  • Engineering teams struggle with context fragmentation across platforms.
  • AI initially seen as standalone tool, not integrated workflow.
  • GeekyAnts team analyzes architectural breakdown and execution challenges.

South Korea, Australia Deepen AI, Minerals Ties

The Korea Trade-Investment Promotion Agency, or KOTRA, held a regular consultation meeting with the Australian Trade and Investment Commission, Austrade, in Sydney, Australia, on Nov.

  • South Korea and Australia held AI, minerals cooperation meeting on November 5, 2023
  • Meeting aimed to explore AI, advanced industry supply chains, core minerals collaboration
  • Identified data center equipment, cybersecurity, industrial AI cooperation areas

More from Thursday 5 November →