Skip to content

Commit

Permalink
feat: update Gemini model configuration and enhance request data stru…
Browse files Browse the repository at this point in the history
…cture for AI lead extraction
  • Loading branch information
amit-webkul committed Jan 30, 2025
1 parent 8051929 commit 258dff8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/Webkul/Admin/src/Config/core_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
'title' => 'GPT 4O Mini',
'value' => 'gpt-4o-mini',
], [
'title' => 'Gemini 2.0 Flash',
'value' => 'gemini-2.0-flash-exp',
'title' => 'Gemini 1.5 Flash',
'value' => 'gemini-1.5-flash',
], [
'title' => 'Deepseek r1 8b',
'value' => 'deepseek-r1:8b',
Expand All @@ -77,7 +77,7 @@
'name' => 'api_key',
'title' => 'API Key',
'type' => 'password',
'depends' => 'enable:1,model:*',
'depends' => 'enable:1,model:gpt-4o,model:gpt-4o-mini,model:gemini-1.5-flash,model:llama-3.3-70b-versatile',
'validation' => 'required_if:enable,1',
'info' => 'Please ensure that you use a unique API key for each model type to maintain optimal performance and security.',
], [
Expand Down
47 changes: 44 additions & 3 deletions packages/Webkul/Admin/src/Helpers/Lead.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,50 @@ private static function sendGeminiRequest($prompt, $model)

$url = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key={$apiKey}";

$data = self::prepareRequestData($model, $prompt);

$data['stream'] = false;
$data = [
"contents" => [
[
"parts" => [
[
"text" => 'You are an AI assistant. You have to extract the data from the PDF file.
Example Output:
{
"status": 1,
"title": "Untitled Lead",
"person": {
"name": "Unknown",
"emails": {
"value": null,
"label": null
},
"contact_numbers": {
"value": null,
"label": null
}
},
"lead_pipeline_stage_id": null,
"lead_value": 0,
"source": "AI Extracted"
}
Note: Only return the output, Do not return or add any comments.'
]
],
"role" => "system"
],
[
"parts" => [
["text" => "PDF:\n$prompt"]
],
"role" => "user"
]
],
"generationConfig" => [
"temperature" => 0.2,
"topK" => 30,
"topP" => 0.8,
"maxOutputTokens" => 512
]
];

return self::makeCurlRequest($url, $model, $data);
}
Expand Down

0 comments on commit 258dff8

Please sign in to comment.