Dagfinn1962 commited on
Commit
0e957b2
1 Parent(s): 8f4e89d

Update src/llm_boilers.py

Browse files
Files changed (1) hide show
  1. src/llm_boilers.py +15 -10
src/llm_boilers.py CHANGED
@@ -6,12 +6,6 @@ import os
6
 
7
  import openai
8
 
9
- model_id = "gpt-3.5-turbo"
10
- openai_key = "<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>"
11
-
12
- model = llm_boiler(model_id, openai_key)
13
-
14
-
15
  # supress warnings
16
  warnings.filterwarnings("ignore")
17
 
@@ -80,7 +74,7 @@ def gpt(
80
  temperature (float, optional): The value used to modulate the next token probabilities.
81
  Defaults to 1.0
82
  """
83
- conversation = prompt.split("<|im_start|>")
84
 
85
  messages = []
86
  for turn in conversation:
@@ -90,14 +84,14 @@ def gpt(
90
  messages.append(
91
  {
92
  "role": "system",
93
- "content": turn.replace("system\n", "").replace("<|im_end|>\n", ""),
94
  }
95
  )
96
  elif first_word == "user":
97
  messages.append(
98
  {
99
  "role": "user",
100
- "content": turn.replace("user\n", "").replace("<|im_end|>\n", ""),
101
  }
102
  )
103
  elif first_word == "assistant":
@@ -105,7 +99,7 @@ def gpt(
105
  {
106
  "role": "assistant",
107
  "content": turn.replace("assistant\n", "").replace(
108
- "<|im_end|>\n", ""
109
  ),
110
  }
111
  )
@@ -122,3 +116,14 @@ def gpt(
122
 
123
 
124
  MODEL_FUNCTIONS.append(gpt)
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  import openai
8
 
 
 
 
 
 
 
9
  # supress warnings
10
  warnings.filterwarnings("ignore")
11
 
 
74
  temperature (float, optional): The value used to modulate the next token probabilities.
75
  Defaults to 1.0
76
  """
77
+ conversation = prompt.split("")
78
 
79
  messages = []
80
  for turn in conversation:
 
84
  messages.append(
85
  {
86
  "role": "system",
87
+ "content": turn.replace("system\n", "").replace("\n", ""),
88
  }
89
  )
90
  elif first_word == "user":
91
  messages.append(
92
  {
93
  "role": "user",
94
+ "content": turn.replace("user\n", "").replace("\n", ""),
95
  }
96
  )
97
  elif first_word == "assistant":
 
99
  {
100
  "role": "assistant",
101
  "content": turn.replace("assistant\n", "").replace(
102
+ "\n", ""
103
  ),
104
  }
105
  )
 
116
 
117
 
118
  MODEL_FUNCTIONS.append(gpt)
119
+
120
+ # Define the model and its parameters
121
+ model_id = "dfurman/chat-gpt-3.5-turbo"
122
+ openai_key = "<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>"
123
+
124
+ model = llm_boiler(model_id, openai_key)
125
+
126
+ prompt = "Hello, how are you?"
127
+ temperature = 0.8
128
+
129
+ response = model.run(prompt, temperature)