used api url from .env
This commit is contained in:
parent
032c902606
commit
d36dbb94d8
@ -56,40 +56,37 @@ const ChipDetection = ({ updateChipCount }) => {
|
|||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(process.env.EXPO_PUBLIC_API_URL, {
|
||||||
"https://api.openai.com/v1/chat/completions",
|
method: "POST",
|
||||||
{
|
headers: {
|
||||||
method: "POST",
|
Authorization: `Bearer ${process.env.EXPO_PUBLIC_API_KEY}`, // Use environment variable for API key
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${process.env.EXPO_PUBLIC_API_KEY}`,
|
},
|
||||||
"Content-Type": "application/json",
|
body: JSON.stringify({
|
||||||
},
|
model: process.env.EXPO_PUBLIC_MODEL_NAME, // Use environment variable for model name
|
||||||
body: JSON.stringify({
|
messages: [
|
||||||
model: process.env.EXPO_PUBLIC_MODEL_NAME,
|
{
|
||||||
messages: [
|
role: "system",
|
||||||
{
|
content:
|
||||||
role: "system",
|
"Identify and count poker chips by color. Return only the count for each color in JSON format.",
|
||||||
content:
|
},
|
||||||
"Identify and count poker chips by color. Return only the count for each color in JSON format.",
|
{
|
||||||
},
|
role: "user",
|
||||||
{
|
content: [
|
||||||
role: "user",
|
{
|
||||||
content: [
|
type: "text",
|
||||||
{
|
text: "How many poker chips are there for each color? Return structured JSON.",
|
||||||
type: "text",
|
},
|
||||||
text: "How many poker chips are there for each color? Return structured JSON.",
|
{
|
||||||
},
|
type: "image_url",
|
||||||
{
|
image_url: { url: `data:image/png;base64,${base64Image}` },
|
||||||
type: "image_url",
|
},
|
||||||
image_url: { url: `data:image/png;base64,${base64Image}` },
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
max_tokens: 1000,
|
||||||
],
|
}),
|
||||||
max_tokens: 1000,
|
});
|
||||||
}),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user