Spaces:
Build error
Build error
jh000107
commited on
Commit
·
cc9e3ea
1
Parent(s):
11cca34
handling openai key
Browse files
app.py
CHANGED
|
@@ -189,7 +189,8 @@ def get_completion(conversation, model="gpt-4-1106-preview"):
|
|
| 189 |
"""
|
| 190 |
|
| 191 |
client = OpenAI()
|
| 192 |
-
|
|
|
|
| 193 |
messages = [{"role": "user", "content": prompt}]
|
| 194 |
response = client.chat.completions.create(
|
| 195 |
model=model,
|
|
@@ -304,10 +305,11 @@ with gr.Blocks() as gpt_analysis:
|
|
| 304 |
volunteer's perspective.<br /> Click on them and submit them to the model to see how it works.")
|
| 305 |
conversation = gr.Textbox(label="Input", lines=2)
|
| 306 |
btn = gr.Button(value="Submit")
|
|
|
|
| 307 |
with gr.Row():
|
| 308 |
output_box = gr.Textbox(value="", label="Output",lines=4)
|
| 309 |
plot_box = gr.Plot(label="Analysis Plot")
|
| 310 |
|
| 311 |
btn.click(get_completion, inputs=conversation, outputs=[output_box, plot_box])
|
| 312 |
|
| 313 |
-
gr.TabbedInterface([gpt_analysis], ["GPT
|
|
|
|
| 189 |
"""
|
| 190 |
|
| 191 |
client = OpenAI()
|
| 192 |
+
openai.api_key = os.environ['OPENAI_KEY']
|
| 193 |
+
|
| 194 |
messages = [{"role": "user", "content": prompt}]
|
| 195 |
response = client.chat.completions.create(
|
| 196 |
model=model,
|
|
|
|
| 305 |
volunteer's perspective.<br /> Click on them and submit them to the model to see how it works.")
|
| 306 |
conversation = gr.Textbox(label="Input", lines=2)
|
| 307 |
btn = gr.Button(value="Submit")
|
| 308 |
+
|
| 309 |
with gr.Row():
|
| 310 |
output_box = gr.Textbox(value="", label="Output",lines=4)
|
| 311 |
plot_box = gr.Plot(label="Analysis Plot")
|
| 312 |
|
| 313 |
btn.click(get_completion, inputs=conversation, outputs=[output_box, plot_box])
|
| 314 |
|
| 315 |
+
gr.TabbedInterface([gpt_analysis], ["GPT Analysis"]).launch(inline=False)
|