cotxetj commited on
Commit
a4cba59
1 Parent(s): 72d8188

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -12,6 +12,13 @@ MODEL = "gpt-3.5-turbo"
12
  API_URL = "https://api.openai.com/v1/chat/completions"
13
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
14
 
 
 
 
 
 
 
 
15
  project = hopsworks.login(project="ServerlessIntroIris")
16
  fs = project.get_feature_store()
17
  dataset1 = fs.get_feature_group(name="daily_topic_info").read()
@@ -20,6 +27,20 @@ dataset2 = fs.get_feature_group(name="daily_document_info").read()
20
  df2 = dataset2
21
  topics = df['topic'].unique()
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def gpt_predict(inputs, request:gr.Request=gr.State([]), top_p = 1, temperature = 1, chat_counter = 0,history =[]):
24
  payload = {
25
  "model": MODEL,
@@ -50,9 +71,7 @@ def gpt_predict(inputs, request:gr.Request=gr.State([]), top_p = 1, temperature
50
  message["content"] = data
51
  messages.append(message)
52
 
53
- message = {}
54
- message["role"] = "user"
55
- message["content"] = inputs
56
  messages.append(message)
57
  payload = {
58
  "model": MODEL,
 
12
  API_URL = "https://api.openai.com/v1/chat/completions"
13
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
14
 
15
+ user_inputs = [
16
+ "[season, gordon, doncic, points, nba, nuggets, rebounds, kuminga, game, raptors]",
17
+ "Give me a precise word for each item in the list.",
18
+ "NBA was ok.",
19
+ "With no brackets."
20
+ ]
21
+
22
  project = hopsworks.login(project="ServerlessIntroIris")
23
  fs = project.get_feature_store()
24
  dataset1 = fs.get_feature_group(name="daily_topic_info").read()
 
27
  df2 = dataset2
28
  topics = df['topic'].unique()
29
 
30
+ conversation_history = []
31
+
32
+ def add_user_input(user_input):
33
+ conversation_history.append({"role": "user", "content": user_input})
34
+ response = get_model_response(conversation_history)
35
+ conversation_history.append({"role": "assistant", "content": response})
36
+
37
+
38
+ # Example usage:
39
+ add_user_input("[season, gordon, doncic, points, nba, nuggets, rebounds, kuminga, game, raptors]")
40
+ add_user_input("Give me a precise word for each item in the list.")
41
+ add_user_input("NBA was ok.")
42
+ add_user_input("With no brackets.")
43
+
44
  def gpt_predict(inputs, request:gr.Request=gr.State([]), top_p = 1, temperature = 1, chat_counter = 0,history =[]):
45
  payload = {
46
  "model": MODEL,
 
71
  message["content"] = data
72
  messages.append(message)
73
 
74
+ message = conversation_history
 
 
75
  messages.append(message)
76
  payload = {
77
  "model": MODEL,