跳转到主要内容
POST
/
v1
/
answers
创建答案
curl --request POST \
  --url https://api.olostep.com/v1/answers \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "task": "<string>",
  "json_format": {}
}
'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "metadata": {},
  "task": "<string>",
  "result": {
    "json_content": "<string>",
    "json_hosted_url": "<string>"
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.olostep.com/llms.txt

Use this file to discover all available pages before exploring further.

创建答案

使用此端点创建一个新的答案。

请求

路径 POST /v1/answers 参数
名称类型描述
questionstring需要回答的问题文本。
contextstring提供答案的上下文信息。

响应

成功的响应将返回一个包含答案的 JSON 对象。

示例

import { useState } from 'react';

function CreateAnswerExample() {
  const [question, setQuestion] = useState('');
  const [context, setContext] = useState('');
  const [answer, setAnswer] = useState(null);

  const createAnswer = async () => {
    const response = await fetch('/v1/answers', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ question, context }),
    });
    const data = await response.json();
    setAnswer(data.answer);
  };

  return (
    <div>
      <input
        type="text"
        placeholder="输入你的问题"
        value={question}
        onChange={(e) => setQuestion(e.target.value)}
      />
      <textarea
        placeholder="输入上下文"
        value={context}
        onChange={(e) => setContext(e.target.value)}
      />
      <button onClick={createAnswer}>创建答案</button>
      {answer && <div>答案: {answer}</div>}
    </div>
  );
}
在上面的示例中,用户可以输入一个问题和相关的上下文,然后点击“创建答案”按钮来获取答案。

授权

Authorization
string
header
必填

Bearer 认证头格式为 Bearer ,其中 是你的认证令牌。

请求体

application/json
task
string
必填

要执行的任务。

json_format
object

期望的输出 JSON 对象,带有空值作为模式,或者简单地描述你想要的数据作为字符串。

响应

成功响应并返回答案。

id
string
object
string
created
integer
metadata
object
task
string
result
object