diff --git a/application/api/answer/routes.py b/application/api/answer/routes.py index f109db26..f9ab19be 100644 --- a/application/api/answer/routes.py +++ b/application/api/answer/routes.py @@ -141,17 +141,17 @@ def save_conversation(conversation_id, question, response, source_log_docs, llm) "role": "assistant", "content": "Summarise following conversation in no more than 3 " "words, respond ONLY with the summary, use the same " - "language as the system \n\nUser: " - + question - + "\n\n" - + "AI: " - + response, + "language as the system", }, { "role": "user", "content": "Summarise following conversation in no more than 3 words, " "respond ONLY with the summary, use the same language as the " - "system", + "system \n\nUser: " + + question + + "\n\n" + + "AI: " + + response, }, ] diff --git a/application/llm/docsgpt_provider.py b/application/llm/docsgpt_provider.py index bca39729..bb23d824 100644 --- a/application/llm/docsgpt_provider.py +++ b/application/llm/docsgpt_provider.py @@ -9,35 +9,25 @@ class DocsGPTAPILLM(BaseLLM): super().__init__(*args, **kwargs) self.api_key = api_key self.user_api_key = user_api_key - self.endpoint = "https://llm.docsgpt.co.uk" + self.endpoint = "https://llm.arc53.com" def _raw_gen(self, baseself, model, messages, stream=False, *args, **kwargs): - context = messages[0]["content"] - user_question = messages[-1]["content"] - prompt = f"### Instruction \n {user_question} \n ### Context \n {context} \n ### Answer \n" - response = requests.post( - f"{self.endpoint}/answer", json={"prompt": prompt, "max_new_tokens": 30} + f"{self.endpoint}/answer", json={"messages": messages, "max_new_tokens": 30} ) response_clean = response.json()["a"].replace("###", "") return response_clean def _raw_gen_stream(self, baseself, model, messages, stream=True, *args, **kwargs): - context = messages[0]["content"] - user_question = messages[-1]["content"] - prompt = f"### Instruction \n {user_question} \n ### Context \n {context} \n ### Answer \n" - - # send prompt to endpoint /stream response = requests.post( f"{self.endpoint}/stream", - json={"prompt": prompt, "max_new_tokens": 256}, + json={"messages": messages, "max_new_tokens": 256}, stream=True, ) for line in response.iter_lines(): if line: - # data = json.loads(line) data_str = line.decode("utf-8") if data_str.startswith("data: "): data = json.loads(data_str[6:])