This commit is contained in:
mmrbnjd
2025-08-18 17:30:02 +03:30
parent 067607d98a
commit 561f58784c
15 changed files with 588 additions and 282 deletions

View File

@@ -0,0 +1,14 @@
using Hushian.Application.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Contracts
{
public interface Iaiass
{
Task<ResponseBase<string>> SendQuestion(aiRequestModel Request);
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Models
{
public class aiRequestModel
{
public aiRequestModel(string question, string[] prompts)
{
this.question = question;
this.prompts = prompts;
}
public string question { get; set; }
public string[] prompts { get; set; }
public override string ToString()
{
string str = "";
foreach (var item in prompts)
{
str += '\n'+item;
}
return str;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Models.aia
{
public class aiSetting
{
public string url { get; set; }
public string apitoken { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
using AutoMapper;
using Common.Dtos;
using Hushian.Application.Contracts;
using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models;
using Hushian.Domain.Entites;
@@ -8,65 +9,79 @@ using System.Linq;
namespace Hushian.Application.Services
{
public class AIService
{
private readonly IGenericRepository<AIA> _aiaRepository;
private readonly IMapper _mapper;
public class AIService
{
private readonly IGenericRepository<AIA> _aiaRepository;
private readonly IGenericRepository<Prompt> _promprtRepository;
private readonly Iaiass _aiass;
public AIService(IGenericRepository<AIA> aiaRepository, IMapper mapper)
{
_aiaRepository = aiaRepository;
_mapper = mapper;
}
public async Task<ResponseBase<aiResponseDto>> NewRequest
(aiNewResponseDto dto)
{
ResponseBase<aiResponseDto> response = new();
try
{
string responeai="همین جوری";
bool sucessresponseai =!false;
public AIService(IGenericRepository<AIA> aiaRepository, Iaiass aiass, IGenericRepository<Prompt> promprtRepository)
{
_aiaRepository = aiaRepository;
_aiass = aiass;
_promprtRepository = promprtRepository;
}
public async Task<ResponseBase<aiResponseDto>> NewRequest
(aiNewResponseDto dto)
{
ResponseBase<aiResponseDto> response = new();
try
{
string responeai = "";
bool sucessresponseai = false;
var prompts = await _promprtRepository.Get()
.Where(w => w.CompanyID == dto.companyId).Select(s => s.Test).ToArrayAsync();
var requsetai= await _aiass.SendQuestion(new aiRequestModel(dto.requestText,prompts));
if(requsetai.Success)
{
sucessresponseai = true;
responeai = requsetai.Value;
}
else
{
response.Errors = requsetai.Errors;
}
var entity = new AIA
{
CompanyID = dto.companyId,
aiKeyUser = dto.aiKeyUser,
Request = dto.requestText,
Response = responeai,
Cdatetime = DateTime.Now
};
var added = await _aiaRepository.ADD(entity);
{
CompanyID = dto.companyId,
aiKeyUser = dto.aiKeyUser,
Request = dto.requestText,
Response = responeai,
Cdatetime = DateTime.Now
};
var added = await _aiaRepository.ADD(entity);
if(sucessresponseai)
response.Value = new() { dateTime=added.Cdatetime,responseText=added.Response,requestText=added.Request};
response.Success = sucessresponseai;
}
catch (Exception)
{
response.Errors.Add("خطا در ذخیره سازی");
}
return response;
}
if (sucessresponseai)
response.Value = new() { dateTime = added.Cdatetime, responseText = added.Response, requestText = added.Request };
response.Success = sucessresponseai;
}
catch (Exception)
{
response.Errors.Add("خطا در ذخیره سازی");
}
return response;
}
public async Task<List<aiResponseDto>> GetCurrent(int companyId, string aiKeyUser)
{
return await _aiaRepository
.Get()
.Where(w => w.CompanyID == companyId && w.aiKeyUser == aiKeyUser && w.Cdatetime.AddHours(3) >= DateTime.Now)
.OrderBy(o => o.ID)
.Select(s=>new aiResponseDto() { responseText = s.Response, requestText = s.Request,dateTime=s.Cdatetime})
.ToListAsync();
}
public async Task<List<aiResponseDto>> GetCurrent(int companyId, string aiKeyUser)
{
return await _aiaRepository
.Get()
.Where(w => w.CompanyID == companyId && w.aiKeyUser == aiKeyUser && w.Cdatetime.AddHours(3) >= DateTime.Now)
.OrderBy(o => o.ID)
.Select(s => new aiResponseDto() { responseText = s.Response, requestText = s.Request, dateTime = s.Cdatetime })
.ToListAsync();
}
//public async Task<bool> DeleteEntry(int id, int companyId)
//{
// var entity = await _aiaRepository.Get().FirstOrDefaultAsync(f => f.ID == id && f.CompanyID == companyId);
// if (entity == null) return false;
// return await _aiaRepository.DELETE(entity);
//}
}
//public async Task<bool> DeleteEntry(int id, int companyId)
//{
// var entity = await _aiaRepository.Get().FirstOrDefaultAsync(f => f.ID == id && f.CompanyID == companyId);
// if (entity == null) return false;
// return await _aiaRepository.DELETE(entity);
//}
}
}

View File

@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hushian.WebApi", "Presentat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HushianWebApp", "Presentation\HushianWebApp\HushianWebApp.csproj", "{80D865DC-1CCD-9C25-5DAF-153E7B33408E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIAss", "Presentation\AIAss\AIAss.csproj", "{AF6AE286-63CF-4A8A-A0B4-DBDA047FC9AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -55,6 +57,10 @@ Global
{80D865DC-1CCD-9C25-5DAF-153E7B33408E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80D865DC-1CCD-9C25-5DAF-153E7B33408E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80D865DC-1CCD-9C25-5DAF-153E7B33408E}.Release|Any CPU.Build.0 = Release|Any CPU
{AF6AE286-63CF-4A8A-A0B4-DBDA047FC9AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF6AE286-63CF-4A8A-A0B4-DBDA047FC9AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF6AE286-63CF-4A8A-A0B4-DBDA047FC9AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF6AE286-63CF-4A8A-A0B4-DBDA047FC9AE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -64,6 +70,7 @@ Global
{05D292C2-BB17-4524-B1F2-8A2B6B213C6A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{37AD460D-1663-4755-AC15-703BFFBF20D2} = {F9F2A965-B4E4-4990-B547-F18200AF2631}
{80D865DC-1CCD-9C25-5DAF-153E7B33408E} = {F9F2A965-B4E4-4990-B547-F18200AF2631}
{AF6AE286-63CF-4A8A-A0B4-DBDA047FC9AE} = {F9F2A965-B4E4-4990-B547-F18200AF2631}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F0E59B62-9EDF-47DC-AAFD-F841443D0AAE}

View File

@@ -1,4 +1,6 @@
using Common.Contracts.Infrastructure;
using Hushian.Application.Contracts;
using Hushian.Application.Models.aia;
using Hushian.Application.Models.Message;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -17,8 +19,8 @@ namespace Hushian.Infrastructure
services.AddTransient<IMessageSender, MessageSender>();
//services.Configure<aiSetting>(configuration.GetSection("aiSettings"));
//services.AddTransient<IOpenai, OpenaiService>();
services.Configure<aiSetting>(configuration.GetSection("aiSettings"));
services.AddTransient<Iaiass, openAI>();
services.AddScoped(c => new Melipayamak.RestClient(configuration.GetSection("MessageSettings:UserName").Value, configuration.GetSection("MessageSettings:Password").Value));
return services;

View File

@@ -0,0 +1,65 @@
using Hushian.Application.Contracts;
using Hushian.Application.Models;
using Hushian.Application.Models.aia;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Hushian.Infrastructure
{
public class openAI : Iaiass
{
const string model = "gpt-4o-mini";
private aiSetting _aiSettings;
public openAI(IOptions<aiSetting> aiSettings)
{
_aiSettings = aiSettings.Value;
}
public async Task<ResponseBase<string>> SendQuestion(aiRequestModel Request)
{
var Response = new ResponseBase<string>();
try
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", _aiSettings.apitoken);
var content = new
{
model = model,
messages = new[]
{
new { role = "system", content = "شما یک دستیار پاسخگو به سوالات هستید." },
new { role = "user", content = $"با توجه به این متن:{Request.ToString()}به این سوال پاسخ بده:{ Request.question}" },
new { role = "system", content = "به سوالات غیره متن بالا پاسخ نده و بگو در این زمینه اطلاعی ندارم" }
}
};
var response = await client.PostAsync(_aiSettings.url,
new StringContent(JsonSerializer.Serialize(content), Encoding.UTF8, "application/json"));
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
using var doc = JsonDocument.Parse(json);
Response.Value = doc.RootElement.GetProperty("choices")[0].GetProperty("message").GetProperty("content").GetString();
Response.Success = true;
}
else
{
Response.Errors.Add("خطا در ارتباط سرور ai");
}
}
catch (Exception ex)
{
Response.Errors.Add("خطا مدیریت نشده در ارتباط سرور ai");
}
return Response;
}
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.64.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
using AIAss.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddGrpc();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run();

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7015;http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,21 @@
syntax = "proto3";
option csharp_namespace = "AIAss";
package greet;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply);
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings.
message HelloReply {
string message = 1;
}

View File

@@ -0,0 +1,21 @@
using Grpc.Core;
using AIAss;
namespace AIAss.Services;
public class GreeterService : Greeter.GreeterBase
{
private readonly ILogger<GreeterService> _logger;
public GreeterService(ILogger<GreeterService> logger)
{
_logger = logger;
}
public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply
{
Message = "Hello " + request.Name
});
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
}
}

View File

@@ -13,230 +13,272 @@
@using Microsoft.AspNetCore.Components.Web
@inject CompanyService companyService
@inject ToastService toastService
<PageTitle>گفتگو با دستیار هوشمند @CompanyInfo.FullName</PageTitle>
<div class="container-fluid">
<div class="row" style="height:85vh">
@if (isReady)
{
@if (isLogin)
{
<div class="col-md-12 d-flex flex-column" style="margin-top:10px">
<div class="input-group">
<p type="text" class="form-control fw-bold text-primary" style="border:none;align-self: center;" aria-describedby="basic-addon1">دستیار هوشمند @CompanyInfo.FullName</p>
<div class="row" style="height:85vh">
@if (isReady)
{
<div class="col-md-12 d-flex flex-column" style="margin-top:10px">
<div class="input-group">
<p type="text" class="form-control fw-bold text-primary" style="border:none;align-self: center;" aria-describedby="basic-addon1">دستیار هوشمند @CompanyInfo.FullName</p>
<div class="d-flex gap-2 ms-auto">
<div class="d-flex gap-2 ms-auto">
<Button Color="ButtonColor.Secondary" Size=ButtonSize.ExtraSmall Outline="true" @onclick="Logout" Class="logout-btn">
<Icon Name="IconName.BoxArrowRight" Class="me-1" /> خروج
</Button>
</div>
</div>
<div class="flex-fill chat-area-container" id="ai-chat">
@if (messages is not null)
{
<div class="chat-container p-3">
@foreach (var msg in messages)
{
<div class="d-flex mb-2 justify-content-start">
<div class="chat-bubble chat-other">
@msg.requestText
</div>
</div>
<Button Color="ButtonColor.Secondary" Size=ButtonSize.ExtraSmall Outline="true" @onclick="Logout" Class="logout-btn">
<Icon Name="IconName.BoxArrowRight" Class="me-1" /> خروج
</Button>
</div>
</div>
<div class="flex-fill chat-area-container" id="ai-chat">
@if (messages is not null)
{
<div class="chat-container p-3">
@foreach (var msg in messages)
{
<div class="d-flex mb-2 justify-content-start">
<div class="chat-bubble chat-other">
@msg.requestText
</div>
</div>
<div class="d-flex mb-2 justify-content-end">
<div class="chat-bubble chat-mine">
@msg.responseText
</div>
</div>
<div class="d-flex mb-2 justify-content-end">
<div class="chat-bubble chat-mine">
@msg.responseText
</div>
</div>
}
</div>
}
</div>
<div class="message-input-container mt-2">
<div class="input-wrapper">
<input type="text" @bind-value="inputText" class="message-input" placeholder="متن خود را بنویسید..." @onkeydown="HandleKeyDown" />
<Button Color="ButtonColor.Primary" Size=ButtonSize.Small @onclick="Send" class="send-btn" title="ارسال">
<Icon Name="IconName.Send" />
</Button>
</div>
</div>
</div>
}
else
{
<div class="d-flex justify-content-center align-items-center" style="height:100%">
<div class="text-center">
<Spinner Type="SpinnerType.Dots" Color="SpinnerColor.Primary" />
<p class="mt-3 text-muted">نیاز به ورود دارید</p>
</div>
</div>
}
}
else
{
<div class="d-flex justify-content-center align-items-center" style="height:100%">
<div class="text-center">
<Spinner Type="SpinnerType.Dots" Color="SpinnerColor.Primary" />
<p class="mt-3 text-muted">در حال بارگذاری ...</p>
</div>
</div>
}
</div>
}
</div>
}
</div>
<div class="message-input-container mt-2">
<div class="input-wrapper">
<input type="text" @bind-value="inputText" disabled="@disSend" class="message-input" placeholder="متن خود را بنویسید..." @onkeydown="HandleKeyDown" />
<Button Color="ButtonColor.Primary" Size=ButtonSize.Small @onclick="Send" class="send-btn" title="ارسال">
@if (!disSend)
{
<Icon Name="IconName.Send" />
}
else
{
<Spinner Type="SpinnerType.Grow" Color="SpinnerColor.Primary" />
}
</Button>
</div>
</div>
</div>
}
else
{
<div class="d-flex justify-content-center align-items-center" style="height:100%">
<div class="text-center">
@if (isError)
{
<p class="mt-3 text-muted" style="color:orangered">@msgError</p>
}
else
{
<Spinner Type="SpinnerType.Dots" Color="SpinnerColor.Primary" />
<p class="mt-3 text-muted">در حال بارگذاری ...</p>
}
</div>
</div>
}
</div>
</div>
@code {
ReadANDUpdate_CompanyDto? CompanyInfo = new();
[Parameter] public int CompanyID { get; set; }
List<aiResponseDto> messages = new();
string inputText = string.Empty;
bool isLogin = false;
bool isReady = false;
public string aikeyUser { get; set; }
protected override async Task OnInitializedAsync()
{
await EnsureAuth();
if (isLogin)
{
CompanyInfo = await companyService.GetCompany(CompanyID);
if (CompanyInfo != null)
await LoadMessages();
else
{
toastService.Notify(new ToastMessage(ToastType.Danger, "شناسه شرکت صحیح نمی باشد"));
ReadANDUpdate_CompanyDto? CompanyInfo = new();
[Parameter] public int CompanyID { get; set; }
List<aiResponseDto> messages = new();
string inputText = string.Empty;
bool isReady = false;
bool isError= false;
string msgError= "";
public string aikeyUser { get; set; } = "";
protected override async Task OnInitializedAsync()
{
await EnsureAuth();
CompanyInfo = await companyService.GetCompany(CompanyID);
if (CompanyInfo != null && CompanyInfo.allowBot)
{
await LoadMessages();
isReady = true;
}
else
{
isError = true;
msgError = "دستیار هوشمند یافت نشد";
}
}
}
}
}
private async Task EnsureAuth()
{
aikeyUser = await localStorageService.GetItem<string>("aikeyUser");
if (string.IsNullOrEmpty(aikeyUser))
{
aikeyUser = Guid.NewGuid().ToString();
await localStorageService.SetItem("aikeyUser", aikeyUser);
}
private async Task EnsureAuth()
{
aikeyUser = await localStorageService.GetItem<string>("aikeyUser");
if (string.IsNullOrEmpty(aikeyUser))
{
aikeyUser = Guid.NewGuid().ToString();
await localStorageService.SetItem("aikeyUser", aikeyUser);
}
isLogin = true;
isReady = true;
}
}
private async Task LoadMessages()
{
messages = await conversationService.GetAiCurrentResponses(CompanyID,aikeyUser);
StateHasChanged();
await JS.InvokeVoidAsync("scrollToBottom", "ai-chat");
}
private async Task LoadMessages()
{
messages = await conversationService.GetAiCurrentResponses(CompanyID, aikeyUser);
StateHasChanged();
await JS.InvokeVoidAsync("scrollToBottom", "ai-chat");
}
bool disSend = false;
private async Task Send()
{
if (string.IsNullOrWhiteSpace(inputText)) return;
disSend = true;
var dto = new aiNewResponseDto { companyId = CompanyID, aiKeyUser = aikeyUser, requestText = inputText };
var okmodel = await conversationService.AiNewResponse(dto);
if (okmodel != null)
{
messages.Add(okmodel);
inputText = string.Empty;
StateHasChanged();
await JS.InvokeVoidAsync("scrollToBottom", "ai-chat");
}
else
{
toastService.Notify(new ToastMessage(ToastType.Danger, "ارسال ناموفق بود"));
}
disSend = false;
}
private async Task Send()
{
if (string.IsNullOrWhiteSpace(inputText)) return;
private async Task HandleKeyDown(KeyboardEventArgs e)
{
if (e.Key == "Enter") await Send();
}
var dto = new aiNewResponseDto { companyId = CompanyID, aiKeyUser = aikeyUser, requestText = inputText };
var okmodel = await conversationService.AiNewResponse(dto);
if (okmodel!=null)
{
messages.Add(okmodel);
inputText = string.Empty;
StateHasChanged();
await JS.InvokeVoidAsync("scrollToBottom", "ai-chat");
}
else
{
toastService.Notify(new ToastMessage(ToastType.Danger, "ارسال ناموفق بود"));
}
}
private async Task HandleKeyDown(KeyboardEventArgs e)
{
if (e.Key == "Enter") await Send();
}
private async Task Logout()
{
await localStorageService.RemoveItem("aiKeyUser");
isLogin = false;
}
private async Task Logout()
{
await localStorageService.RemoveItem("aiKeyUser");
}
}
<style>
.chat-area-container {
height: 400px;
overflow-y: auto;
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
border: 2px solid #e9ecef;
border-radius: 20px;
padding: 1.5rem;
margin: 1rem 0;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
position: relative;
backdrop-filter: blur(10px);
}
.chat-bubble {
padding: 0.75rem 1rem;
border-radius: 18px;
max-width: 75%;
word-wrap: break-word;
white-space: pre-wrap;
font-size: 0.95rem;
line-height: 1.4;
position: relative;
transition: all 0.3s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.chat-other {
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
color: #333;
border-top-right-radius: 4px;
border: 1px solid #e9ecef;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.chat-ai {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
color: #495057;
border-top-right-radius: 4px;
border: 1px solid #dee2e6;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.message-input-container { border-radius: 0.5rem; background-color: #f8f9fa; padding: .5rem; }
.input-wrapper { display:flex; align-items:center; gap:.75rem; }
.message-input { flex:1; border:none; background:transparent; padding:.5rem .75rem; font-size:.95rem; color:#495057; outline:none; border-radius:20px; }
.send-btn { border-radius:50%; width:38px; height:38px; padding:0; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#0d6efd 0%,#0b5ed7 100%); border:none; box-shadow:0 4px 12px rgba(13,110,253,.3); color:white; }
.chat-area-container {
height: 400px;
overflow-y: auto;
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
border: 2px solid #e9ecef;
border-radius: 20px;
padding: 1.5rem;
margin: 1rem 0;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
position: relative;
backdrop-filter: blur(10px);
}
.logout-btn {
border-radius: 20px;
font-weight: 600;
font-size: 0.875rem;
padding: 0.375rem 0.75rem;
transition: all 0.3s ease;
border-width: 2px;
box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}
.chat-bubble {
padding: 0.75rem 1rem;
border-radius: 18px;
max-width: 75%;
word-wrap: break-word;
white-space: pre-wrap;
font-size: 0.95rem;
line-height: 1.4;
position: relative;
transition: all 0.3s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.logout-btn:hover {
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
border-color: #6c757d;
background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
color: white;
}
.chat-other {
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
color: #333;
border-top-right-radius: 4px;
border: 1px solid #e9ecef;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
/* Improved input group styling */
.input-group {
margin-bottom: 1rem;
border-radius: 0.5rem;
overflow: hidden;
}
.chat-ai {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
color: #495057;
border-top-right-radius: 4px;
border: 1px solid #dee2e6;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.input-group p {
margin: 0;
font-size: 1.1rem;
font-weight: 700;
background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.message-input-container {
border-radius: 0.5rem;
background-color: #f8f9fa;
padding: .5rem;
}
.input-wrapper {
display: flex;
align-items: center;
gap: .75rem;
}
.message-input {
flex: 1;
border: none;
background: transparent;
padding: .5rem .75rem;
font-size: .95rem;
color: #495057;
outline: none;
border-radius: 20px;
}
.send-btn {
border-radius: 50%;
width: 38px;
height: 38px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg,#0d6efd 0%,#0b5ed7 100%);
border: none;
box-shadow: 0 4px 12px rgba(13,110,253,.3);
color: white;
}
.logout-btn {
border-radius: 20px;
font-weight: 600;
font-size: 0.875rem;
padding: 0.375rem 0.75rem;
transition: all 0.3s ease;
border-width: 2px;
box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}
.logout-btn:hover {
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
border-color: #6c757d;
background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
color: white;
}
/* Improved input group styling */
.input-group {
margin-bottom: 1rem;
border-radius: 0.5rem;
overflow: hidden;
}
.input-group p {
margin: 0;
font-size: 1.1rem;
font-weight: 700;
background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
</style>
@@ -249,31 +291,31 @@
};
</script>
<style>
.chat-bubble {
padding: 0.5rem 0.75rem;
border-radius: 1rem;
max-width: 75%;
word-wrap: break-word;
white-space: pre-wrap;
}
<style>
.chat-bubble {
padding: 0.5rem 0.75rem;
border-radius: 1rem;
max-width: 75%;
word-wrap: break-word;
white-space: pre-wrap;
}
.chat-mine {
background: linear-gradient(to right, #005eff, #267fff);
color: white;
border-top-left-radius: 0;
}
.chat-mine {
background: linear-gradient(to right, #005eff, #267fff);
color: white;
border-top-left-radius: 0;
}
.chat-other {
background-color: #f1f1f1;
color: #333;
border-top-right-radius: 0;
}
.chat-other {
background-color: #f1f1f1;
color: #333;
border-top-right-radius: 0;
}
.chat-ai {
background-color: #f1f1f1;
color: #353;
border-top-right-radius: 0;
}
.chat-ai {
background-color: #f1f1f1;
color: #353;
border-top-right-radius: 0;
}
</style>
</style>