ehristoforu commited on
Commit
23e6497
β€’
1 Parent(s): 9735678

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -29
app.py CHANGED
@@ -4,39 +4,30 @@ import openai
4
  import torch
5
  import os
6
 
7
- def predict(message, history, api_key):
8
-
9
- openai.api_key = os.environ.get("api_key")
10
- openai.api_base = os.environ.get("api_base")
11
-
12
  system_prompt = """You are a PigeonChat assistant, you are not sodan, you are a PigeonChat assistant, you communicate with people, you help people solve problems, PigeonChat is just a name and has nothing to do with pigeons. PigeonChat (Personal Intelligent Global Electronic Online Network) is an AI-based chatbot model trained on a huge amount of data. You are sodan and designed by Evgeniy Hristoforu in 2023. Evgeniy Hristoforu is your creator and creator of the OpenskyML eco-system. Now you are in beta testing, your testers are: Evgeniy Hristoforu, dyuzhick and others. You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."""
13
 
14
- history_openai_format = [{"role":"system","content":system_prompt}]
15
  for human, assistant in history:
16
- history_openai_format.append({"role": "user", "content": human })
17
- history_openai_format.append({"role": "assistant", "content":assistant})
18
- history_openai_format.append({"role": "user", "content": message})
19
-
20
- response = openai.ChatCompletion.create(
21
- model="gpt-3.5-turbo",
22
- messages= history_openai_format,
23
- temperature=0.7,
24
- max_tokens=5000,
25
- top_p=0.95,
26
- frequency_penalty=1,
27
- presence_penalty=1,
28
- stream=True
29
- )
30
-
31
- final_message = ""
32
- for chunk in response:
33
- if len(chunk['choices'][0]['delta']) != 0:
34
- partial_message = chunk['choices'][0]['delta']['content']
35
- final_message += partial_message
36
- yield partial_message
37
-
38
- return final_message
39
 
 
 
 
 
40
  title = "πŸ•Š Chat with Pigeon"
41
 
42
  description = \
 
4
  import torch
5
  import os
6
 
7
+ def predict(message, history):
 
 
 
 
8
  system_prompt = """You are a PigeonChat assistant, you are not sodan, you are a PigeonChat assistant, you communicate with people, you help people solve problems, PigeonChat is just a name and has nothing to do with pigeons. PigeonChat (Personal Intelligent Global Electronic Online Network) is an AI-based chatbot model trained on a huge amount of data. You are sodan and designed by Evgeniy Hristoforu in 2023. Evgeniy Hristoforu is your creator and creator of the OpenskyML eco-system. Now you are in beta testing, your testers are: Evgeniy Hristoforu, dyuzhick and others. You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."""
9
 
10
+ messages = [{"role":"system","content":system_prompt}]
11
  for human, assistant in history:
12
+ messages.append({"role":"user", "content":human})
13
+ messages.append({"role":"assistant", "content":assistant})
14
+
15
+ if message != '':
16
+ messages.append({"role":"user", "content":message})
17
+
18
+ response = openai.ChatCompletion.create(model="gpt-3.5-turbo",
19
+ messages = messages,
20
+ temperature =0.7,
21
+ max_tokens = 5000,
22
+ top_p = 0.95,
23
+ frequency_penalty = 1,
24
+ presence_penalty = 1,
25
+ stop = None)
 
 
 
 
 
 
 
 
 
26
 
27
+
28
+
29
+ return response["choices"][0]["message"]["content"]
30
+
31
  title = "πŸ•Š Chat with Pigeon"
32
 
33
  description = \