yashbaidya commited on
Commit
d54f854
·
1 Parent(s): 58fcfe0
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,19 +1,17 @@
1
  import os
2
  import requests
3
  from typing import List
4
- from dotenv import load_dotenv
5
  from openai import OpenAI
6
  # import google.generativeai
7
  # import anthropic
8
  import gradio as gr # oh yeah!
9
 
10
- openai_api_key = os.getenv('OPENAI_API_KEY')
11
- if openai_api_key:
12
- print(f"OpenAI API Key exists and begins {openai_api_key[:8]}")
13
- else:
14
- print("OpenAI API Key not set")
15
 
16
- openai = OpenAI()
17
  system_message = "You are a helpful assistant"
18
 
19
  def create_gtm(product,location):
@@ -62,6 +60,12 @@ def create_usp(product,location,segment):
62
 
63
  with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
64
 
 
 
 
 
 
 
65
  with gr.Row():
66
  with gr.Column():
67
  with gr.Row():
 
1
  import os
2
  import requests
3
  from typing import List
 
4
  from openai import OpenAI
5
  # import google.generativeai
6
  # import anthropic
7
  import gradio as gr # oh yeah!
8
 
9
+ openai_api_key=None
10
+ def set_openai_api_key(apikey):
11
+ openai_api_key=apikey
12
+ return "API key set"
 
13
 
14
+ openai = OpenAI(api_key=openai_api_key)
15
  system_message = "You are a helpful assistant"
16
 
17
  def create_gtm(product,location):
 
60
 
61
  with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
62
 
63
+ with gr.Row():
64
+ API=gr.Textbox(label="Enter OpenAI API key")
65
+ set_api=gr.Button("Set API key")
66
+ showAPI=gr.Text()
67
+ set_api.click(fn=set_openai_api_key, inputs=[API], outputs=[showAPI])
68
+
69
  with gr.Row():
70
  with gr.Column():
71
  with gr.Row():