XINZHANG94 commited on
Commit
0010e43
·
1 Parent(s): 78f7eb8
Files changed (2) hide show
  1. app.py +19 -13
  2. models/put your models here.txt +0 -0
app.py CHANGED
@@ -20,15 +20,17 @@ def upload_file(file_paths):
20
  return file_paths
21
 
22
 
23
- def summary(text, chunk_num, chunk_overlap, api_key, llm_type):
24
- print(text)
 
 
 
25
  api_key = api_key.strip()
26
  llm = ChatOpenAI(temperature=1, openai_api_key=api_key, model_name=llm_type)
27
  rds = RefineDataSummarizer(llm=llm)
28
  result = rds.get_summarization(text, chunk_num=chunk_num, chunk_overlap=chunk_overlap)
29
  return result["output_text"]
30
 
31
-
32
  with gr.Blocks() as demo:
33
  with gr.Row(equal_height=False):
34
  with gr.Column():
@@ -51,15 +53,19 @@ with gr.Blocks() as demo:
51
 
52
  with gr.Column():
53
  transcript_text = gr.Textbox(placeholder="Transcript Result", label="Transcript")
54
- chunk_num = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label="Chunk Number", value=1)
55
- chunk_overlap = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label="Chunk Overlap", value=100)
56
- api_key = gr.Textbox(placeholder="key", label="Your API Key", value=os.getenv("openai_api"))
57
- llm_type = gr.Dropdown(
58
- [
59
- "gpt-3.5-turbo",
60
- "gpt-3.5-turbo-16k",
61
- "gpt-4-1106-preview"
62
- ], label="LLM Type", value="gpt-4-1106-preview")
 
 
 
 
63
  SunmmaryButton = gr.Button("Summary", variant="primary")
64
  summary_text = gr.Textbox(placeholder="Summary Result", label="Summary")
65
 
@@ -78,7 +84,7 @@ with gr.Blocks() as demo:
78
  transcript_text,
79
  chunk_num,
80
  chunk_overlap,
81
- api_key,
82
  llm_type
83
  ],
84
  outputs=[summary_text]
 
20
  return file_paths
21
 
22
 
23
+ def summary(text, chunk_num, chunk_overlap, user_api, llm_type):
24
+ if user_api == "Not Provided":
25
+ api_key = os.getenv("openai_api")
26
+ else:
27
+ api_key = user_api
28
  api_key = api_key.strip()
29
  llm = ChatOpenAI(temperature=1, openai_api_key=api_key, model_name=llm_type)
30
  rds = RefineDataSummarizer(llm=llm)
31
  result = rds.get_summarization(text, chunk_num=chunk_num, chunk_overlap=chunk_overlap)
32
  return result["output_text"]
33
 
 
34
  with gr.Blocks() as demo:
35
  with gr.Row(equal_height=False):
36
  with gr.Column():
 
53
 
54
  with gr.Column():
55
  transcript_text = gr.Textbox(placeholder="Transcript Result", label="Transcript")
56
+
57
+ with gr.Accordion(open=False, label=["summary settings"]):
58
+ chunk_num = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label="Chunk Number", value=1)
59
+ chunk_overlap = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label="Chunk Overlap", value=100)
60
+
61
+ with gr.Accordion(open=False, label=["llm settings"]):
62
+ user_api = gr.Textbox(placeholder="If Empty, Use Default Key", label="Your API Key", value="Not Provided")
63
+ llm_type = gr.Dropdown(
64
+ [
65
+ "gpt-3.5-turbo",
66
+ "gpt-3.5-turbo-16k",
67
+ "gpt-4-1106-preview"
68
+ ], label="LLM Type", value="gpt-4-1106-preview")
69
  SunmmaryButton = gr.Button("Summary", variant="primary")
70
  summary_text = gr.Textbox(placeholder="Summary Result", label="Summary")
71
 
 
84
  transcript_text,
85
  chunk_num,
86
  chunk_overlap,
87
+ user_api,
88
  llm_type
89
  ],
90
  outputs=[summary_text]
models/put your models here.txt ADDED
File without changes