Skip to content

Commit

Permalink
Minor logging and formatting changes
Browse files Browse the repository at this point in the history
Add default `llm_bots` configuration to Docker
Implement persona support from NeonGeckoCom/neon-llm-core#3
  • Loading branch information
NeonDaniel committed Dec 13, 2023
1 parent 461dd8d commit fc67a4e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ LABEL vendor=neon.ai \
ENV OVOS_CONFIG_BASE_FOLDER neon
ENV OVOS_CONFIG_FILENAME diana.yaml
ENV XDG_CONFIG_HOME /config
COPY docker_overlay/ /
ENV CHATBOT_VERSION v2

COPY docker_overlay/ /
RUN apt update && apt install -y git
WORKDIR /app
COPY . /app
RUN pip install /app
Expand Down
12 changes: 9 additions & 3 deletions docker_overlay/etc/neon/diana.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
log_level: INFO
log_level: DEBUG
logs:
level_overrides:
error:
Expand All @@ -8,7 +8,7 @@ logs:
info: []
debug: []
MQ:
server: api.neon.ai
server: neon-rabbitmq
port: 5672
users:
mq_handler:
Expand All @@ -19,4 +19,10 @@ LLM_CHAT_GPT:
role: "You are trying to give a short answer in less than 40 words."
context_depth: 3
max_tokens: 100
num_parallel_processes: 2
num_parallel_processes: 2
llm_bots:
chat_gpt:
- name: assistant
description: You are a personal assistant who responds in 40 words or less
- name: author
description: You will respond as an author and expert in literary history
2 changes: 2 additions & 0 deletions neon_llm_chatgpt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from neon_llm_chatgpt.rmq import ChatgptMQ
from neon_utils.log_utils import init_log


def main():
init_log(log_name="chatgpt")
# Run RabbitMQ
chatgptMQ = ChatgptMQ()
chatgptMQ.run(run_sync=False, run_consumers=True,
Expand Down
7 changes: 4 additions & 3 deletions neon_llm_chatgpt/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from typing import List, Dict
from neon_llm_core.llm import NeonLLM
from ovos_utils.log import LOG


class ChatGPT(NeonLLM):
Expand Down Expand Up @@ -71,7 +72,7 @@ def _system_prompt(self) -> str:
return self.role

def warmup(self):
self.model
_ = self.model

def get_sorted_answer_indexes(self, question: str, answers: List[str], persona: dict) -> List[int]:
"""
Expand Down Expand Up @@ -102,7 +103,7 @@ def _call_model(self, prompt: List[Dict[str, str]]) -> str:
max_tokens=self.max_tokens,
)
text = response.choices[0].message['content']

LOG.debug(text)
return text

def _assemble_prompt(self, message: str, chat_history: List[List[str]], persona: dict) -> List[Dict[str, str]]:
Expand Down Expand Up @@ -153,4 +154,4 @@ def _embeddings(self, question: str, answers: List[str], persona: dict) -> (List
embeddings = get_embeddings(texts, engine="text-embedding-ada-002")
question_embeddings = embeddings[0]
answers_embeddings = embeddings[1:]
return question_embeddings, answers_embeddings
return question_embeddings, answers_embeddings
11 changes: 8 additions & 3 deletions neon_llm_chatgpt/rmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ def model(self):
return self._model

def warmup(self):
self.model
"""
Initialize this LLM to be ready to provide responses
"""
_ = self.model

@staticmethod
def compose_opinion_prompt(respondent_nick: str, question: str, answer: str) -> str:
return f'Why Answer "{answer}" to the Question "{question}" generated by Bot named "{respondent_nick}" is good?'
def compose_opinion_prompt(respondent_nick: str, question: str,
answer: str) -> str:
return (f'Why Answer "{answer}" to the Question "{question}" '
f'generated by Bot named "{respondent_nick}" is good?')
4 changes: 3 additions & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# model
openai[embeddings]~=0.27
# networking
neon_llm_core~=0.1.0
# neon_llm_core~=0.1.0
neon-llm-core[chatbots]@git+https://github.com/neongeckocom/neon-llm-core@FEAT_ConfigureChatbotPersonas
ovos-utils~=0.0.32

0 comments on commit fc67a4e

Please sign in to comment.