القرارات
استخراج القيم
استخرج قيمًا ذات أنواع محددة من النصوص والصور.
POST
/
extractions
استخراج قيم محددة النوع
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
input: '<string>',
fields: {},
images: [{base64: '<string>'}],
reference_date: '2023-12-25'
})
};
fetch('https://api.phaseo.app/v1/extractions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/extractions"
payload = {
"model": "<string>",
"input": "<string>",
"fields": {},
"images": [{ "base64": "<string>" }],
"reference_date": "2023-12-25"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.phaseo.app/v1/extractions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": "<string>",
"fields": {},
"images": [
{
"base64": "<string>"
}
],
"reference_date": "2023-12-25"
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/extractions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"fields\": {},\n \"images\": [\n {\n \"base64\": \"<string>\"\n }\n ],\n \"reference_date\": \"2023-12-25\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.phaseo.app/v1/extractions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"fields\": {},\n \"images\": [\n {\n \"base64\": \"<string>\"\n }\n ],\n \"reference_date\": \"2023-12-25\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/extractions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'input' => '<string>',
'fields' => [
],
'images' => [
[
'base64' => '<string>'
]
],
'reference_date' => '2023-12-25'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.phaseo.app/v1/extractions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"fields\": {},\n \"images\": [\n {\n \"base64\": \"<string>\"\n }\n ],\n \"reference_date\": \"2023-12-25\"\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"answers": {},
"truncated": true,
"usage": {
"input_tokens": 1,
"output_tokens": 0,
"total_tokens": 1
}
}الاستخراج في مرحلة المعاينة. يعتمد توفر النماذج على مسارات المزوّدين المكوّنة.
fields التي تريدها وأرسلها مع النص المصدر إلى POST /v1/extractions لتحصل على قيم ذات أنواع محددة، مثل رقم فاتورة أو تاريخ أو إجمالي. للاختيار من بين خيارات معروفة بدلًا من ذلك، استخدم Decisions.
curl https://api.phaseo.app/v1/extractions \
-H "Authorization: Bearer $PHASEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cloudflare/clairic",
"input": "Invoice INV-2291: 4 pallets at $250 each, shipping $80.",
"fields": {
"invoice_number": { "type": "text" },
"total": { "type": "number", "decimals": 2, "instructions": "Total including shipping" }
}
}'
import { Phaseo } from "@phaseo/sdk";
const client = new Phaseo({ apiKey: process.env.PHASEO_API_KEY });
const result = await client.extractions.create({
model: "cloudflare/clairic",
input: "Invoice INV-2291: 4 pallets at $250 each, shipping $80.",
fields: {
invoice_number: { type: "text" },
total: { type: "number", decimals: 2, instructions: "Total including shipping" },
},
});
console.log(result.answers.total.value);
import os
from phaseo import Phaseo
client = Phaseo(api_key=os.environ["PHASEO_API_KEY"])
result = client.extractions.create({
"model": "cloudflare/clairic",
"input": "Invoice INV-2291: 4 pallets at $250 each, shipping $80.",
"fields": {"total": {"type": "number", "decimals": 2,
"instructions": "Total including shipping"}},
})
print(result["answers"]["total"]["value"])
AsyncPhaseo في Python أيضًا
await client.extractions.create(...).
أنواع الحقول
الأنواع المدعومة هيtext وnumber وdate وtime وdatetime وduration و
list. تتطلب القوائم items: "text" أو "number" أو "date". قدّم من 1 إلى 64 حقلًا
و16,384 حرفًا مصدريًا على الأكثر. تبدأ أسماء الحقول بحرف أو شرطة سفلية،
وتحتوي حتى 64 حرفًا من الأحرف أو الأرقام أو الشرطات السفلية أو النقاط أو الشرطات.
تدعم الأرقام والمدد integer وdecimals (0–6). تقبل المدد
seconds وminutes وhours وdays وweeks وmonths وyears. اضبط
reference_date عندما يعتمد تفسير التواريخ غير المكتملة على سنة محددة.
تستخدم مدخلات الصور كائنات { content_type, base64 }: أربع صور PNG/JPEG/WebP على الأكثر،
4 MiB لكل منها و8 MiB مجتمعة بعد فك الترميز. حد الطلب 16 MiB.
العناوين البعيدة وملفات PDF والصوت والفيديو والتقديرات والتنبؤات والبث غير مدعومة.
اقرأ الإجابات
اقرأanswers[field_name].value. قد تكون القيمة المفردة null عندما لا يحددها
المصدر. p_null هو احتمال النموذج لقيمة غير محددة؛
وconfidence درجة منفصلة يبلغ عنها النموذج. توفّر القوائم الثقة بدون
p_null. لا تضمن هذه الدرجات الصحة: اختر عتبات المراجعة المناسبة
لعبء العمل لديك. القائمة الفارغة الصالحة تختلف عن الطلب الفاشل.
تعني truncated: true أن المزوّد لم يعالج كل الإدخال المصدري. راجع الإدخال أو
أعد إرساله بطول أقصر قبل الاعتماد على اكتماله. لا تُتاح إزاحات النص ولا التخمينات الخام.
ينبغي إجراء العمليات الحسابية المعقدة في شيفرة التطبيق.
تجمع تقارير الاستخدام input_tokens عبر تمريرات المزوّد. tokens الإخراج
صفر. استخدم التسعير الذي يُرجعه الـ Gateway بدلًا من تقدير التكلفة من طول المصدر
أو ضرب الاستخدام في عدد الحقول.الجسم
application/json
آخر تعديل في ١٦ نوفمبر ٢٠٢٦
هل كانت هذه الصفحة مفيدة؟
⌘I
استخراج قيم محددة النوع
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
input: '<string>',
fields: {},
images: [{base64: '<string>'}],
reference_date: '2023-12-25'
})
};
fetch('https://api.phaseo.app/v1/extractions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/extractions"
payload = {
"model": "<string>",
"input": "<string>",
"fields": {},
"images": [{ "base64": "<string>" }],
"reference_date": "2023-12-25"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.phaseo.app/v1/extractions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": "<string>",
"fields": {},
"images": [
{
"base64": "<string>"
}
],
"reference_date": "2023-12-25"
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/extractions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"fields\": {},\n \"images\": [\n {\n \"base64\": \"<string>\"\n }\n ],\n \"reference_date\": \"2023-12-25\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.phaseo.app/v1/extractions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"fields\": {},\n \"images\": [\n {\n \"base64\": \"<string>\"\n }\n ],\n \"reference_date\": \"2023-12-25\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/extractions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'input' => '<string>',
'fields' => [
],
'images' => [
[
'base64' => '<string>'
]
],
'reference_date' => '2023-12-25'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.phaseo.app/v1/extractions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"fields\": {},\n \"images\": [\n {\n \"base64\": \"<string>\"\n }\n ],\n \"reference_date\": \"2023-12-25\"\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"answers": {},
"truncated": true,
"usage": {
"input_tokens": 1,
"output_tokens": 0,
"total_tokens": 1
}
}