Spaces:
Sleeping
Sleeping
bhaskartripathi
commited on
Commit
•
ea4d797
1
Parent(s):
ffffc8f
Update app.py
Browse files
app.py
CHANGED
@@ -100,14 +100,20 @@ def load_recommender(path, start_page=1):
|
|
100 |
|
101 |
def generate_text(openAI_key, prompt, model="gpt-3.5-turbo"):
|
102 |
openai.api_key = openAI_key
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
if model == "text-davinci-003":
|
104 |
completions = openai.Completion.create(
|
105 |
engine=model,
|
106 |
prompt=prompt,
|
107 |
-
max_tokens=
|
108 |
n=1,
|
109 |
stop=None,
|
110 |
-
temperature=
|
111 |
)
|
112 |
message = completions.choices[0].text
|
113 |
else:
|
@@ -115,8 +121,14 @@ def generate_text(openAI_key, prompt, model="gpt-3.5-turbo"):
|
|
115 |
model=model,
|
116 |
messages=[
|
117 |
{"role": "system", "content": "You are a helpful assistant."},
|
|
|
118 |
{"role": "user", "content": prompt}
|
119 |
-
]
|
|
|
|
|
|
|
|
|
|
|
120 |
).choices[0].message['content']
|
121 |
return message
|
122 |
|
|
|
100 |
|
101 |
def generate_text(openAI_key, prompt, model="gpt-3.5-turbo"):
|
102 |
openai.api_key = openAI_key
|
103 |
+
temperature=0.7
|
104 |
+
max_tokens=256
|
105 |
+
top_p=1
|
106 |
+
frequency_penalty=0
|
107 |
+
presence_penalty=0
|
108 |
+
|
109 |
if model == "text-davinci-003":
|
110 |
completions = openai.Completion.create(
|
111 |
engine=model,
|
112 |
prompt=prompt,
|
113 |
+
max_tokens=max_tokens,
|
114 |
n=1,
|
115 |
stop=None,
|
116 |
+
temperature=temperature,
|
117 |
)
|
118 |
message = completions.choices[0].text
|
119 |
else:
|
|
|
121 |
model=model,
|
122 |
messages=[
|
123 |
{"role": "system", "content": "You are a helpful assistant."},
|
124 |
+
{"role": "assistant", "content": "Here is some initial assistant message."},
|
125 |
{"role": "user", "content": prompt}
|
126 |
+
],
|
127 |
+
temperature=temperature,
|
128 |
+
max_tokens=max_tokens,
|
129 |
+
top_p=top_p,
|
130 |
+
frequency_penalty=frequency_penalty,
|
131 |
+
presence_penalty=presence_penalty,
|
132 |
).choices[0].message['content']
|
133 |
return message
|
134 |
|