Blessin commited on
Commit
909dcda
·
1 Parent(s): 7ea919d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -51,23 +51,22 @@ def set_openai_key(api_key):
51
  openai.api_key = api_key
52
 
53
  def generate_statement(api_key, use_gpt):
54
- try:
55
- # Set the OpenAI API key using the provided input
56
- set_openai_key(api_key)
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- if use_gpt:
59
- # Generate a statement using OpenAI's GPT 3.5 Turbo model
60
- response = openai.Completion.create(
61
- engine="gpt-3.5-turbo",
62
- prompt="Provide a short and intriguing dialogue that can be incorporated into an improvisation scene to provoke unexpected reactions and drive the narrative in interesting directions.",
63
- max_tokens=15
64
- )
65
- return response.choices[0].text.strip()
66
- else:
67
- # Return a random dialogue from the provided list
68
- return random.choice(DIALOGUES)
69
- except Exception as e:
70
- return str(e)
71
 
72
  def main():
73
  # Define the UI components using gr.Interface
 
51
  openai.api_key = api_key
52
 
53
  def generate_statement(api_key, use_gpt):
54
+ # Set the OpenAI API key
55
+ set_openai_key(api_key)
56
+
57
+ if use_gpt:
58
+ # Generate a statement using OpenAI's davinci model
59
+ response = openai.Completion.create(
60
+ engine="davinci",
61
+ prompt="Provide a short and intriguing dialogue that can be incorporated into an improvisation scene to provoke unexpected reactions and drive the narrative in interesting directions.",
62
+ max_tokens=15
63
+ )
64
+ return response.choices[0].text.strip()
65
+ else:
66
+ # Return a random dialogue from the provided list
67
+ return random.choice(DIALOGUES)
68
+
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  def main():
72
  # Define the UI components using gr.Interface