diff options
author | Nate Buttke <nate-web@riseup.net> | 2023-08-15 23:29:58 -0700 |
---|---|---|
committer | Nate Buttke <nate-web@riseup.net> | 2023-08-15 23:29:58 -0700 |
commit | 8abc176c440499a4de8406fd58b7d2c0a4e5b9ff (patch) | |
tree | d8d89fa1a4c79c52a75c6046de7ac30643fc8718 /server.py | |
parent | 7435e423776c7b35b9c6c9bebba25a44691554bf (diff) |
use new 3.5 turbo chat model.
Diffstat (limited to 'server.py')
-rw-r--r-- | server.py | 40 |
1 files changed, 28 insertions, 12 deletions
@@ -39,18 +39,34 @@ def generate_answer(question): for i in range(3): prompt += results.iloc[i]["summary"] + "\n" + results.iloc[i]["blob"] + "\n" prompt += "\n" + "Answer the following question using the code context given above, and show an example with 'Example'\nQ: " + question + "\nA: " - response = openai.Completion.create( - model="text-davinci-003", - # model="code-davinci-002", - prompt=prompt, - temperature=0.7, - max_tokens=1000, - top_p=1.0, - frequency_penalty=0.0, - presence_penalty=0.0, - stop=["\"\"\""] - ) - return response["choices"][0]["text"] + + response = openai.ChatCompletion.create( + model="gpt-3.5-turbo", + messages=[{"role": "user", "content": prompt}], + temperature=0.7, + max_tokens=300, + top_p=1.0, + frequency_penalty=0.0, + presence_penalty=0.0, + stop=["\"\"\""] + ) + resp = response["choices"][0]["message"]["content"] + + counter = 0 + outstr = "" + for char in resp: + if counter == 60: + outstr += "\n" + counter = 0 + if char == "\n": + counter = 0 + outstr += " " + else: + counter += 1 + outstr += char + + #return [response["choices"][0]["text"], ""] + return [outstr, ""] def add_to_tree(tree: dict, path: str): parts = PurePosixPath(path).parts |