Spaces:
Configuration error
Configuration error
Update main.py
Browse files
main.py
CHANGED
@@ -3,22 +3,19 @@ from pymongo import MongoClient
|
|
3 |
import pandas as pd
|
4 |
import os
|
5 |
|
6 |
-
# Ortam değişkeninden secret key'i al
|
7 |
-
secret_key = os.getenv('huggingface_key')
|
8 |
|
9 |
-
|
10 |
print(f"Secret Key: {secret_key}")
|
11 |
|
12 |
|
13 |
-
|
14 |
client = MongoClient('mongodb://localhost:27017/')
|
15 |
db = client['EgitimDatabase']
|
16 |
collection = db['test']
|
17 |
|
18 |
-
# Model eğitme fonksiyonu (örnek)
|
19 |
def train_model(filtered_data):
|
20 |
-
|
21 |
-
|
22 |
model_response = {
|
23 |
'status': 'success',
|
24 |
'message': 'Model trained successfully!',
|
@@ -29,7 +26,7 @@ def train_model(filtered_data):
|
|
29 |
|
30 |
# Gradio uygulaması için fonksiyon
|
31 |
def train_model_gradio(title,keywords,subheadings):
|
32 |
-
|
33 |
query = {
|
34 |
'title': {'$in': title},
|
35 |
'category': {'$in': keywords.split(',')},
|
@@ -37,7 +34,7 @@ def train_model_gradio(title,keywords,subheadings):
|
|
37 |
}
|
38 |
filtered_data = list(collection.find(query))
|
39 |
|
40 |
-
|
41 |
response = train_model(filtered_data)
|
42 |
return response
|
43 |
|
|
|
3 |
import pandas as pd
|
4 |
import os
|
5 |
|
|
|
|
|
6 |
|
7 |
+
secret_key = os.getenv('huggingface_key')
|
8 |
print(f"Secret Key: {secret_key}")
|
9 |
|
10 |
|
11 |
+
|
12 |
client = MongoClient('mongodb://localhost:27017/')
|
13 |
db = client['EgitimDatabase']
|
14 |
collection = db['test']
|
15 |
|
|
|
16 |
def train_model(filtered_data):
|
17 |
+
|
18 |
+
|
19 |
model_response = {
|
20 |
'status': 'success',
|
21 |
'message': 'Model trained successfully!',
|
|
|
26 |
|
27 |
# Gradio uygulaması için fonksiyon
|
28 |
def train_model_gradio(title,keywords,subheadings):
|
29 |
+
|
30 |
query = {
|
31 |
'title': {'$in': title},
|
32 |
'category': {'$in': keywords.split(',')},
|
|
|
34 |
}
|
35 |
filtered_data = list(collection.find(query))
|
36 |
|
37 |
+
|
38 |
response = train_model(filtered_data)
|
39 |
return response
|
40 |
|