ramalMr commited on
Commit
34421df
·
verified ·
1 Parent(s): 4b9c814

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -7,7 +7,7 @@ from io import BytesIO
7
  import csv
8
  import os
9
  import io
10
-
11
  # Initialize the inference client with your chosen model
12
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
13
 
@@ -23,6 +23,7 @@ def save_to_csv(sentence, output, filename="synthetic_data.csv"):
23
  writer = csv.writer(file)
24
  writer.writerow([sentence, output])
25
 
 
26
  def generate(file, temperature, max_new_tokens, top_p, repetition_penalty):
27
  text = extract_text_from_pdf(file)
28
  sentences = text.split('.')
@@ -62,7 +63,13 @@ def generate(file, temperature, max_new_tokens, top_p, repetition_penalty):
62
  with open("synthetic_data.csv", "r", encoding="utf-8") as file:
63
  csv_content = file.read()
64
  csv_bytes = csv_content.encode()
65
- return io.BytesIO(csv_bytes)
 
 
 
 
 
 
66
  gr.Interface(
67
  fn=generate,
68
  inputs=[
 
7
  import csv
8
  import os
9
  import io
10
+ import tempfile
11
  # Initialize the inference client with your chosen model
12
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
13
 
 
23
  writer = csv.writer(file)
24
  writer.writerow([sentence, output])
25
 
26
+
27
  def generate(file, temperature, max_new_tokens, top_p, repetition_penalty):
28
  text = extract_text_from_pdf(file)
29
  sentences = text.split('.')
 
63
  with open("synthetic_data.csv", "r", encoding="utf-8") as file:
64
  csv_content = file.read()
65
  csv_bytes = csv_content.encode()
66
+
67
+ # Geçici dosya oluştur ve içeriği yaz
68
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as tmp:
69
+ tmp.write(csv_bytes)
70
+ tmp_path = tmp.name
71
+
72
+ return tmp_path
73
  gr.Interface(
74
  fn=generate,
75
  inputs=[