gptaibox commited on
Commit
d5cb50f
1 Parent(s): c791143

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -10,7 +10,7 @@ from transformers import GPT2Tokenizer
10
  import requests
11
 
12
  # define the text summarizer function
13
- def text_prompt(request, system_role, page_url, api_key, temp):
14
  try:
15
  USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
16
 
@@ -45,8 +45,8 @@ def text_prompt(request, system_role, page_url, api_key, temp):
45
 
46
  num_tokens = len(tokens)
47
 
48
- if num_tokens > 10 and api_key.startswith("sk-"):
49
- openai.api_key = api_key
50
  # get the response from openai API
51
  try:
52
  response = openai.ChatCompletion.create(
@@ -83,8 +83,8 @@ iface = gr.Interface(
83
  gr.Textbox(lines=1, placeholder="Enter your API-key here...", label="API-Key:", type="password"),
84
  gr.Slider(0.0,1.0, value=0.7, label="Temperature:")
85
  ],
86
- outputs=[gr.Textbox(label="Output:"), gr.Markdown(label="Output:"), gr.Markdown(label="Total Tokens:")],
87
- examples=[["请用简体中文生成一段200字的摘要,并提取5个关键词.", "作为新闻编辑", "https://openai.com/blog/planning-for-agi-and-beyond","",0.7],
88
  ["Generate a summary of the following text. Give me an overview of the main business impact from the text following this template:\n- Summary:\n- Business Impact:\n- Companies:", "Act as a Business Consultant", "https://ai.googleblog.com/2019/10/quantum-supremacy-using-programmable.html","",0.7],
89
  ["Generate the next insights based on the following text. Indicates N/A if the information is not available in the text.\n- Summary:\n- Acquisition Price:\n- Why is this important for the acquirer:\n- Business Line for the acquirer:\n- Tech Focus for the acquired (list):","Act as a Business Consultant", "https://techcrunch.com/2022/09/28/eqt-acquires-billtrust-a-company-automating-the-invoice-to-cash-process-for-1-7b/","",0.3]
90
  ],
 
10
  import requests
11
 
12
  # define the text summarizer function
13
+ def text_prompt(request, system_role, page_url, contraseña, temp):
14
  try:
15
  USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
16
 
 
45
 
46
  num_tokens = len(tokens)
47
 
48
+ if num_tokens > 10 and contraseña.startswith("sk-"):
49
+ openai.api_key = contraseña
50
  # get the response from openai API
51
  try:
52
  response = openai.ChatCompletion.create(
 
83
  gr.Textbox(lines=1, placeholder="Enter your API-key here...", label="API-Key:", type="password"),
84
  gr.Slider(0.0,1.0, value=0.7, label="Temperature:")
85
  ],
86
+ outputs=[gr.Textbox(label="Input:"), gr.Markdown(label="Output:"), gr.Markdown(label="Total Tokens:")],
87
+ examples=[["请用简体中文生成一段200字的摘要, 并提取5个关键词.", "Act as a News Editor", "https://openai.com/blog/planning-for-agi-and-beyond","",0.7],
88
  ["Generate a summary of the following text. Give me an overview of the main business impact from the text following this template:\n- Summary:\n- Business Impact:\n- Companies:", "Act as a Business Consultant", "https://ai.googleblog.com/2019/10/quantum-supremacy-using-programmable.html","",0.7],
89
  ["Generate the next insights based on the following text. Indicates N/A if the information is not available in the text.\n- Summary:\n- Acquisition Price:\n- Why is this important for the acquirer:\n- Business Line for the acquirer:\n- Tech Focus for the acquired (list):","Act as a Business Consultant", "https://techcrunch.com/2022/09/28/eqt-acquires-billtrust-a-company-automating-the-invoice-to-cash-process-for-1-7b/","",0.3]
90
  ],