Compare commits
No commits in common. "889c368a462defc6aeba6fe577a47b3d855ed4d2" and "9bc7d4a27e666eb792d6ef8f4f14419eca091405" have entirely different histories.
889c368a46
...
9bc7d4a27e
|
|
@ -14,7 +14,6 @@ using Nop.Plugin.Misc.FruitBankPlugin.Helpers;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Services.FileStorage;
|
using Nop.Plugin.Misc.FruitBankPlugin.Services.FileStorage;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Common;
|
|
||||||
using Nop.Services.Security;
|
using Nop.Services.Security;
|
||||||
using Nop.Web.Framework;
|
using Nop.Web.Framework;
|
||||||
using Nop.Web.Framework.Controllers;
|
using Nop.Web.Framework.Controllers;
|
||||||
|
|
@ -32,37 +31,31 @@ namespace Nop.Plugin.Misc.FruitBank.Controllers
|
||||||
{
|
{
|
||||||
private readonly IPermissionService _permissionService;
|
private readonly IPermissionService _permissionService;
|
||||||
private readonly OpenAIApiService _aiApiService;
|
private readonly OpenAIApiService _aiApiService;
|
||||||
private readonly CerebrasAPIService _cerebrasApiService;
|
|
||||||
private readonly AICalculationService _aiCalculationService;
|
private readonly AICalculationService _aiCalculationService;
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly FruitBankDbContext _dbContext;
|
private readonly FruitBankDbContext _dbContext;
|
||||||
private readonly PdfToImageService _pdfToImageService;
|
private readonly PdfToImageService _pdfToImageService;
|
||||||
private readonly IWorkContext _workContext;
|
private readonly IWorkContext _workContext;
|
||||||
private readonly FileStorageService _fileStorageService;
|
private readonly FileStorageService _fileStorageService;
|
||||||
private readonly FruitBankAttributeService _fruitBankAttributeService;
|
|
||||||
|
|
||||||
public FileManagerController(
|
public FileManagerController(
|
||||||
IPermissionService permissionService,
|
IPermissionService permissionService,
|
||||||
OpenAIApiService aiApiService,
|
OpenAIApiService aiApiService,
|
||||||
CerebrasAPIService cerebrasApiService,
|
|
||||||
AICalculationService aiCalculationService,
|
AICalculationService aiCalculationService,
|
||||||
IProductService productService,
|
IProductService productService,
|
||||||
FruitBankDbContext fruitBankDbContext,
|
FruitBankDbContext fruitBankDbContext,
|
||||||
PdfToImageService pdfToImageService,
|
PdfToImageService pdfToImageService,
|
||||||
IWorkContext workContext,
|
IWorkContext workContext,
|
||||||
FileStorageService fileStorageService,
|
FileStorageService fileStorageService)
|
||||||
FruitBankAttributeService fruitBankAttributeService)
|
|
||||||
{
|
{
|
||||||
_permissionService = permissionService;
|
_permissionService = permissionService;
|
||||||
_aiApiService = aiApiService;
|
_aiApiService = aiApiService;
|
||||||
_cerebrasApiService = cerebrasApiService;
|
|
||||||
_aiCalculationService = aiCalculationService;
|
_aiCalculationService = aiCalculationService;
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
_dbContext = fruitBankDbContext;
|
_dbContext = fruitBankDbContext;
|
||||||
_pdfToImageService = pdfToImageService;
|
_pdfToImageService = pdfToImageService;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
_fileStorageService = fileStorageService;
|
_fileStorageService = fileStorageService;
|
||||||
_fruitBankAttributeService = fruitBankAttributeService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -490,8 +483,7 @@ namespace Nop.Plugin.Misc.FruitBank.Controllers
|
||||||
deserializedProduct.name + "\n\n" +
|
deserializedProduct.name + "\n\n" +
|
||||||
"Return the best matching product name from the catalog above (matching ALL details including size/grade), or 'NONE' if no good match exists.";
|
"Return the best matching product name from the catalog above (matching ALL details including size/grade), or 'NONE' if no good match exists.";
|
||||||
|
|
||||||
//var aiMatchedProductName = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
var aiMatchedProductName = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
||||||
var aiMatchedProductName = await _cerebrasApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
|
||||||
|
|
||||||
//var aiMatchedProductName = await _aiApiService.GetSimpleResponseAsync(aiMatchPrompt, deserializedProduct.name);
|
//var aiMatchedProductName = await _aiApiService.GetSimpleResponseAsync(aiMatchPrompt, deserializedProduct.name);
|
||||||
Console.WriteLine($"AI matched product name for {deserializedProduct.name}: {aiMatchedProductName}");
|
Console.WriteLine($"AI matched product name for {deserializedProduct.name}: {aiMatchedProductName}");
|
||||||
|
|
@ -585,8 +577,7 @@ namespace Nop.Plugin.Misc.FruitBank.Controllers
|
||||||
deserializedProduct.name + "\n\n" +
|
deserializedProduct.name + "\n\n" +
|
||||||
"Return the best matching product name from the catalog above that matches ALL details (size, grade, quality), or 'NONE' if no confident match exists.";
|
"Return the best matching product name from the catalog above that matches ALL details (size, grade, quality), or 'NONE' if no confident match exists.";
|
||||||
|
|
||||||
//var aiMatchedProductName2 = await _aiApiService.GetSimpleResponseAsync(systemPrompt2, userPrompt2);
|
var aiMatchedProductName2 = await _aiApiService.GetSimpleResponseAsync(systemPrompt2, userPrompt2);
|
||||||
var aiMatchedProductName2 = await _cerebrasApiService.GetSimpleResponseAsync(systemPrompt2, userPrompt2);
|
|
||||||
Console.WriteLine($"AI matched product name from hybrid catalog for {deserializedProduct.name}: {aiMatchedProductName2}");
|
Console.WriteLine($"AI matched product name from hybrid catalog for {deserializedProduct.name}: {aiMatchedProductName2}");
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(aiMatchedProductName2) && aiMatchedProductName2 != "NONE")
|
if (!string.IsNullOrEmpty(aiMatchedProductName2) && aiMatchedProductName2 != "NONE")
|
||||||
|
|
@ -746,8 +737,7 @@ namespace Nop.Plugin.Misc.FruitBank.Controllers
|
||||||
partnerAnalysis + "\n\n" +
|
partnerAnalysis + "\n\n" +
|
||||||
"Return ONLY the numeric ID of the matching partner, or '0' if no match found.";
|
"Return ONLY the numeric ID of the matching partner, or '0' if no match found.";
|
||||||
|
|
||||||
//var aiResponse = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
var aiResponse = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
||||||
var aiResponse = await _cerebrasApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
|
||||||
Console.WriteLine($"AI Partner Match Response: {aiResponse}");
|
Console.WriteLine($"AI Partner Match Response: {aiResponse}");
|
||||||
|
|
||||||
// Parse the ID
|
// Parse the ID
|
||||||
|
|
@ -838,8 +828,7 @@ namespace Nop.Plugin.Misc.FruitBank.Controllers
|
||||||
"4. Return ONLY the company name, nothing else\n\n" +
|
"4. Return ONLY the company name, nothing else\n\n" +
|
||||||
"If uncertain, return the most prominent non-FruitBank company name from the document.";
|
"If uncertain, return the most prominent non-FruitBank company name from the document.";
|
||||||
|
|
||||||
//var partnerAnalysis = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
var partnerAnalysis = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
||||||
var partnerAnalysis = await _cerebrasApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
|
||||||
|
|
||||||
// Clean up the response
|
// Clean up the response
|
||||||
var cleanedPartnerName = CleanPartnerName(partnerAnalysis);
|
var cleanedPartnerName = CleanPartnerName(partnerAnalysis);
|
||||||
|
|
@ -1098,17 +1087,6 @@ namespace Nop.Plugin.Misc.FruitBank.Controllers
|
||||||
Console.WriteLine("⚠ No original file provided - skipping file save");
|
Console.WriteLine("⚠ No original file provided - skipping file save");
|
||||||
}
|
}
|
||||||
|
|
||||||
//everything done, let's update the genericattribute "IncomingQuantity" of the product
|
|
||||||
foreach (var item in shippingDocument.ShippingItems.Where(x => x.ProductId != null))
|
|
||||||
{
|
|
||||||
await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, int>(
|
|
||||||
item.ProductId.Value,
|
|
||||||
"IncomingQuantity",
|
|
||||||
item.QuantityOnDocument
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return Json(new
|
return Json(new
|
||||||
{
|
{
|
||||||
success = true,
|
success = true,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
private readonly IPermissionService _permissionService;
|
private readonly IPermissionService _permissionService;
|
||||||
private readonly OpenAIApiService _aiApiService;
|
private readonly OpenAIApiService _aiApiService;
|
||||||
private readonly CerebrasAPIService _cerebrasApiService;
|
|
||||||
private readonly ICustomerService _customerService;
|
private readonly ICustomerService _customerService;
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly FruitBankDbContext _dbContext;
|
private readonly FruitBankDbContext _dbContext;
|
||||||
|
|
@ -32,14 +31,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
public VoiceOrderController(
|
public VoiceOrderController(
|
||||||
IPermissionService permissionService,
|
IPermissionService permissionService,
|
||||||
OpenAIApiService aiApiService,
|
OpenAIApiService aiApiService,
|
||||||
CerebrasAPIService cerebrasApiService,
|
|
||||||
ICustomerService customerService,
|
ICustomerService customerService,
|
||||||
IProductService productService,
|
IProductService productService,
|
||||||
FruitBankDbContext dbContext)
|
FruitBankDbContext dbContext)
|
||||||
{
|
{
|
||||||
_permissionService = permissionService;
|
_permissionService = permissionService;
|
||||||
_aiApiService = aiApiService;
|
_aiApiService = aiApiService;
|
||||||
_cerebrasApiService = cerebrasApiService;
|
|
||||||
_customerService = customerService;
|
_customerService = customerService;
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
|
@ -323,12 +320,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
transcribedText = await _aiApiService.TranscribeAudioAsync(audioStream, fileName, language, customPrompt);
|
transcribedText = await _aiApiService.TranscribeAudioAsync(audioStream, fileName, language, customPrompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transcribedText.EndsWith(".") || transcribedText.EndsWith("!") || transcribedText.EndsWith("?"))
|
|
||||||
{
|
|
||||||
//remove trailing punctuation
|
|
||||||
transcribedText = transcribedText.Substring(0, transcribedText.Length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up temporary file
|
// Clean up temporary file
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -421,7 +412,9 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get all customers with company names (increased limit)
|
// Get all customers with company names (increased limit)
|
||||||
var allCustomersWithCompany = await _customerService.GetAllCustomersAsync(); // Increased from 500 to catch more companies
|
var allCustomersWithCompany = await _customerService.GetAllCustomersAsync(
|
||||||
|
pageIndex: 0,
|
||||||
|
pageSize: 1000); // Increased from 500 to catch more companies
|
||||||
|
|
||||||
// Filter to only those with company names
|
// Filter to only those with company names
|
||||||
var customersWithCompany = allCustomersWithCompany
|
var customersWithCompany = allCustomersWithCompany
|
||||||
|
|
@ -448,7 +441,7 @@ CRITICAL MATCHING RULES (in priority order):
|
||||||
2. SUBSTRING MATCH: If the search term is contained within a company name (e.g., 'Junket' in 'Junket Silver Kft.')
|
2. SUBSTRING MATCH: If the search term is contained within a company name (e.g., 'Junket' in 'Junket Silver Kft.')
|
||||||
3. WORD MATCH: If all words from search term appear in company name (any order)
|
3. WORD MATCH: If all words from search term appear in company name (any order)
|
||||||
4. PARTIAL MATCH: If significant words overlap (e.g., 'Silver' matches 'Junket Silver')
|
4. PARTIAL MATCH: If significant words overlap (e.g., 'Silver' matches 'Junket Silver')
|
||||||
5. PHONETIC SIMILARITY: How it sounds when spoken in Hungarian (e.g. 'Ökotály' should be matched to 'Öcotáj')
|
5. PHONETIC SIMILARITY: How it sounds when spoken
|
||||||
6. ABBREVIATIONS: 'SFI' matches 'SFI Rotterdam B.V.'
|
6. ABBREVIATIONS: 'SFI' matches 'SFI Rotterdam B.V.'
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
|
|
@ -468,8 +461,7 @@ OUTPUT FORMAT (JSON only):
|
||||||
Companies:
|
Companies:
|
||||||
{companyList}";
|
{companyList}";
|
||||||
|
|
||||||
//var aiResponse = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
var aiResponse = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
||||||
var aiResponse = await _cerebrasApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
|
||||||
|
|
||||||
Console.WriteLine($"[VoiceOrder] AI company matching response: {aiResponse}");
|
Console.WriteLine($"[VoiceOrder] AI company matching response: {aiResponse}");
|
||||||
|
|
||||||
|
|
@ -560,8 +552,7 @@ Output: [{""product"":""szőlő"",""quantity"":50}]";
|
||||||
|
|
||||||
var userPrompt = $"Parse this: {text}";
|
var userPrompt = $"Parse this: {text}";
|
||||||
|
|
||||||
//var aiResponse = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
var aiResponse = await _aiApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
||||||
var aiResponse = await _cerebrasApiService.GetSimpleResponseAsync(systemPrompt, userPrompt);
|
|
||||||
|
|
||||||
Console.WriteLine($"[VoiceOrder] AI Response: {aiResponse}");
|
Console.WriteLine($"[VoiceOrder] AI Response: {aiResponse}");
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -333,7 +333,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
"TaxId",
|
"TaxId",
|
||||||
customer.VatNumber);
|
customer.VatNumber);
|
||||||
}
|
}
|
||||||
_dbContext.Customers.Update(customer, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -840,7 +840,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
role = "system",
|
role = "system",
|
||||||
content = new object[]
|
content = new object[]
|
||||||
{
|
{
|
||||||
new { type = "text", text = systemPrompt },
|
new { type = "text", text = prompt },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new {
|
new {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue