ysharma HF staff commited on
Commit
5816f03
·
1 Parent(s): 83632e0

updated predict

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -19,7 +19,6 @@ from langchain.schema import (
19
  from langchain.utilities import WikipediaAPIWrapper
20
  from langchain.tools import AIPluginTool
21
 
22
-
23
  # Setting up a system message for our Chatbot
24
  #system = SystemMessage(content = "You are a helpful AI assistant") # that translates English to Pirate English.")
25
 
@@ -30,13 +29,11 @@ def predict(user_input, chatbot):
30
  print(f"user_input - {user_input}")
31
 
32
  chat = ChatOpenAI(
33
- #openai_api_key=openai_api_key,
34
- temperature=1.0, #temperature, #1.0
35
  streaming=True,
36
  model='gpt-3.5-turbo-0613')
37
  #messages = [system]
38
  messages=[]
39
- #function_call_decision = True if any(plugins) else False
40
 
41
  if len(chatbot) != 0:
42
  for conv in chatbot:
@@ -46,7 +43,7 @@ def predict(user_input, chatbot):
46
  messages.append(ai)
47
  messages.append(HumanMessage(content=user_input))
48
  print(f"messages list is - {messages}")
49
-
50
  else: # for first user message
51
  messages.append(HumanMessage(content=user_input))
52
  print(f"messages list is - {messages}")
@@ -57,10 +54,12 @@ def predict(user_input, chatbot):
57
  bot_message = gpt_response.content
58
  print(f"bot_message - {bot_message}")
59
 
60
- chatbot.append((user_input, bot_message))
61
 
62
  #return "", chatbot, None #"", chatbot
63
  return bot_message
64
 
 
 
65
  chatbot = gr.Chatbot()
66
  gr.ChatInterface(predict, chatbot=chatbot, delete_last_btn="del").queue().launch(share=False, debug=True) #examples=["How are you?", "What's up?"],
 
19
  from langchain.utilities import WikipediaAPIWrapper
20
  from langchain.tools import AIPluginTool
21
 
 
22
  # Setting up a system message for our Chatbot
23
  #system = SystemMessage(content = "You are a helpful AI assistant") # that translates English to Pirate English.")
24
 
 
29
  print(f"user_input - {user_input}")
30
 
31
  chat = ChatOpenAI(
32
+ temperature=1.0,
 
33
  streaming=True,
34
  model='gpt-3.5-turbo-0613')
35
  #messages = [system]
36
  messages=[]
 
37
 
38
  if len(chatbot) != 0:
39
  for conv in chatbot:
 
43
  messages.append(ai)
44
  messages.append(HumanMessage(content=user_input))
45
  print(f"messages list is - {messages}")
46
+
47
  else: # for first user message
48
  messages.append(HumanMessage(content=user_input))
49
  print(f"messages list is - {messages}")
 
54
  bot_message = gpt_response.content
55
  print(f"bot_message - {bot_message}")
56
 
57
+ #chatbot.append((user_input, bot_message))
58
 
59
  #return "", chatbot, None #"", chatbot
60
  return bot_message
61
 
62
+
63
+
64
  chatbot = gr.Chatbot()
65
  gr.ChatInterface(predict, chatbot=chatbot, delete_last_btn="del").queue().launch(share=False, debug=True) #examples=["How are you?", "What's up?"],