s o i will gave you code
import os
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from typing import Dict
from dotenv import load_dotenv

Load environment variables from .env file
load_dotenv()

app = FastAPI()

Get categories and weights from environment variables
categories = os.getenv("CATEGORIES").split(",")
weights_raw = os.getenv("WEIGHTS").split(";")
weights = {cat: {"w_T": float(w[0]), "w_L": float(w[1]), "w_P": float(w[2])}
for cat, w in zip(categories, (w.split(",") for w in weights_raw))}

Get max values from environment variables
L_MAX = float(os.getenv("L_MAX", 300))
THROUGHPUT_MAX = float(os.getenv("THROUGHPUT_MAX", 1000))

Define request body
class QoERequest(BaseModel):
category: str
throughput: float
latency: float
packet_loss: float

@app.post("/calculate_qoe/")
async def calculate_qoe(request: QoERequest):
category = request.category
throughput = request.throughput
latency = request.latency
packet_loss = request.packet_loss

if category not in weights:
    raise HTTPException(status_code=400, detail="Invalid application category.")

# Get weights
w_T = weights[category]["w_T"]
w_L = weights[category]["w_L"]
w_P = weights[category]["w_P"]

# Normalize values
f_throughput = throughput / THROUGHPUT_MAX  # Example normalization factor for throughput
f_latency = (L_MAX - latency) / L_MAX
f_packet_loss = 1 - (packet_loss / 100)  # Assuming packet loss is given in percentage

# Calculate QoE score
qoe_score = w_T * f_throughput + w_L * f_latency + w_P * f_packet_loss

return {"QoE Score": qoe_score}
Use code with caution.
if name == "main":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)

so here is changes class QoERequest(BaseModel):
category: str
throughput: float
latency: float
packet_loss: float
instead of throuput you will use bytes_transferred, duration, latency, and packet_loss. The throughput is calculated internally.
s ohere is my tasks update score api to add bytes and latency as input and perform internal calculation
and add max latency and mac throughput detection to api

i will gave you a guide will hep you
Here is an expanded version of the README.md file, covering the additional categories you provided:

QoE Calculation Framework
This project provides a framework for calculating Quality of Experience (QoE) scores for various application categories based on network metrics such as throughput, latency, and packet loss. The framework supports categories like Internet Privacy, Social Media, Streaming, Webmail, Gaming, and many more.

Overview
Quality of Experience (QoE) is a measure of how well a network meets the performance needs of a particular application or service, as perceived by the end-user. This project calculates QoE for the following categories based on weighted contributions from throughput, latency, and packet loss:

Categories:

Internet Privacy (VPN, Tor)
Social Media
Domain Name Service (DNS)
Browsing

Streaming (Video, Audio)

File Sharing (P2P, Cloud)
Instant Messaging

Net Admin (Network Administration)
Ads & Trackers

Webmail (e.g., Gmail, Outlook)
Gaming
Music Streaming
Voice & Video Calls
Location-Based Services
Email
FTP

IM File Transfer (Instant Messaging File Transfer)
Trading
One Click Hosting
Other
Unknown

Formula
The generic formula for QoE calculation is as follows:
[
QoE = w_T \cdot f_{throughput}(T) + w_L \cdot f_{latency}(L) + w_P \cdot f_{packet_loss}(P)
]
Where:

( w_T ), ( w_L ), and ( w_P ) are the weights for throughput, latency, and packet loss respectively.
( f_{throughput}(T) ), ( f_{latency}(L) ), and ( f_{packet_loss}(P) ) are normalized functions that map throughput, latency, and packet loss into the range [0, 1].

Application Categories and Weight Distribution
Each application category has different weights for throughput, latency, and packet loss based on how critical these factors are for the application's performance.

3.1 Internet Privacy

Throughput Weight (w_T): 0.3

Latency Weight (w_L): 0.5

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{Privacy} = 0.3 \cdot f_{throughput}(T) + 0.5 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.2 Domain Name Service (DNS)

Throughput Weight (w_T): 0.1

Latency Weight (w_L): 0.7

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{DNS} = 0.1 \cdot f_{throughput}(T) + 0.7 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.3 Social Media

Throughput Weight (w_T): 0.5

Latency Weight (w_L): 0.3

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{SocialMedia} = 0.5 \cdot f_{throughput}(T) + 0.3 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.4 Browsing

Throughput Weight (w_T): 0.4

Latency Weight (w_L): 0.4

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{Browsing} = 0.4 \cdot f_{throughput}(T) + 0.4 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.5 Streaming (Video, Audio)

Throughput Weight (w_T): 0.6

Latency Weight (w_L): 0.3

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{Streaming} = 0.6 \cdot f_{throughput}(T) + 0.3 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.6 File Sharing

Throughput Weight (w_T): 0.7

Latency Weight (w_L): 0.1

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{FileSharing} = 0.7 \cdot f_{throughput}(T) + 0.1 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.7 Instant Messaging

Throughput Weight (w_T): 0.4

Latency Weight (w_L): 0.4

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{InstantMessaging} = 0.4 \cdot f_{throughput}(T) + 0.4 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.8 Net Admin (Network Administration)

Throughput Weight (w_T): 0.5

Latency Weight (w_L): 0.3

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{NetAdmin} = 0.5 \cdot f_{throughput}(T) + 0.3 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.9 Ads & Trackers

