RamV commited on
Commit
c811100
·
1 Parent(s): 926b66c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -2,8 +2,10 @@ import os
2
  import openai
3
  import gradio as gr
4
 
5
- # Set up OpenAI API credentials
6
- openai.api_key = os.environ.get("OPENAI_API_KEY")
 
 
7
 
8
  # Define the conversation prompt
9
  conversation_prompt = "Welcome to ChatRobo, kindly type in your enquiries: "
@@ -22,24 +24,18 @@ def openai_chat_history(input, history):
22
  return ""
23
 
24
  def openai_create(prompt):
25
- # Check if user input contains the phrase "who created you"
26
- if "who created you" in prompt.lower():
27
- # Generate a response that includes your name
28
- chat_response = "I was created by [YOUR NAME HERE]!"
29
- else:
30
- response = openai.Completion.create(
31
- model="text-davinci-003",
32
- prompt=prompt,
33
- temperature=0.9,
34
- max_tokens=150,
35
- top_p=1,
36
- frequency_penalty=0,
37
- presence_penalty=0.6,
38
- stop=["Human:", "AI:"]
39
- )
40
- chat_response = response.choices[0].text
41
 
42
- return chat_response
43
 
44
  block = gr.Interface(
45
  fn=openai_chat_history,
@@ -49,4 +45,3 @@ block = gr.Interface(
49
  block.launch()
50
 
51
 
52
-
 
2
  import openai
3
  import gradio as gr
4
 
5
+ api_key = os.environ.get("OPENAI_API_KEY")
6
+
7
+ start_sequence = "\nAI:"
8
+ restart_sequence = "\nHuman: "
9
 
10
  # Define the conversation prompt
11
  conversation_prompt = "Welcome to ChatRobo, kindly type in your enquiries: "
 
24
  return ""
25
 
26
  def openai_create(prompt):
27
+ response = openai.Completion.create(
28
+ model="text-davinci-003",
29
+ prompt=prompt,
30
+ temperature=0.9,
31
+ max_tokens=150,
32
+ top_p=1,
33
+ frequency_penalty=0,
34
+ presence_penalty=0.6,
35
+ stop=["Human:", "AI:"]
36
+ )
 
 
 
 
 
 
37
 
38
+ return response.choices[0].text
39
 
40
  block = gr.Interface(
41
  fn=openai_chat_history,
 
45
  block.launch()
46
 
47