A reinforcement learning environment simulating a jewelry shop management pipeline. An AI agent navigates three sequential phases — buying raw materials, selecting products to craft based on demand, and negotiating sales — to maximize profit.
Environment Overview
Phase 1: Market (Buy / Wait)
Gold prices fluctuate ±10% each round (up to 3 rounds).
The agent analyzes price trends and decides to buy gold or wait for a better price.
Goal: Buy gold at the lowest possible price while reserving cash for crafting labor.
Phase 2: Warehouse (Product Selection)
The agent sees demand levels for each product type:
Product
Gold (oz)
Labor ($)
Demand Range
Ring
1.0
$200
40-100%
Necklace
2.0
$300
20-80%
Bracelet
0.5
$100
10-60%
The agent picks the highest-demand product it can afford to craft.
Goal: Match production to market demand.
Phase 3: Showroom (Negotiation)
A customer makes an initial offer based on cost basis and product demand.
The agent can accept, counter-offer, or reject.
Each counter raises the customer's offer by 5% (up to 5 rounds).
Goal: Sell at maximum profit through smart negotiation.
1from ShopManagerEng import JewelryAction, JewelryShopEnv
23asyncdefrun():4 env = JewelryShopEnv(base_url="http://localhost:8000")56 result =await env.reset()7print(f"Gold price: ${result.observation.gold_price}/oz")89# Phase 1 — Market: wait for better price10 result =await env.step(JewelryAction(market_action="wait"))1112# Phase 1 — Market: buy gold13 result =await env.step(JewelryAction(market_action="buy", gold_qty=2.0))1415# Phase 2 — Warehouse: choose product16 result =await env.step(JewelryAction(product_choice="ring"))1718# Phase 3 — Showroom: negotiate19 result =await env.step(JewelryAction(message="How about $600?"))20 result =await env.step(JewelryAction(message="I accept"))2122print(f"Final reward: {result.reward}, Cash: {result.observation.cash}")23await env.close()2425import asyncio
26asyncio.run(run())
Action Space
python
1classJewelryAction:2 market_action:str# "buy" or "wait" (Phase 1)3 gold_qty:float# Ounces to buy (Phase 1)4 product_choice:str# "ring", "necklace", or "bracelet" (Phase 2)5 message:str# Negotiation text (Phase 3)
Observation Space
python
1classJewelryObservation:2 phase:str# "market" | "warehouse" | "showroom"3 cash:float# Current cash balance4 gold_oz:float# Raw gold in inventory5 gold_price:float# Current gold price ($/oz)6 gold_price_history: List[float]# Price trend for analysis7 market_round:int# Current market round8 demand: Dict[str,float]# Demand per product (0-1)9 product_catalog: Dict[str,dict]# Specs per product10 inventory: Dict[str,int]# Crafted products in stock11 product_for_sale:str# Product being sold (showroom)12 cost_basis:float# Total manufacturing cost13 current_offer:float# Customer's current offer14 negotiation_round:int# Counter-offer round15 message:str# Environment feedback
Running the Inference Script
bash
1# Terminal 1: Start the server2cd ShopManagerEng
3uv run server
45# Terminal 2: Run inference (from parent directory or inside ShopManagerEng)6python inference.py
Required environment variables (set in .env):
HF_TOKEN — Hugging Face API token
MODEL_NAME — LLM model (default: meta-llama/Llama-3.3-70B-Instruct)