summaryrefslogtreecommitdiff
path: root/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'server.py')
-rw-r--r--server.py40
1 files changed, 28 insertions, 12 deletions
diff --git a/server.py b/server.py
index 1cd914c..cd27865 100644
--- a/server.py
+++ b/server.py
@@ -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