Spaces:
Runtime error
Runtime error
Commit
·
a8ee66f
1
Parent(s):
9b06190
functional
Browse files
app.py
CHANGED
|
@@ -15,14 +15,12 @@ def gpt3(prompt):
|
|
| 15 |
model='gpt3.5', messages=[{"role": "user", "content": prompt}])
|
| 16 |
return response['choices'][0]['message']['content']
|
| 17 |
|
| 18 |
-
def respond(
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
input_ids = tokenizer.encode(prompt, return_tensors="pt")
|
| 22 |
output_ids = model.generate(input_ids, max_length=50, num_beams=5, no_repeat_ngram_size=2)
|
| 23 |
bot_message = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
| 24 |
|
| 25 |
-
chat_history.append((
|
| 26 |
time.sleep(2)
|
| 27 |
return "", chat_history
|
| 28 |
|
|
@@ -32,6 +30,8 @@ def interface(tab_name):
|
|
| 32 |
textbox_prompt = gr.Textbox(show_label=False, placeholder="Write a prompt and press enter")
|
| 33 |
openai.api_key = gr.Textbox(label="Open AI Key", placeholder="Enter your Openai key here", type="password")
|
| 34 |
|
|
|
|
|
|
|
| 35 |
gr.Markdown("Strategy 1 QA-Based Prompting")
|
| 36 |
with gr.Row():
|
| 37 |
vicuna_S1_chatbot = gr.Chatbot(label="vicuna-7b")
|
|
|
|
| 15 |
model='gpt3.5', messages=[{"role": "user", "content": prompt}])
|
| 16 |
return response['choices'][0]['message']['content']
|
| 17 |
|
| 18 |
+
def respond(message, chat_history):
|
| 19 |
+
input_ids = tokenizer.encode(message, return_tensors="pt")
|
|
|
|
|
|
|
| 20 |
output_ids = model.generate(input_ids, max_length=50, num_beams=5, no_repeat_ngram_size=2)
|
| 21 |
bot_message = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
| 22 |
|
| 23 |
+
chat_history.append((message, bot_message))
|
| 24 |
time.sleep(2)
|
| 25 |
return "", chat_history
|
| 26 |
|
|
|
|
| 30 |
textbox_prompt = gr.Textbox(show_label=False, placeholder="Write a prompt and press enter")
|
| 31 |
openai.api_key = gr.Textbox(label="Open AI Key", placeholder="Enter your Openai key here", type="password")
|
| 32 |
|
| 33 |
+
prompt = template_single.format(tab_name, textbox_prompt)
|
| 34 |
+
|
| 35 |
gr.Markdown("Strategy 1 QA-Based Prompting")
|
| 36 |
with gr.Row():
|
| 37 |
vicuna_S1_chatbot = gr.Chatbot(label="vicuna-7b")
|