feat: Initialize a React application with Vite for image analysis and translation, configured with Docker and Gitea CI/CD.
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 51s

This commit is contained in:
almazlar
2026-02-08 23:36:40 +03:00
parent 3ed4a4e985
commit 282b5f4d19
20 changed files with 3883 additions and 338 deletions

53
src/services/api.js Normal file
View File

@@ -0,0 +1,53 @@
const API_URL = 'https://ai.almazlar.com/ollama/api/generate';
export const analyzeImage = async (base64Image) => {
try {
const response = await fetch(API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: "moondream",
prompt: "Describe this image.",
images: [base64Image],
stream: false
})
});
if (!response.ok) {
throw new Error(`HTTP error: ${response.status} - ${response.statusText}`);
}
const data = await response.json();
return data.response;
} catch (error) {
console.error("Analysis Error:", error);
throw error;
}
};
export const translateText = async (text) => {
try {
const response = await fetch(API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: "translategemma:4b", // Using the model specified in original code
prompt: `Act as a professional English-to-Turkish translator. Translate the following text into natural, fluent Turkish. Output ONLY the translation: "${text}"`,
options: {
temperature: 0.3
},
stream: false
})
});
if (!response.ok) {
throw new Error(`HTTP error: ${response.status} - ${response.statusText}`);
}
const data = await response.json();
return data.response;
} catch (error) {
console.error("Translation Error:", error);
throw error;
}
};