RamV commited on
Commit
dd7e3c9
·
1 Parent(s): 98434e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -16,32 +16,30 @@ def generate_response(user_input):
16
  prompt = f"You said: {user_input}"
17
 
18
  # Generate a response using the OpenAI API
 
19
  response = openai.Completion.create(
20
- engine="text-davinci-002",
21
- prompt=prompt,
22
- temperature=0.7,
23
- max_tokens=1024,
24
- n=1,
25
- stop=None,
26
- frequency_penalty=0,
27
- presence_penalty=0
28
- )
 
29
 
30
  # Extract the response from the API output
31
- chat_response = response.choices[0].text.strip()
32
-
33
- return chat_response
34
-
35
- # Test the chatbot
36
- while True:
37
- try:
38
- user_input = input("You: ")
39
- except EOFError:
40
- print("Input stream ended unexpectedly. Exiting program...")
41
- break
42
- response = generate_response(user_input)
43
- print("Chatbot:", response)
44
- print("Welcome to the chatbot!\n")
45
 
46
 
47
 
 
16
  prompt = f"You said: {user_input}"
17
 
18
  # Generate a response using the OpenAI API
19
+ def openai_create(prompt):
20
  response = openai.Completion.create(
21
+ model="text-davinci-003",
22
+ prompt=prompt,
23
+ temperature=0.9,
24
+ max_tokens=150,
25
+ top_p=1,
26
+ frequency_penalty=0,
27
+ presence_penalty=0.6,
28
+ stop=["Human:", "AI:"]
29
+ )
30
+
31
 
32
  # Extract the response from the API output
33
+
34
+
35
+ return response.choices[0].text
36
+
37
+ block = gr.Interface(
38
+ fn=openai_chat_history,
39
+ inputs=[gr.inputs.Textbox(placeholder=conversation_prompt)],
40
+ outputs=[gr.outputs.Textbox(label="ChatRobo Output")]
41
+ )
42
+ block.launch()
 
 
 
 
43
 
44
 
45