Spaces:
Configuration error

chat / main.py
yonkasoft's picture
Update main.py
0977ffe verified
raw
history blame
1.37 kB
import gradio as gr
from pymongo import MongoClient
import pandas as pd
import os
secret_key = os.getenv('huggingface_key')
print(f"Secret Key: {secret_key}")
client = MongoClient('mongodb://localhost:27017/')
db = client['EgitimDatabase']
collection = db['test']
def train_model(filtered_data):
model_response = {
'status': 'success',
'message': 'Model trained successfully!',
'accuracy': 0.95, # Örnek doğruluk değeri
'data_size': len(filtered_data)
}
return model_response
# Gradio uygulaması için fonksiyon
def train_model_gradio(title,keywords,subheadings):
query = {
'title': {'$in': title},
'category': {'$in': keywords.split(',')},
'subheadings': {'$in': subheadings.split(',')}
}
filtered_data = list(collection.find(query))
response = train_model(filtered_data)
return response
# Gradio arayüzü
iface = gr.Interface(
fn=train_model_gradio,
inputs=[
gr.Textbox(label="Title"),
gr.Textbox(label="Keywords (comma-separated)"),
gr.Textbox(label="Subheadings (comma-separated)")
],
outputs="json",
title="Model Training Interface",
description="Enter the titles, categories, subcategories, and subheadings to filter the data and train the model."
)
if __name__ == "__main__":
iface.launch()