VikranthBhat/navigation-slm
0
๐งญ TraderTreasure Navigation Assistant
This Space hosts an AI-powered navigation chatbot for the TraderTreasure commodity trading application.
โจ Features
- Natural Language Navigation - Just tell it where you want to go
- Typo Tolerant - Handles misspellings gracefully
- Category Aware - Understands the Master section hierarchy
- High Accuracy - Trained on 500+ navigation patterns
๐ Usage
Web Interface
Simply type your query in the text box:
- "take me to brokers"
- "show clients in master"
- "where can I see reports?"
- "help" - lists all available pages
API Access
You can access this chatbot programmatically:
Using Gradio Client (Python)
from gradio_client import Client
client = Client("YOUR_USERNAME/navigation-chatbot")
result = client.predict(
query="take me to brokers",
api_name="/predict"
)
print(result)
# Output: {"route": "/management/brokers", "confidence": "98.5%", "query": "take me to brokers"}Using Gradio Client (JavaScript/TypeScript)
import { Client } from "@gradio/client";
const client = await Client.connect("YOUR_USERNAME/navigation-chatbot");
const result = await client.predict("/predict", {
query: "take me to brokers"
});
console.log(result.data);Using REST API
curl -X POST "https://YOUR_USERNAME-navigation-chatbot.hf.space/api/predict" \
-H "Content-Type: application/json" \
-d '{"data": ["take me to brokers"]}'๐ Available Pages
General Section
Master Section
๐ง Integration with Your App
NestJS Backend Integration
// navigation.service.ts
import { Injectable } from '@nestjs/common';
@Injectable()
export class NavigationService {
private readonly apiUrl = 'https://YOUR_USERNAME-navigation-chatbot.hf.space/api/predict';
async getNavigation(query: string): Promise<{route: string, confidence: string}> {
const response = await fetch(this.apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ data: [query] })
});
const result = await response.json();
return JSON.parse(result.data[0]);
}
}React Frontend Integration
// useNavigation.ts
import { useState } from 'react';
export function useNavigation() {
const [loading, setLoading] = useState(false);
const navigate = async (query: string) => {
setLoading(true);
try {
const response = await fetch('/api/chat/navigate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query })
});
const { route } = await response.json();
if (route && !route.startsWith('HELP') && !route.startsWith('MASTER')) {
window.location.href = route;
}
return route;
} finally {
setLoading(false);
}
};
return { navigate, loading };
}๐ Model Information
- Base Model: DistilBERT (distilbert-base-uncased)
- Training Examples: 500+
- Task: Text Classification (Navigation Intent)
- Accuracy: ~95% on test set
๐ License
MIT License - Feel free to use and modify!
๐ค Contributing
To add new pages to the model:
- Update
training_data.jsonwith new examples - Re-train the model in Google Colab
- Push updated model to Hugging Face Hub
- The Space will automatically use the new model
Built with โค๏ธ for TraderTreasure
