last ...
This commit is contained in:
@@ -480,6 +480,36 @@
|
||||
"labels": [],
|
||||
"checkboxes": [],
|
||||
"comments": []
|
||||
},
|
||||
{
|
||||
"id": "9508c8d9-d5de-4f87-b855-7bcf81ea141e",
|
||||
"listId": "1706107f-ace2-4240-aa32-3d2031264a41",
|
||||
"title": "Add Support for Routing and Proxy Requests to LLM Services",
|
||||
"description": "since in many cases we have to redirect requests to llm provider api, like Open AI Compatible. we have to implement this mechanism inside xAiApi after routing controllers.\n",
|
||||
"labels": [],
|
||||
"checkboxes": [
|
||||
{
|
||||
"id": "e9830cf7-33b8-494c-bfd5-88593db2e093",
|
||||
"title": "Extends a Middleware for this ...",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"id": "79137be0-30d7-4dbe-b311-da1110acc3eb",
|
||||
"title": "Specified Model to this in request route ...",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"id": "15821146-d04b-423d-b81c-b6761b4517b1",
|
||||
"title": "Handle Authentication Mechanism using xApiKey or JWT Token ...",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"id": "d6fb137d-b500-4c51-948a-47ad91fa9f3f",
|
||||
"title": "Others ...",
|
||||
"checked": false
|
||||
}
|
||||
],
|
||||
"comments": []
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -487,15 +517,6 @@
|
||||
"id": "171f43f3-ae73-49b7-9239-9f3fb695cc2b",
|
||||
"title": "InProgress",
|
||||
"cards": [
|
||||
{
|
||||
"id": "c072d0a6-f2be-419b-8fb2-d127d73dd709",
|
||||
"listId": "171f43f3-ae73-49b7-9239-9f3fb695cc2b",
|
||||
"title": "Prepare Vector Data Store in XAiModels ...",
|
||||
"description": "",
|
||||
"labels": [],
|
||||
"checkboxes": [],
|
||||
"comments": []
|
||||
},
|
||||
{
|
||||
"id": "17bbcc83-4330-4631-a08a-521c99047ebc",
|
||||
"listId": "171f43f3-ae73-49b7-9239-9f3fb695cc2b",
|
||||
@@ -569,6 +590,24 @@
|
||||
}
|
||||
],
|
||||
"comments": []
|
||||
},
|
||||
{
|
||||
"id": "c4633423-da53-4942-a9b4-d5f23b5759b3",
|
||||
"listId": "171f43f3-ae73-49b7-9239-9f3fb695cc2b",
|
||||
"title": "Implement Chat With Documents ...",
|
||||
"description": "",
|
||||
"labels": [],
|
||||
"checkboxes": [],
|
||||
"comments": []
|
||||
},
|
||||
{
|
||||
"id": "ba4048ef-f6bd-40b5-bd17-3e34edd534f2",
|
||||
"listId": "171f43f3-ae73-49b7-9239-9f3fb695cc2b",
|
||||
"title": "Implement Document Storing Vector ...",
|
||||
"description": "",
|
||||
"labels": [],
|
||||
"checkboxes": [],
|
||||
"comments": []
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -576,6 +615,15 @@
|
||||
"id": "8c15334f-3b2e-4eca-999e-4c887cb628e9",
|
||||
"title": "Test",
|
||||
"cards": [
|
||||
{
|
||||
"id": "c072d0a6-f2be-419b-8fb2-d127d73dd709",
|
||||
"listId": "8c15334f-3b2e-4eca-999e-4c887cb628e9",
|
||||
"title": "Prepare Vector Data Store in XAiModels ...",
|
||||
"description": "",
|
||||
"labels": [],
|
||||
"checkboxes": [],
|
||||
"comments": []
|
||||
},
|
||||
{
|
||||
"id": "5f8a8b2f-06ce-46a9-8101-f14e34b51249",
|
||||
"listId": "8c15334f-3b2e-4eca-999e-4c887cb628e9",
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using AutoMapper;
|
||||
using xAiModels.Models.Dtos;
|
||||
using xAiModels.Models.Entities;
|
||||
|
||||
namespace xAiModels.Configurations.Entities
|
||||
{
|
||||
public class XAiVectorMappingAction : IMappingAction<XAiVector, XAiVectorDto>
|
||||
{
|
||||
public XAiVectorMappingAction()
|
||||
{
|
||||
}
|
||||
|
||||
public void Process(
|
||||
XAiVector source,
|
||||
XAiVectorDto destination,
|
||||
ResolutionContext context
|
||||
)
|
||||
{
|
||||
// No additional mapping needed for XAiVector
|
||||
// All properties are directly mapped
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Constants\ConfigurationNodeNames.cs
|
||||
|
||||
namespace xAiService.Constants
|
||||
{
|
||||
public partial struct ConfigurationNodeNames
|
||||
{
|
||||
public const string AI_SERVICE_NODE = "AIServiceConfiguration";
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Constants\XAiServiceConstants.cs
|
||||
|
||||
namespace xAiService.Constants
|
||||
{
|
||||
public struct XAiServiceConstants
|
||||
{
|
||||
//
|
||||
// Service Extensions Log Tag ...
|
||||
public const string XAiServiceDILogTag = "XAiService";
|
||||
|
||||
//
|
||||
// File Provider Identifiers ...
|
||||
public const string XAiProjectFilesIdentifier = "AiPrjF";
|
||||
public const string XAiMessageFilesIdentifier = "AiMsgF";
|
||||
public const string XMetaDataFileIdsIdentifier = "FileIds";
|
||||
public const string XAiConversationFilesIdentifier = "AiCnvrF";
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\DI\XDIHelperExtension.cs
|
||||
|
||||
namespace xAiService.DI
|
||||
{
|
||||
public static partial class XDIHelperExtension
|
||||
{ }
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Extensions\XAiServiceExtensions.cs
|
||||
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityModels.Models;
|
||||
|
||||
namespace xAiService.Extensions
|
||||
{
|
||||
public static class XAiServiceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Validate User Info ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XUserClaimsInfoDto source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.UserId.IsNullOrEmpty() &&
|
||||
!source.AccessToken.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate User Info ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="invalidException"></param>
|
||||
public static void Validate(
|
||||
this XUserClaimsInfoDto source,
|
||||
XException invalidException = XException.InvalidArgs
|
||||
)
|
||||
{
|
||||
//
|
||||
var isValid = source.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
invalidException.Throw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Helpers\VectorHelper.cs
|
||||
|
||||
using System;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xAiService.Helpers
|
||||
{
|
||||
public static class VectorHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Normalize a Vector ...
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
public static void Normalize(float[] vector)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (vector.IsNull() || !vector.HasChild())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
float sum = 0f;
|
||||
foreach (var value in vector)
|
||||
{
|
||||
sum += value * value;
|
||||
}
|
||||
|
||||
//
|
||||
float norm = MathF.Sqrt(sum);
|
||||
if (norm <= 1e-9f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < vector.Length; i++)
|
||||
{
|
||||
vector[i] /= norm;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Similarity Check ...
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static float CosineSimilarity(float[] a, float[] b)
|
||||
{
|
||||
//
|
||||
if (a.IsNull() || b.IsNull())
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
//
|
||||
if (a.Length != b.Length)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
//
|
||||
float dot = 0f;
|
||||
float normA = 0f;
|
||||
float normB = 0f;
|
||||
for (int i = 0; i < a.Length; i++)
|
||||
{
|
||||
//
|
||||
dot += a[i] * b[i];
|
||||
normA += a[i] * a[i];
|
||||
normB += b[i] * b[i];
|
||||
}
|
||||
|
||||
//
|
||||
float denominator = MathF.Sqrt(normA) * MathF.Sqrt(normB);
|
||||
if (denominator <= 1e-9f)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
//
|
||||
var result = dot / denominator;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
Submodule Modules/xAiModels updated: 26df2c7ebc...c8ad34944a
+1
-1
Submodule xAiApi updated: 20f1c7fb2f...ddfa7979a5
Reference in New Issue
Block a user