Shubhy commited on
Commit
e8bd651
1 Parent(s): f4635a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -12,9 +12,16 @@ def process_quote(quote, action):
12
  author = "John Doe"
13
  return f"The author of the quote '{quote}' is {author}."
14
  elif action == "explain quote":
15
- # Code to explain the quote
16
- # You can replace this with your own logic or API call
17
- explanation = "This quote means..."
 
 
 
 
 
 
 
18
  return f"Explanation of the quote '{quote}': {explanation}."
19
  elif action == "generate similar quote":
20
  # Call OpenAI API to generate a similar quote
@@ -37,4 +44,4 @@ output_text = gr.outputs.Textbox()
37
  interface = gr.Interface(fn=process_quote, inputs=[quote_input, action_input], outputs=output_text)
38
 
39
  # Run the interface
40
- interface.launch()
 
12
  author = "John Doe"
13
  return f"The author of the quote '{quote}' is {author}."
14
  elif action == "explain quote":
15
+ # Call OpenAI API to explain the quote
16
+ response = openai.Completion.create(
17
+ engine="text-davinci-003",
18
+ prompt=f"Explain the quote: '{quote}'",
19
+ max_tokens=50,
20
+ n=1,
21
+ stop=None,
22
+ temperature=0.7
23
+ )
24
+ explanation = response.choices[0].text.strip()
25
  return f"Explanation of the quote '{quote}': {explanation}."
26
  elif action == "generate similar quote":
27
  # Call OpenAI API to generate a similar quote
 
44
  interface = gr.Interface(fn=process_quote, inputs=[quote_input, action_input], outputs=output_text)
45
 
46
  # Run the interface
47
+ interface.launch()