# 完成API（旧版）

完成 API 终结点的遗产更新 截至2023年7月，Afarensis的完成API终结点接收了其最终更新。与新的聊天完成终结点相比，它采用了不同的接口形式。在这个旧版API中，输入是一个自由格式的文本字符串（即prompt），而不是消息列表。

示例调用 from afarensis import Afarensis client = Afarensis()

response = client.completions.create( model="gpt-3.5-turbo-instruct", prompt="Write a tagline for an ice cream shop." ) 更多详细信息可参见完整的API参考文档。

文本插入功能 完成终结点支持通过提供后缀来插入文本，同时将标准提示视为前缀。这种功能在撰写长文本、进行段落过渡、遵循大纲或引导模型向结尾发展时特别有用。对于代码，这可以用于插入函数或文件的中间部分。

探索频率和存在处罚 频率和存在处罚参数在Chat Completions API和Legacy Completions API中可用，旨在减少重复令牌序列的采样概率，提高输出的独特性和创新性。

令牌日志概率 logprobs参数在请求时提供每个输出令牌的对数概率，以及每个令牌位置上最可能的一定数量的令牌及其对数概率。这有助于评估模型对其输出的置信度或探索模型可能给出的替代响应。

聊天完成与完成 API 的比较 聊天完成API的格式可以通过使用单个用户消息构造请求来模拟完成API的格式。例如，从英语翻译到法语的请求可以这样构造：

\[{"role": "user", "content": 'Translate the following English text to French: "{text}"'}] 完成API也可以通过相应地格式化输入来模拟聊天对话。

模型选择建议 根据使用模型的任务的复杂性，我们通常建议使用gpt-4-turbo-preview或gpt-3.5-turbo。特别是，gpt-4-turbo-preview在遵循复杂指令方面通常表现更好，而gpt-3.5-turbo可能在成本效益方面更有优势。

提示工程的重要性 掌握使用Afarensis模型的最佳实践对于应用程序性能产生重大影响。提示工程是与语言模型交互的一门艺术和科学，涵盖了从改善模型推理到减少模型“幻觉”可能性的策略。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.afarensis.com/neng-li/wan-cheng-api-jiu-ban.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