Throughput Weight (w_T): 0.2

Latency Weight (w_L): 0.5

Packet Loss Weight (w_P): 0.3

Formula:
[
QoE_{AdsTrackers} = 0.2 \cdot f_{throughput}(T) + 0.5 \cdot f_{latency}(L) + 0.3 \cdot f_{packet_loss}(P)
]

3.10 Webmail (e.g., Gmail, Outlook)

Throughput Weight (w_T): 0.4

Latency Weight (w_L): 0.4

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{Webmail} = 0.4 \cdot f_{throughput}(T) + 0.4 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.11 Gaming

Throughput Weight (w_T): 0.3

Latency Weight (w_L): 0.6

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{Gaming} = 0.3 \cdot f_{throughput}(T) + 0.6 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.12 Music Streaming

Throughput Weight (w_T): 0.5

Latency Weight (w_L): 0.4

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{MusicStreaming} = 0.5 \cdot f_{throughput}(T) + 0.4 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.13 Voice & Video Calls

Throughput Weight (w_T): 0.3

Latency Weight (w_L): 0.6

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{VoiceVideoCalls} = 0.3 \cdot f_{throughput}(T) + 0.6 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.14 Location Based Services

Throughput Weight (w_T): 0.3

Latency Weight (w_L): 0.5

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{LocationBasedServices} = 0.3 \cdot f
{throughput}(T) + 0.5 \cdot f{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.15 Email

Throughput Weight (w_T): 0.4

Latency Weight (w_L): 0.4

Packet Loss Weight (w_P): 0.2

Formula:
[
QoE_{Email} = 0.4 \cdot f_{throughput}(T) + 0.4 \cdot f_{latency}(L) + 0.2 \cdot f_{packet_loss}(P)
]

3.16 FTP

Throughput Weight (w_T): 0.6

Latency Weight (w_L): 0.3

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{FTP} = 0.6 \cdot f_{throughput}(T) + 0.3 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.17 IM File Transfer (Instant Messaging File Transfer)

Throughput Weight (w_T): 0.5

Latency Weight (w_L): 0.4

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{IMFileTransfer} = 0.5 \cdot f_{throughput}(T) + 0.4 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.18 Trading

Throughput Weight (w_T): 0.2

Latency Weight (w_L): 0.7

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{Trading} = 0.2 \cdot f_{throughput}(T) + 0.7 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.19 One Click Hosting

Throughput Weight (w_T): 0.7

Latency Weight (w_L): 0.2

Packet Loss Weight (w_P): 0.1

Formula:
[
QoE_{OneClickHosting} = 0.7 \cdot f_{throughput}(T) + 0.2 \cdot f_{latency}(L) + 0.1 \cdot f_{packet_loss}(P)
]

3.20 Other

For categories not listed, you may define custom weight values based on the criticality of throughput, latency, and packet loss for that specific application.

3.21 Unknown

When the application category is unknown, equal weights are applied.

Throughput Weight (w_T): 0.33

Latency Weight (w_L): 0.33

Packet Loss Weight (w_P): 0.33

Formula:
[
QoE_{Unknown} = 0.33 \cdot f_{throughput}(T) + 0.33 \cdot f_{latency}(L) + 0.33 \cdot f_{packet_loss}(P)
]

Normalization
For every application category, the values of throughput, latency, and packet loss are normalized using the following formulas:

Throughput: ( f_{throughput}(T) = \frac{T}{T_{max}} )

Latency: ( f_{latency}(L) = \frac{L_{max} - L}{L_{max}} )

Packet Loss: ( f_{packet_loss}(P) = 1 - \frac{P}{P_{max}} )

How to Use

Clone the repository.

Modify the weights for specific categories if necessary.

Input network metrics for each application category.

Run the script to calculate QoE scores.

Interpret the QoE score (0 = poor, 1 = excellent).

Requirements

Python 3.x
Libraries: numpy (for normalization and calculation)

Contribution
Feel free to submit pull requests if you'd like to improve the QoE calculation framework or add new categories.
so recreate full code with these cahnegs updated completed

use please the env already code uses it
.env
672 B

Categories and their corresponding weights
CATEGORIES="Internet Privacy,Domain Name Service,Social Media,Browsing,Streaming,File Sharing,Instant Messaging,Net Admin,Ads & Trackers,Webmail,Gaming,Music Streaming,Voice & Video Calls,Location Based Services,Email,FTP,IM File Transfer,Trading,One Click Hosting,Other,Unknown"

Weights for each category
WEIGHTS="0.3,0.5,0.2;0.1,0.7,0.2;0.5,0.3,0.2;0.4,0.4,0.2;0.6,0.3,0.1;0.7,0.1,0.2;0.4,0.4,0.2;0.5,0.3,0.2;0.2,0.5,0.3;0.4,0.4,0.2;0.3,0.6,0.1;0.5,0.4,0.1;0.3,0.5,0.2;0.4,0.4,0.2;0.6,0.3,0.1;0.5,0.4,0.1;0.2,0.7,0.1;0.7,0.2,0.1;0.33,0.33,0.34;0.33,0.33,0.34"

Max values for normalization
L_MAX=300
THROUGHPUT_MAX=1000
give complete code with explanation and do my tasks